222 - Topic 14 - Multivariate Integration

1706 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('y,t') # drawing R using horizontal strips needed for dxdy ystart = 0 yend = 2 xstart = y^2 xend = 4 + 0*y # need this second term so that I can call xend for various y values... G1 =implicit_plot(x==xstart,(x,0,4),(y,ystart,yend))+implicit_plot(x==xend,(x,0,4),(y,ystart,yend)) for k in range(1,20): yvalue = k*(2-0)/20 G1 += parametric_plot((t,yvalue),(t,xstart(y=yvalue),xend(y=yvalue)),color='red',thickness=5) G1.show() # drawing R using vertical strips needed for dydx xstart = 0 xend = 4 ystart = 0*x yend = sqrt(x) G2 = implicit_plot(y==ystart,(x,xstart,xend),(y,0,2))+implicit_plot(y==yend,(x,xstart,xend),(y,0,2)) for k in range(1,50): xvalue = k*(4-0)/50 G2 += parametric_plot((xvalue,t),(t,ystart(x=xvalue),yend(x=xvalue)),color='red',thickness=5) G2.show() 
       

f = y/(x^2+1) 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_28.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/tmpJiQI9y/___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-8.7/local/lib/python2.7/site-packages/sage/misc/functional.py", line 753, in integral
    return x.integral(*args, **kwds)
  File "sage/symbolic/expression.pyx", line 12361, in sage.symbolic.expression.Expression.integral (build/cythonized/sage/symbolic/expression.cpp:63599)
  File "/home/sageserver/sage-8.7/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.py", line 817, in integrate
    return definite_integral(expression, v, a, b, hold=hold)
  File "sage/symbolic/function.pyx", line 998, in sage.symbolic.function.BuiltinFunction.__call__ (build/cythonized/sage/symbolic/function.cpp:11841)
  File "sage/symbolic/function.pyx", line 487, in sage.symbolic.function.Function.__call__ (build/cythonized/sage/symbolic/function.cpp:6820)
  File "sage/symbolic/function.pyx", line 1086, in sage.symbolic.function.BuiltinFunction._evalf_or_eval_ (build/cythonized/sage/symbolic/function.cpp:12980)
  File "/home/sageserver/sage-8.7/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.py", line 183, in _eval_
    return integrator(*args)
  File "/home/sageserver/sage-8.7/local/lib/python2.7/site-packages/sage/symbolic/integration/external.py", line 34, in maxima_integrator
    result = maxima.sr_integral(expression, v, a, b)
  File "/home/sageserver/sage-8.7/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.py", line 817, in sr_integral
    self._missing_assumption(s)
  File "/home/sageserver/sage-8.7/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.py", line 1053, 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.