222 - Topic 14 - Multivariate Integration

295 days ago by Professor222

Multiple Integration Issues

John Travis

Mississippi College

Compute:

$  \int_{0}^{2}\int_{y^2}^{4}f(x,y)dx dy $

or

$  \int_{0}^{4}\int_{0}^{\sqrt{x}}f(x,y)dy dx $


var ('x,y') f = y/(1+x*x) show (f) 
       

                                
                            

                                
g = integrate(f,y) g 
       

                                
                            

                                
# We first try to integrate directly using the sage command g = integrate(f,x,y^2,4) 
       
Traceback (click to the left of this block for traceback)
...
Is (y-2)*(y+2) positive, negative or zero?
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_7.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("IyAgV2UgZmlyc3QgdHJ5IHRvIGludGVncmF0ZSBkaXJlY3RseSB1c2luZyB0aGUgc2FnZSBjb21tYW5kCgpnID0gaW50ZWdyYXRlKGYseCx5XjIsNCk="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmpbhqm9w/___code___.py", line 4, in <module>
    exec compile(u'g = integrate(f,x,y**_sage_const_2 ,_sage_const_4 )
  File "", line 1, in <module>
    
  File "/home/sageserver/sage-7.5/local/lib/python2.7/site-packages/sage/misc/functional.py", line 664, in integral
    return x.integral(*args, **kwds)
  File "sage/symbolic/expression.pyx", line 11660, in sage.symbolic.expression.Expression.integral (/home/sageserver/sage-7.5/src/build/cythonized/sage/symbolic/expression.cpp:64427)
  File "/home/sageserver/sage-7.5/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.py", line 775, in integrate
    return definite_integral(expression, v, a, b, hold=hold)
  File "sage/symbolic/function.pyx", line 996, in sage.symbolic.function.BuiltinFunction.__call__ (/home/sageserver/sage-7.5/src/build/cythonized/sage/symbolic/function.cpp:11437)
  File "sage/symbolic/function.pyx", line 486, in sage.symbolic.function.Function.__call__ (/home/sageserver/sage-7.5/src/build/cythonized/sage/symbolic/function.cpp:6480)
  File "sage/symbolic/function.pyx", line 1085, in sage.symbolic.function.BuiltinFunction._evalf_or_eval_ (/home/sageserver/sage-7.5/src/build/cythonized/sage/symbolic/function.cpp:12797)
  File "/home/sageserver/sage-7.5/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.py", line 178, in _eval_
    return integrator(*args)
  File "/home/sageserver/sage-7.5/local/lib/python2.7/site-packages/sage/symbolic/integration/external.py", line 24, in maxima_integrator
    result = maxima.sr_integral(expression, v, a, b)
  File "/home/sageserver/sage-7.5/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.py", line 807, in sr_integral
    self._missing_assumption(s)
  File "/home/sageserver/sage-7.5/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.py", line 1017, in _missing_assumption
    raise ValueError(outstr)
ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before evaluation *may* help (example of legal syntax is 'assume((y-2)*(y+2)>0)', see `assume?` for more details)
Is (y-2)*(y+2) positive, negative or zero?
# The "assume" command helps deal with some of these symbolic issues assume(y>0,y<2) g = integrate(f,x,y^2,4) g 
       

                                
                            

                                
# To finish the double integral, integrate now with respect to y integrate(g,y,0,2) 
       

                                
                            

                                
# This command makes sage forget all previous assumptions...essentially starts over the "proof" forget() 
       
assume(y>0,y<2) integrate(integrate (f,x,y^2,4),y,0,2) 
       

                                
                            

                                
# Notice what happens here if we don't assume x is nonnegative g = integrate(f,y,0,sqrt(x)) g 
       

                                
                            

                                
# Notice what happens here if we assume that x is nonnegative--so that sqrt(x) is assumed to be real valued assume(x>0) g = integrate(f,y,0,sqrt(x)) show(g) 
       

                                
                            

                                
# Finish up by integrating now with respect to x integrate(g,x,0,4) 
       

                                
                            

                                
var('r,t') h = f(x=r*cos(t),y=r*sin(t)) h 
       

                                
                            

                                
c = atan(1/2) 
       
assume(cos(t)>0) show(h) I1 = integrate(r*h,r,0,4/cos(t)) show(I1) I2 = integrate(I1,t,0,c) show(I2) 
       

                                
                            

                                
I3 = integrate(r*h,r,0,cos(t)/sin(t)^2) show(I3) I4 = integrate(I1,t,c,pi/2) show(I4) 
       
Traceback (click to the left of this block for traceback)
...
ValueError: Integral is divergent.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_27.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("STMgPSBpbnRlZ3JhdGUocipoLHIsMCxjb3ModCkvc2luKHQpXjIpCnNob3coSTMpCkk0ID0gaW50ZWdyYXRlKEkxLHQsYyxwaS8yKQpzaG93KEk0KQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmpkplZff/___code___.py", line 5, in <module>
    I4 = integrate(I1,t,c,pi/_sage_const_2 )
  File "/home/sageserver/sage-6.7/local/lib/python2.7/site-packages/sage/misc/functional.py", line 663, in integral
    return x.integral(*args, **kwds)
  File "sage/symbolic/expression.pyx", line 10712, in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:52942)
  File "/home/sageserver/sage-6.7/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.py", line 761, in integrate
    return definite_integral(expression, v, a, b, hold=hold)
  File "sage/symbolic/function.pyx", line 994, in sage.symbolic.function.BuiltinFunction.__call__ (build/cythonized/sage/symbolic/function.cpp:10866)
  File "sage/symbolic/function.pyx", line 502, in sage.symbolic.function.Function.__call__ (build/cythonized/sage/symbolic/function.cpp:6802)
  File "sage/symbolic/function.pyx", line 1065, in sage.symbolic.function.BuiltinFunction._evalf_or_eval_ (build/cythonized/sage/symbolic/function.cpp:11523)
  File "/home/sageserver/sage-6.7/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.py", line 176, in _eval_
    return integrator(*args)
  File "/home/sageserver/sage-6.7/local/lib/python2.7/site-packages/sage/symbolic/integration/external.py", line 23, in maxima_integrator
    result = maxima.sr_integral(expression, v, a, b)
  File "/home/sageserver/sage-6.7/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.py", line 782, in sr_integral
    raise ValueError("Integral is divergent.")
ValueError: Integral is divergent.