| # Maple function "int" calculates single integrals only. | # For example: > f:= x-> x*cos(2*x); # Define Integrand Function f of One Variable x. < f := x cos(2 x) > I1:= int(f(x),x=0..Pi/2); # Calculate definite integral of f on [0, Pi/2]. < I1 := 1/2 | # Get explicit answer for integral; Note: "Pi = 4*arctan(1)" is a Maple constant; | # "Pi" is Also the Area of Circle of Unit Radius. | # DO NOT use "I:=" since "I" is Maple Reserved Word for Imaginary Unit "sqrt(-1)", | # like "D" is Maple Reserved Word for Derivative. | # Same Answer is Produced Directly by > int(x*cos(2*x),x=0..Pi/2); < 1/2
| # Following Examples are Variations of Examples from Math 210 Calculus III | # Textbook Multivariable Calculus, Third Edition, by James Stewart | # from Section 13.2 Double Integrals Over Rectangles | # and Section 13.3 Over General Regions. | # First Example is Degenerate Function Factored into | # x-Function times y-Function, i.e., f(x,y) = g(x) * h(y). > f:=(x,y)->sin(2*x)*cos(3*y); # Defines Function f of 2 Variables (x,y): < f := (x,y) -> sin(2 x) cos(3 y) > I2: = int(int(f(x,y),x=0..Pi/2),y=0..Pi/2); # Calculates as Interated Integral < I2 := -1/3 | # Or Answer Can be Calculated as Product of Two Single Integrals: > int(sin(2*x),x=0..Pi/2)*int(cos(3*y),y=0..Pi/2); < -1/3 | # Getting the Same Answer! | # Note that Double Integral is Calculated as Iterated or Partial Integrals | # in General, Using Maple's Single Integral Function "int" Twice in Nest.
> f:=(x,y)->exp(4*x-5*y);a:=0;b:=2;c:=0;d:=3; # Define Function and Limits. < f := (x,y) -> exp(4 x - 5 y) < a := 0 < b := 2 < c := 0 < d := 3 > I3 := int(int(f(x,y),x=a..b),y=c..d); # Form for General Double Integral | # on Rectangle [a, b] X [c, d]: < I3 := - 1/20 exp(-7) + 1/20 exp(-15) + 1/20 exp(8) - 1/20 | # Maple Initially Generates Algebraic Answer: Ask for Floating Point Evaluation: > evalf(%); # "percent" Agument Means Evaluate Last Expression: < 148.9978538 | # Giving Answer Value to Default 10 Floating Point (Real) Digits; | # Else Use "evalf(I3,20)" for 20 or Replace "20" by Number of Choice. | # Since by Law of Exponents f(x,y) = exp(4*x-5*y) = exp(4*x) * exp(-5*y), | # Function is Degenerate and Can by Calculated by Simultaneous Integrals | # in x and y (to 20 digits for kicks {%>)}): > evalf(int(exp(4*x),x=a..b)*int(exp(-5*y),y=c..d),20); < 148.99785377328325203
| # This Double Integrand Can Not Easily be Factored: > f:=(x,y)->y*cos(x*y);a:=0;b:=Pi;c:=1;d:=2; < f := (x,y) -> y cos(x y) < a := 0 < b := Pi < c := 1 < d := 2 > I4 := int(int(f(x,y),x=a..b),y=c..d); # Integrate 1st in x, 2nd in y: < 2 < I4 := - ---- < Pi < | # Since This and Similar Integral in Text was Easy One Way Than the Other, | # We Try Opposite Order of Integration: > I4 := int(int(f(x,y),y=c..d),x=a..b); # Integrate 1st in y, 2nd in x: < 2 < I4 := - ---- < Pi < | # Get Same Answer without Maple Complaint, But Maple could have Done Both | # the Same Way (Need to Go Deeper into Maple to Find Out).
| # Similar Example of Integral Over Bounded Domain Between Two Parabolas | # in xy-Plane is Treated in Section 13.3: > f:=(x,y)->2*x^2+2*y^2;a:=-sqrt(5/3);b:=sqrt(5/3);c:=4*x^2;d:=5+x^2; < 2 2 < f := (x,y) -> 2 x + 2 y < < 1/2 < a := - 1/3 15 < < 1/2 < b := 1/3 15 < < 2 < c := 4 x < < 2 < d := 5 + x | # Here, x-Limits of Integration Come From Solving for Intersection of | # Lower Domain Boundary c := g1(x) = 4*x^2 and | # Upper Domain Boundary d := g2(x) = 5+x^2, i.e., | # for x-Values: > solve(4*x^2=5+x^2,x); < 1/2 1/2 < 1/3 15 , - 1/3 15 | # Or in Reverse Order, a := -sqrt(5/3) and b := sqrt(5/3): > I5 := int(int(f(x,y),y=c..d),x=a..b); # Must Do y-Integration First! < 1640 1/2 < I5 := ---- 15 < 27 > I5indefinite := int(int(f(x,y),y),x); # Checking Indefinite Integral < 3 3 < I5indefinite := 2/3 x y + 2/3 y x | # This is a Type I Integral, Integration of Type II Integrals are Similar, | # Except x-Integration is Done First, Followed by y-Integration.
| ## See Stewart/Section 13.7 Triple Integrals and Center of Mass > rho:=abs(x)*y*z; # define density function < rho := abs(x)*y*z | ## Calculate Mass M0 as Triple Integral over Volume V | ## inside Parabolic Cylinder y = x^2, to left of Plane y = 2, | ## intersecting the Parabola at x = +sqrt(2) and x = -sqrt(2), | ## over Plane z = 0 and under plane z = 3*y | ## Leading to Triple Integral: > M0:=evalf(int(int(int(rho,z=0..3*y),y=x^2..2),x=-sqrt(2)..sqrt(2))); < M0 := 28.80000000 | ## Vector Radius Arm about Coordinate Planes: > varm:=vector([x,y,z]); < varm := vector([x, y, z]) | ## Mass Weighted Average of Radius Arms = Center of Mass Coordinates | ## Leading to Triple Integrals Very Much Like M0: > xbar:=evalf(int(int(int(x*rho,z=0..3*y),y=x^2..2),x=-sqrt(2)..sqrt(2))/M0); > ybar:=evalf(int(int(int(y*rho,z=0..3*y),y=x^2..2),x=-sqrt(2)..sqrt(2))/M0); > zbar:=evalf(int(int(int(z*rho,z=0..3*y),y=x^2..2),x=-sqrt(2)..sqrt(2))/M0); < xbar := 0 < ybar := 1.666666667 < zbar := 3.333333333 | ## Center of Mass Vector = (Myz, Mxz, Mxy)/M0 = (xbar, ybar, zbar), | ## Myz is the Moment about yz-Plane (i.e., moment arm = x), | ## Mxz is the Moment about xz-Plane (i.e., moment arm = y), | ## Mxy is the Moment about xy-Plane (i.e., moment arm = z): > CenterOfMass:=vector([xbar,ybar,zbar]); < CenterOfMass := vector([0, 1.666666667, 3.333333333]) | # Note Moment about yz-Plane is Zero Since x is Odd function in Volume V.
Email Comments or Questions to hanson@uic.edu