MaplePartialDiffIntEx.mws

Partial Differentiation and Multiple Integration Examples

Use these examples for syntax.

Partial Differentiation Examples

The capital "D" produces a statement of what you want to do and the value(%) computes the partial derivative.

>    Diff(3*x*sin(4*x*y^2),x);

Diff(3*x*sin(4*x*y^2),x)

>    value(%);

3*sin(4*x*y^2)+12*x*cos(4*x*y^2)*y^2

The small "d" computes the partial derivative immediately.

>    diff(3*x*sin(4*x*y^2),x);

3*sin(4*x*y^2)+12*x*cos(4*x*y^2)*y^2

>    diff((2*y^3-4*x)*(sin(2*y))^2,y);

6*y^2*sin(2*y)^2+4*(2*y^3-4*x)*sin(2*y)*cos(2*y)

Here is a second partial derivative.

>    diff(3*y*sin(4*y*x^2),x,x);

-192*y^3*sin(4*y*x^2)*x^2+24*y^2*cos(4*y*x^2)

>    Diff(3*y*sin(4*y*x^2),x,x);

Diff(3*y*sin(4*y*x^2),`$`(x,2))

>    value(%);

-192*y^3*sin(4*y*x^2)*x^2+24*y^2*cos(4*y*x^2)

In the example below we are looking at mixed second partial derivatives.  Note how they compare (equal).

>    Diff(y*x*sin(4*y*x^2),x,y);

Diff(sin(4*y*x^2)*y*x,x,y)

>    value(%);

-32*sin(4*y*x^2)*x^4*y^2+20*x^2*cos(4*y*x^2)*y+sin(4*y*x^2)

>    Diff(y*x*sin(4*y*x^2),y,x);

Diff(sin(4*y*x^2)*y*x,y,x)

>    value(%);

-32*sin(4*y*x^2)*x^4*y^2+20*x^2*cos(4*y*x^2)*y+sin(4*y*x^2)

This time we have a function of three variables.

>    Diff(x*y*sin(4*z*x^2),z);

Diff(y*x*sin(4*z*x^2),z)

>    value(%);

4*y*x^3*cos(4*z*x^2)

Here are some third partial derivatives.

>    Diff(3*x*y*sin(4*x^2),x,x,x);

Diff(3*x*y*sin(4*x^2),`$`(x,3))

>    value(%);

-1152*y*sin(4*x^2)*x^2+72*y*cos(4*x^2)-1536*x^4*y*cos(4*x^2)

>    Diff(3*x*y*sin(4*x^2),x,y,x);

Diff(3*x*y*sin(4*x^2),x,y,x)

>    value(%);

72*cos(4*x^2)*x-192*x^3*sin(4*x^2)

>    diff(3*x*y*sin(4*x^2),x,x,y);

72*cos(4*x^2)*x-192*x^3*sin(4*x^2)

You can give a name to the function you wish to differentiate.

>    f:=sin(3*x^2)/(2*y^3+4*x);

f := sin(3*x^2)/(2*y^3+4*x)

>    diff(f,x);

6*cos(3*x^2)*x/(2*y^3+4*x)-4*sin(3*x^2)/(2*y^3+4*x)^2

>    diff(f,y);

-6*sin(3*x^2)/(2*y^3+4*x)^2*y^2

>    poly1:=5*x^4-4*x^3*y+3*x^2*y^2-2*x*y^3;

poly1 := 5*x^4-4*x^3*y+3*x^2*y^2-2*x*y^3

>    diff(poly1,x,x,y);

-24*x+12*y

>    diff(ln(x^2+y),x,y);

-2*x/(x^2+y)^2

>    diff(y*ln(x^2+x),y,y);

0

Here is an alternate notation.

>    diff(y*ln(x^2+x),x,x,x,x);

24*y/(x^2+x)^3*(2*x+1)^2-12*y/(x^2+x)^2-6*y*(2*x+1)^4/(x^2+x)^4

>    diff(y*ln(x^2+x),x$4);

24*y/(x^2+x)^3*(2*x+1)^2-12*y/(x^2+x)^2-6*y*(2*x+1)^4/(x^2+x)^4

>    Diff(exp(x),x$5);

Diff(exp(x),`$`(x,5))

>    value(%);

exp(x)

>    Diff((2*x)^(y^2),x,y);

Diff((2*x)^(y^2),x,y)

>    value(%);

2*(2*x)^(y^2)*y^3*ln(2*x)/x+2*(2*x)^(y^2)*y/x

Integration Examples

