A Brief Introduction to Mathematica

Math 104 Calculus II, March 27, 2019
T. Ratliff, Wheaton College
ratliff_thomas@wheatoncollege.edu

A few things to begin with

* This is a Text cell that allows for comments. 
* All Mathematica commands are contained in Input cells (you can change to cell style in the Format menu) 
* The Help - Wolfram Documentation menu will be your friend
* We’ll only touch on a tiny subset of what Mathematica can do, so feel free to explore!

* To execute a command, you must press Shift-Return. 
	Execute the command below

Plot[ Cos[x]+Sin[x], {x,-Pi,3*Pi}]

Notice that every built-in Mathematica command begins with a capital letter, and that Mathematica uses square brackets [ ] to delimit inputs.

Mathematica can also find first and second derivatives, and both definite and indefinite integrals

D[Cos[x^2+Log[x]],x]

D[Cos[x^2+Log[x]],x,x]

Integrate[ArcSin[x],x]

Integrate[x*Exp[x], {x,0,13}]

You can get the numeric value of an output by using the N[ ] command

N[Integrate[x*Exp[x], {x,0,13}]]

Plotting surfaces of revolution

This is pretty cool. FYI, the RevolutionAxis option specifies that we’re rotating about the x-axis.

RevolutionPlot3D[x^2/4 + 1,{x,-1,3}, RevolutionAxis->{1,0,0}]

Some more on plots

If we want to plot an expression that isn’t a function, like an ellipse, we have to use a slightly different format. 
For example, to plot the ellipse
		((x^2)/4)+ ((y^2)/9)=1
we need to use the ContourPlot[ ] command. Be sure to notice the double equal sign == to indicate that we are asserting equality, not assigning the left side to equal the right side.

ContourPlot[x^2/4 + y^2/9 == 1, {x,-4,4},{y,-4,4}]

Or, a hyperbola

ContourPlot[x^2 - y^2== 1, {x,-4,4},{y,-4,4}]

We can also plot surfaces in 3-space that are not the graph of a function of two variables.  
	(x^2)+(y^2)-(z^2)=1

ContourPlot3D[x^2+y^2-z^2==1,{x,-4,4},{y,-4,4},{z,-4,4}]

Or, we use Plot3D[ ] if we have a function of two variables

Plot3D[x^2+y^2,{x,-4,4},{y,-4,4}]

Contour plots and plotting level curves

Let’s look at the surface z = (x^2)- (y^2)
A contour plot shows us the level curves of a surface.

The ColorFunction -> “Rainbow” option colors the plot so that blue is the lowest and red is highest. 
Look under Help > Wolfram Documentation and search for Color Schemes to see all the options. 

You can easily change the number of contours plotted, too.

ContourPlot[x^2-y^2,{x,-5,5},{y,-5,5},Contours-> 10, ColorFunction->"Rainbow"]

Or, we can get show the contours on the surface using the MeshFunctions option.

Plot3D[x^2-y^2,{x,-5,5},{y,-5,5},MeshFunctions->{#3&},Mesh->10, ColorFunction->"Rainbow"]

Or, as just a plain Plot3D with a different color scheme

Plot3D[x^2-y^2,{x,-5,5},{y,-5,5}, ColorFunction->"BlueGreenYellow"]

Accessing WolframAlpha

You can also access WolframAlpha by typing the equal sign = at the beginning of a line, enter your command, and then press Return. This is handy for the times you don’t know the Mathematica syntax. 
You can also use the + button to get more information, including access to WolframAlpha Pro