Monday, November 13, 2023

Triple Integrals

 Triple Integral

 NOTE:

* The order of sending parameter to integral3 is : Integrand, constant lower limit, constant upper limit, 1var lower limit, 1var upper limit,  2var lower limit, 2var upper limit, 
     Example: If x: Const->Const 
                           y: Curve->Curve
                           z: Surface->Surface         then      integral3(f, xL, xU, yL, yU, zL, zU)
                      If  y: Const->Const 
                           x: Curve->Curve 
                           z: Surface->Surface         then       integral3(f, yL, yU, xL, xU, zL, zU)
                      If  z: Const->Const 
                           y: Curve->Curve 
                           x: Surface->Surface         then       integral3(f, zL, zU, yL, yU, xL, xU)

* For the constant limits no need to use function handlers like @(x) or @(y)  for 1 var limits, @(x,y) or @(y,z) or @(x,z) for 2 var limits
* For constant integrand then use use function handlers then add 0.*x.*y.*z
    Example: If f=2 then give input as
                @(x,y,z) 2+0.*x.*y.*z

clear

clc

syms x y z

f = matlabFunction(input("Enter the integrand f(x,y,z) : "));

disp('f(x,y,z) :');

disp(f);

xL=input("Enter lower limit of x: ");

xU=input("Enter Upper limit of x: ");

yL=input("Enter lower limit of y: ");

yU=input("Enter Upper limit of y: ");

zL=input("Enter lower limit of z: ");

zU=input("Enter Upper limit of z: ");

 

d = integral3(f,xL,xU,yL,yU,zL,zU);

disp("Triple Integral of f(x,y,z) :");

disp(d);

 

 Write a program to evaluate Triple integral.

$$\int_0^1 \int_0^2 \int_1^2 (xyz^2) dxdydz$$

OUTPUT:

  Enter the integrand f(x,y,z): @(x,y,z)x.*y.*z.^2

f(x,y,z) : 

     @(x,y,z)x.*y.*z.^2

Enter lower limit of x: 0

Enter Upper limit of x: 1

Enter lower limit of y: 0

Enter Upper limit of y: 2

Enter lower limit of z: 1

Enter Upper limit of z: 2

Triple Integral of f(x,y,z) : 2.3333

 

$$\int_0^1 \int_0^x \int_0^{x+y} e^{x+y+z} dzdydx$$

OUTPUT: 

Enter the integrand f(x,y,z): @(x,y,z)exp(x+y+z)

f(x,y,z) :

     @(x,y,z)exp(x+y+z)

Enter lower limit of x: 0

Enter Upper limit of x: 1

Enter lower limit of y: 0

Enter Upper limit of y: @(x) x

Enter lower limit of z: 0

Enter Upper limit of z: @(x,y) x+y

Triple Integral of f(x,y,z) : 3.6263


 




No comments:

Post a Comment

Search This Blog