Notice the difference between "Int" and "int".  In the indefinite integration you will need to know that you must add an arbitrary function of the "other" variable.

>    Int(x*sqrt(3*y^2+4),x);

Int(x*(3*y^2+4)^(1/2),x)

>    value(%);

1/2*x^2*(3*y^2+4)^(1/2)

>    Int(x*sqrt(3*y^2+4),y);

Int(x*(3*y^2+4)^(1/2),y)

>    value(%);

x*(1/2*y*(3*y^2+4)^(1/2)+2/3*3^(1/2)*arcsinh(1/2*3^(1/2)*y))

Here is an iterated double integral.

>    Int(Int(y*sqrt(3*x+4),x=0..1),y=0..1);

Int(Int(y*(3*x+4)^(1/2),x = 0 .. 1),y = 0 .. 1)

>    value(%);

7/9*7^(1/2)-8/9

>    int(int(y*sqrt(3*x+4),x=0..1),y=0..1);

7/9*7^(1/2)-8/9

You can use evalf to approximate.

>    evalf(%);

1.168917686

>    Int(Int(x*exp(x^2+2),x=0..y),y=0..1);

Int(Int(x*exp(x^2+2),x = 0 .. y),y = 0 .. 1)

>    value(%);

-1/4*I*exp(2)*Pi^(1/2)*erf(I)-1/2*exp(2)

>    evalf(%);

1.709279852

Here are some iterated triple integrals (P 986 # 1, 4, 10, 12).

>    Int(Int(Int(x+y+z,x=0..1),y=0..2),z=0..3);

Int(Int(Int(x+y+z,x = 0 .. 1),y = 0 .. 2),z = 0 .. 3)

>    value(%);

18

>    int(int(int(x+y+z,x=0..1),y=0..2),z=0..3);

18

>    Int(Int(Int(z,z=0..sqrt(y^2-9*x^2)),x=0..y/3),y=0..9);

Int(Int(Int(z,z = 0 .. (y^2-9*x^2)^(1/2)),x = 0 .. 1/3*y),y = 0 .. 9)

>    value(%);

729/4

>    Int(Int(Int(y,z=2*x^2+y^2..4-y^2),y=0..sqrt(2-x^2)),x=0..sqrt(2));

Int(Int(Int(y,z = 2*x^2+y^2 .. 4-y^2),y = 0 .. (2-x^2)^(1/2)),x = 0 .. 2^(1/2))

>    value(%);

16/15*2^(1/2)

>    Int(Int(Int(z*exp(-x^2*y^2),x=0..6-2*y-3*z),z=0..2-2*y/3),y=0..3);

Int(Int(Int(z*exp(-x^2*y^2),x = 0 .. 6-2*y-3*z),z = 0 .. 2-2/3*y),y = 0 .. 3)

>    evalf(%);

2.118384657

Observe that Maple cannot evaluate the iterated triple integral above completely to give an exact analytical result.

>    int(int(int(z*exp(-x^2*y^2),x=0..6-2*y-3*z),z=0..2-2*y/3),y=0..3);

int(-1/72*(-8*y^2*exp(y^2)^36*exp(y^4)^4+24*y*exp(y^2)^36*exp(y^4)^4+72*erf(-6*y+2*y^2)*y^2*Pi^(1/2)*exp(y^2)^36*exp(y^4)^4-48*erf(-6*y+2*y^2)*y^3*Pi^(1/2)*exp(y^2)^36*exp(y^4)^4+8*erf(-6*y+2*y^2)*y^4*...
int(-1/72*(-8*y^2*exp(y^2)^36*exp(y^4)^4+24*y*exp(y^2)^36*exp(y^4)^4+72*erf(-6*y+2*y^2)*y^2*Pi^(1/2)*exp(y^2)^36*exp(y^4)^4-48*erf(-6*y+2*y^2)*y^3*Pi^(1/2)*exp(y^2)^36*exp(y^4)^4+8*erf(-6*y+2*y^2)*y^4*...
int(-1/72*(-8*y^2*exp(y^2)^36*exp(y^4)^4+24*y*exp(y^2)^36*exp(y^4)^4+72*erf(-6*y+2*y^2)*y^2*Pi^(1/2)*exp(y^2)^36*exp(y^4)^4-48*erf(-6*y+2*y^2)*y^3*Pi^(1/2)*exp(y^2)^36*exp(y^4)^4+8*erf(-6*y+2*y^2)*y^4*...

>    evalf(%);

2.118384657

The best we can do is approximate.