(*You can find various helpful videos that Wolfram has provided on getting started with Mathematica at
http://url.wolfram.com/H7tSri/ and http://url.wolfram.com/wSq9_6/. Versions 8 or 9 of Mathematica are like Wolfram Alpha in that it allows you to type things like “plot” or “integrate” or “differentiate”: Hit the equal sign in a new cell and type plot x^2, hit ENTER or SHIFT-RETURN, and you’ll see the official code generated. In the BASIC COMMANDS section of the BASIC MATH ASSISTANT you’ll find helpful tools, as well.

To plot a function f, remember that Mathematica syntax is f[x,y,...], and intervals are given by {x,a,b}. Common functions are capitalized, such as Exp[x], Log[x], Sin[x], Cos[x], ArcTan[x]. Differentiation is denoted by D[f,x], and higher-order partial derivatives are computed with D[f,x,y] and D[f,{x,2}]. When you want to indicate a product of variables, you must either use x*y or, easier, a space between them. Vector-valued functions are written with their components in curly brackets. Somewhat confusingly, if we want to plot several functions, we also use curly brackets to enclose the list of functions.

A general word of advice. A semicolon at the end of a line suppresses any output of the execution of that line. A few other pointers: % will recall the last result, and   /. {x->2} will evaluate the preceding expression at x=2.

The Help menu is incredibly useful. Select the command or term and look under Help for "Find Selected Function." This will give you instructions on syntax and lots of examples, including lists of options that are available. Also, the Basic Math Assistant window under the Palettes menu has just about everything you might need. A word to the wise: Be careful not to reuse the same letter without using ClearAll; when you get inexplicable results, it is often due to Mathematica's remembering a prior definition of the letter or your redefining it subsequently in your document. 

Note that you can also rotate 3-D figures in real time by clicking/dragging with your mouse.

Most important: To evaluate a command (or list of commands), either go to the Evaluation menu or hit Enter or shift-Return.*)

f=Cos[x y];
D[f,x,y]
D[f,{x,2}]

%/. {x->0, y->2}

(*You can also define functions and use the more complicated syntax below. This is needed in more complicated arenas.*)

ClearAll[f];
f[x_,y_] := Cos[x y];
f[0,2]
f[s^2,Sqrt[t]]
D[f[x,y], x,y]

Plot[Cos[x],{x,0,Pi}]

Plot[{Cos[x],Sin[x]},{x,0,Pi}, PlotStyle->{Red,Blue}]

Plot3D[3x y^2-x^3,{x,-2,2},{y,-2,2}]
Plot3D[3x y^2-x^3,{x,-2,2},{y,-2,2},PlotRange->{-2,2}]

ParametricPlot3D[{Cos[t],Sin[t],t},{t,0,2Pi}]

ParametricPlot3D[{{Cos[t],Sin[t],t},{-Cos[t],-Sin[t],t}},{t,0,2Pi}]

ParametricPlot3D[{u Cos[v],u Sin[v], v},{u,-2,2},{v,0,4 Pi}]

(*The Solve command is useful when there is a straightforward algebraic solution. Otherwise use the FindRoot command.*)

ClearAll[f];
f[x_,y_]:= x^3-4x y+ y^2;
fx = D[f[x,y],x]
fy = D[f[x,y],y]
Solve[{fx == 0, fy == 0},{x,y}]

ClearAll[f];
f[x_]:=x^2- Cos[x];
FindRoot[f[x]==0,{x,Pi/6}]

