Course 30189: Maths21A Summer 2009
Multivariable Calculus
CAS
Office: SciCtr 434

## Mathematica Laboratory

Some of the submitted graphics objects

Availability Mathematica can be obtained here. The current version is Mathematica 7. You need this version to do the assignment. Requesting the Mathematica Password requires a FAS email.
Installation After you downloaded the program to your computer, start the application and follow the instructions. During the installation progress, you have to enter the Harvard Licence number L2983-5986 (L2482-2405 for faculty staff). The number which you will get in return has to be entered in the Mathematica Registration page. You will then be sent a password by email. This is what you see during installation in Send me an email if you plan to use Mathematica on a linux system.
Getting the notebook
• The Mathematica laboratory can be obtained here. Save this text file as "lab.nb" on your desktop and click on it.
Running mathematica Mathematica is started like any other application on Macintoshs or PC's. On Linux, just type "mathematica" to start the notebook version, or "math" to start the terminal version.
Some frequently used commands:
 Plot[ x Sin[x],{x,-10,10}] Graph function of one variable Plot3D[ Sin[x y],{x,-2,2},{y,-2,2}] Graph function of two variables ParametricPlot[ {Cos[3 t],Sin[5 t]} ,{t,0,2Pi}] Plot planar curve ParametricPlot3D[ {Cos[t],Sin[t],t} ,{t,0,4Pi},AspectRatio->1] Plot space curve ParametricPlot3D[ {Cos[t] Sin[s],Sin[t] Sin[s],Cos[s]},{t,0,2Pi},{s,0,Pi}] Parametric Surface ContourPlot[ Sin[x y],{x,-2,2},{y,-2,2} ] Contour lines (traces) Integrate[ x Sin[x], x] Integrate symbolically NIntegrate[ Exp[-x^2],{x,0,10}] Integrate numerically D[ Cos^5[x],x ] Differentiate symbolically Series[Exp[x],{x,0,3} ] Taylor series DSolve[ x''[t]==-x[t],x,t ] Solution to ODE ContourPlot3D[x^2+2y^2-z^2==1,{x,-2,2},{y,-2,2},{z,-2,2}] Implicit surface
```ClassifyCriticalPoints[f_,{x_,y_}] := Module[{X,P,H,g,d,S},
ClassifyCriticalPoints[4 x y - x^3 y - x y^3,{x,y}]
```
Here is an example on how to solve a Lagrange problem for functions of 2 variables:
```F[x_,y_]:=2x^2+4 x y
G[x_,y_]:=x^2 y
Solve[{D[F[x,y],x]== L*D[G[x,y],x],D[F[x,y],y]==L*D[G[x,y],y],G[x,y]==1},{x,y,L}]
```
and here an example with functions of 3 variables:
```F[x_,y_,z_]:=x^2+y^2+z^2;
G[x_,y_,z_]:=x-y^2+z;
Solve[{D[F[x,y,z],x]== L*D[G[x,y,z],x],
D[F[x,y,z],y]== L*D[G[x,y,z],y],
D[F[x,y,z],z]== L*D[G[x,y,z],z],
G[x,y,z]==1},{x,y,z,L}]
```
or with two constraints:
```F[x_, y_, z_] := x^2 + y^2 + z^2;
G[x_, y_, z_] := x - y^2 + z;
H[x_, y_, z_] := x + y - 2;
Solve[{
D[F[x, y, z], x] == L*D[G[x, y, z], x] + M*D[H[x, y, z], x],
D[F[x, y, z], y] == L*D[G[x, y, z], y] + M*D[H[x, y, z], y],
D[F[x, y, z], z] == L*D[G[x, y, z], z] + M*D[H[x, y, z], z],
G[x, y, z] == 1, H[x, y, z] == 1}, {x, y, z, L, M}]
```
Here is an example how to check that a function solves a PDE:
```f[t_,x_]:=(x/t)*Sqrt[1/t]*Exp[-x^2/(4 t)]/(1+ Sqrt[1/t] Exp[-x^2/(4 t)]);
D[f[t,x],t]+f[t,x]*D[f[t,x],x]-D[f[t,x],{x,2}]
Simplify[%] Chop[%]
```