Advanced Calculus Functions

This Notebook illustrates how to use the functions in the Advanced Calculus Package.

Initialization

To use the functions in the Advanced Calculus Package, the package must first be `loaded' into the program. Do this is by evaluating the statement

Needs["Calculus`Advanced`"]

Note: the notation i, j, k for the standard unit vectors is avoided since it conflicts too easily with variables named i, j, k in Mathematica. A vector is always represented by a list of numbers or expressions:

v = {1,2,3}; w = {4,5};

r[t_] = {t, t^2, t^3};

Vector

The function Vector[v0,v1] creates a thick line segment from v0 to v1 as a Graphics3D object which can be used to plot vectors.

Example:

Show[{Vector[{0,0,0}, {1,2,3}],
Vector[{0,0,0}, {-2,3,-1}]},
Axes->Automatic,
BoxStyle->GrayLevel[0.7]]

Norm

The function Norm[v] calculates the norm (or the length) of a vector v.

Example:

Norm[{1,2,3}]

Example: Find the speed of a particle whose position function is

r[t_] = {t, t^2, t^3};

And find the distance travelled by the particle  from time t = 0 to t = 1.

Solution:

speed[t_] = Norm[r'[t]]

dist = Integrate[ speed[t], {t, 0, 1} ]

The decimal approximation is given by the function N[]:

N[dist]

Pr

The function Pr[v,w] computes the projection of the vector v onto the vector w.

Example:

Pr[{1,2,3},{4,5,6}]

Cross

The function Cross[v,w] computes the cross product of the 3-dimensional vectors v and w.

Example:

Cross[{1,2,3},{4,5,6}]

Grad

The function Grad[f] computes the gradient of a function f.  The default variables are x, y and z.

Example:

Grad[ x^2 + y^2 + z^2 ]

To use other variables, just include them as a second argument to the function.
(See the section on Vars for setting the default variables.)

Example:

Grad[ u^3 - v^3, {u,v} ]

Grad[ x^2 + y^2, {x,y} ]

Example: Find the equation of the plane tangent to the unit sphere at the point

p = {1/3,2/3,2/3};

Solution: The normal vector is given by the gradient of the equation of the sphere evaluated at the point p.

n = Grad[x^2 + y^2 + z^2] /. {x->1/3, y->2/3, z->2/3}

The equation of the tangent plane is

n.{x,y,z} == n.p

Vars

If  you will be working with a particular set of variables, say only x and y instead of x, y, and z, then you can change what the default variables are by setting the Vars.

Example:

Grad[ x^2 + y^2 ]

The gradient is a 3-dimensional vector because 3 variables x, y, and z are assumed.

To set the default variables to just x and y:

Vars = {x,y}

Grad[ x^2 + y^2 ]

Remember,  you can always specify the variables in any function that relies on them:

Grad[u^2 + v^2, {u,v}]

Be sure to reset Vars if you move onto three variable problems.

Vars = {x,y,z}

CriticalPoints

The function CriticalPoints[f] gives the critical points of the function f in its natural domain by solving the equations D[f,x] == 0 and D[f,y] == 0.

Example:

f[x_,y_] = x^2 - 3 x y + y^3;

CriticalPoints[f[x,y]]

This answer means that the points {9/4, 3/2} and {0,0} are critical points. Mathematica uses this format so that the results can be substituted into other expressions like Discriminant[f[x,y]], see the following section.

To use CriticalPoints[] with functions of other variables, just mention those variables as a second argument or reset Vars as usual.

Example:

cp = CriticalPoints[u^2 v - v^3 + v, {u, v} ]

Answers can be converted to decimal approximations with the function N[] :

N[cp]

You should ignore solutions which are complex numbers (those with the symbol I=Sqrt[-1] in them).

Discriminant

The function Discriminant[f] calculates the quantity fxx fyy - (fxy)^2 used in determining whether a critical point is a saddle point or a local max/min.

Example:

f[x_,y_] = x^2 - 3x y + y^3;

d = Discriminant[f[x,y]]

cp = CriticalPoints[f[x,y]]

Evaluate the discriminant at the critical points:

d /. cp

This shows that the second critical point {0,0} is a saddle point since d < 0. The first point {9/4, 3/2} is either a local max or local min since d > 0. We look at the second derivative in any direction to determine which.

D[f[x,y],{x,2}] /. {x->9/4, y->3/2}

Positive means curved up, so {9/4, 3/2} is a local min of f.

To use Discriminant[] with functions of other variables, just mention those variables as a second argument or reset Vars as usual (see the section on Vars).

Example:

Discriminant[ Cos[u v], {u,v} ]

Lagrange

The function Lagrange[f, g==c] computes the critical points of the function f under the constraint g == c.

Example: Find the maximum and minimum of the function

f[x_,y_] = x^2 - 3 x y + y^3;

on the unit circle.

Solution:

lp = Lagrange[f[x,y], x^2 + y^2 == 1]

To get numerical approximations for this answer apply the function N[] .

N[lp]

Evaluate f[x,y] at these points:

f[x,y] /. N[lp]

The maximum value is 1.924 and the minimum value is -1.716 (we ignore the other answers since they are complex numbers).

Curl

The function Curl[F] calculates the curl of a vector-valued function F.

Example:

F[x_,y_,z_] = {x^2 y, z^3 x, z^3};

Curl[F[x,y,z]]

Curl[F[x,y,z]] always returns a 3-dimensional vector. The variables can be changed to 3 other variables as usual:

Curl[{u v, v w, w u}, {u,v,w}]

Curl[] can be used with two dimensional vectors if the third coordinate is assumed to be 0:

Curl[{x^2 - y^2, 2 x y, 0}]

Div

The function Div[F] calculates the divergence of a vector valued function F.

Example:

F[x_,y_,z_] = {x^2 y, z^3 x, z^3};

Div[F[x,y,z]]

Other variables can be used instead of x, y, z as usual (see the section on Vars above):

Div[{u v, v w, w u}, {u,v,w}]

We can verify the theorem that Div[Curl[F]] == 0 for any vector function F by substituting general expressions for the components of F:

Clear[p,q,r]

Curl[{p[x,y,z], q[x,y,z], r[x,y,z]}]

Div[Curl[{p[x,y,z], q[x,y,z], r[x,y,z]}]]

Example: Calculate the flux of the vector function

F[x,y,z] = { x y, y z, z x };

through the surface of the unit cube 0 <= x, y, z <= 1.

Solution: The flux is the integral of F[x,y,z].n over the surface of the cube where n is the unit normal vector to the cube. By the Divergence Theorem this surface integral equals the triple integral of Div[F[x,y,z]] over the volume of the cube.

flux = Integrate[Div[F[x,y,z]], {z,0,1}, {y,0,1}, {x,0,1}]

VectorField

VectorField[F,{x,x0,x1},{y,x0,y1}] plots the 2-dimensional vector field F on a grid of points {x,y} where x0 <= x <= x1 and y0 <= y <= y1. 
VectorField[F, {x, x0, x1, dx}, {y, y0, y1, dy}] will space the grid points {dx,dy} apart. Options are passed to Show[].

Example:

VectorField[{x/5,y/5}, {x,-10,10,2}, {y,-10,10,2},
	AxesLabel->{"x","y"}]

VectorField[{-y,x}/Sqrt[x^2+y^2], {x,-10,10,2}, {y,-10,10,2},
	AxesLabel->{"x","y"}]

LineIntegrate

LineIntegrate[f, r, {t, a, b}] computes the line integral  of the function f along the curve parameterized by the vector function r from t == a to t == b. 

Examples:

LineIntegrate[x, {t,t^2}, {t,0,1}]

LineIntegrate[x y z, {t, 2t, t^2}, {t,0,1}]

You can use other variables instead of x, y, and z by including them in a list as the last argument.

LineIntegrate[u v w, {t, 2t, t^2}, {t,0,1}, {u,v,w}]

FlowIntegrate

FlowIntegrate[F, r, {t, a, b}] computes the flow integral  of the vector field F along the curve parameterized by the vector function r from t == a to t == b. 

Examples:

FlowIntegrate[{-y,x}, {t,t^2}, {t,0,1}]

FlowIntegrate[{x^2y,y^2z,z^2x}, {t,t^2,t^3}, {t,0,1}]

You can use other variables instead of x, y, and z by including them in a list as the last argument.

FlowIntegrate[{u^2v,v^2w,w^2u}, {t,t^2,t^3}, {t,0,1}, {u,v,w}]