(* Note what happens if we start Newton's method at an inappropriate location *)

FindRoot[f[x] == 0, {x, 0}]

(* If you want to evaluate an expression at the result of a previous computation, you can do so as follows. Note that the optional AspectRatio->Automatic will make the axes scaled evenly. You can also use the PlotRange command to specify what range you want to see. *)

ClearAll[f,a];
f[x_]:= Integrate[Exp[t^2],{t,0,x}];
a[y_]:= x/.FindRoot[f[x]==y,{x,1}]
Plot[{f[y],a[y]},{y,0,2}, AspectRatio->Automatic]
Plot[{f[y],a[y],y},{y,0,2}, AspectRatio->Automatic, PlotRange->{0,2},PlotStyle->{Red,Green,Dotted}]

TableForm[Table[{y,a[y],Sin[a[y]]},{y,0,2,.1}]]

(*Animation: Suppose we have two parametric curves f[t] and g[t] (in the plane or in space) and we want to make a movie of the chord joining f[t] and g[t] as t progresses through a certain interval. Here is an example of how we can do this.*)

ClearAll[f,g];
f[t_]:={Cos[t],Sin[t]};
g[t_]:= Evaluate[f[t] + t D[f[t],t]];
Curves = ParametricPlot[{f[t],g[t]},{t,0,2 Pi}];
Point1[t_]:= Graphics[{Magenta,PointSize[.03],Point[f[t]]}];
Point2[t_]:= Graphics[{Magenta,PointSize[.03],Point[g[t]]}];
seg[t_]:= Graphics[{Green,Thickness[.01],Line[{f[t],g[t]}]}];

Animate[Show[{Curves,Point1[t],Point2[t],seg[t]},Ticks->None],{t,0,2Pi},AnimationRunning->False]

(* Suppose we want to write a little procedure to calculate the arclength of a parametric curve. We might proceed as follows. *)

Arclength[f_][t_]:=Integrate[Sqrt[D[f[u],u].D[f[u],u]],{u,0,t}]
h[t_]={2t,Cos[3t],Sin[3t]};
Arclength[h][t]

(* However, in more complicated situations, it is necessary to use a Module construction. Suppose we start with specified curvature and torsion functions κ (s) and τ (s) and we wish to draw an arclength-parametrized curve with those curvature and torsion functions. We must integrate the Frenet equations, starting at s=smin and going to s=smax. We have it set up so that the curve starts at the origin with its Frenet frame there the standard basis vectors. Note that we must denote the principal normal by NN, since N is reserved for the "numerical value" command in Mathematica.

Note that Mathematica can solve systems of differential equations numerically, using the NDSolve command. 

As a matter of curiosity, if you want to produce Greek letters, you can either go to Special Symbols and Characters under the Typesetting menu of the Basic Math Assistant (under Palettes) or, for example, type escape-kappa-escape. 

The next little program solves the ODEs to plot a curve with prescribed curvature and torsion, starting with the Frenet frame equal to the standard basis at the original value of s.*)

plotcurve[{κ_,τ_},smin_,smax_]:=ParametricPlot3D[Evaluate[Module[{x,T,NN,B},x[s]/.NDSolve[{x'[u]==T[u],T'[u]==κ[u]NN[u],NN'[u]==-κ[u]T[u]+τ[u]B[u],B'[u]==-τ[u]NN[u],x[smin]=={0,0,0},T[smin]=={1,0,0},NN[smin]=={0,1,0},B[smin]=={0,0,1}},{x,T,NN,B},{u,smin,smax}]]],{s,smin,smax}]

κ[s_]=1; τ[s_]=2;
plotcurve[{κ,τ},0,10]

κ[s_]=s; τ[s_]=2-s;
plotcurve[{κ,τ},0,5]

(* If you want to study level curves or level surfaces, the appropriate command is ContourPlot. *)

ContourPlot3D[{x^2+y^2+z^2==4, y^2-2x+x^2==0},{x,-2,2},{y,-2,2},{z,-2,2},AspectRatio->Automatic,Mesh->None]

(* The Manipulate command allows you to study in real time what happens when you vary one or more parameters in a certain function or procedure. *)

Manipulate[ContourPlot[x^2+k x y +y^2==1,{x,-2,2},{y,-2,2},PlotPoints->{60,60},PlotLabel->Style[Framed[x^2+k x y +y^2==1],Background->Lighter[Orange]]],{{k,0},-5,5}]

(* Matrices can be written with nested arrays {{a,b,c},{d,e,f}} or by choosing the Basic Math Assistant under the Palettes menu. The Eigensystem command produces the list of eigenvalues and then the corresponding eigenvectors. *)

A = {{1, 2}, {2, 3}};
MatrixForm[A]
Eigensystem[A]

Eigensystem[(({{1, 2}, {2, 3}}))]