![[Graphics:Images/name.bmp]](Images/name.gif)
![[Graphics:Images/title.gif]](Images/title.gif)
Mathematica is an extremely powerful system for doing mathematics by computer. There are books and tutorials you can use to learn as much as you want to know about it, but you don't need to know very much at all to get it working for you.
Find a computer with Mathematica on it. Beware: SIPA lab computers do not have Mathematica, but all computers in the Lehman Library computer cluster do. (You can also find it in the labs at 213 Butler and 251 Mudd Engineering Terrace).
To start, select Programs, then Quantitative Apps., Mathematica, then Mathematica 5.2.
Run through the various exercises below, and see if you get what I get.
You enter the things that follow the In[ ] tags, and Mathematica responds with the things following the Out[ ] tags.
To input a new cell, get a horizontal black line by clicking the cursor after the cell you want your input to follow---then start typing. When you've finished entering data, hit the Shift-Return keys together to record it.
![[Graphics:Images/index_gr_1.gif]](Images/index_gr_1.gif)
![[Graphics:Images/index_gr_3.gif]](Images/index_gr_3.gif)
You can get a precise numerical answer by applying the function N[ ] to it:
![[Graphics:Images/index_gr_5.gif]](Images/index_gr_5.gif)
The Plot[ ] command does the plotting. You give it the function you want plotted, the range of x values you want it plotted for, and tell it where you want the axes origin to be:
![[Graphics:Images/index_gr_7.gif]](Images/index_gr_7.gif)
![[Graphics:Images/index_gr_10.gif]](Images/index_gr_10.gif)
You don't always need the AxesOrigin command. Sometimes Mathematica guesses correctly:
![[Graphics:Images/index_gr_13.gif]](Images/index_gr_13.gif)
You can go to Help to find a range of commands and options. Or, to find a description of any command, just type a question mark ? followed by the name of the command
![[Graphics:Images/index_gr_16.gif]](Images/index_gr_16.gif)
![[Graphics:Images/index_gr_18.gif]](Images/index_gr_18.gif)
Suppose we have the function of two variables , z= f[x,y], where
z = x^2+3*x*y +y^2
To obtain a 3-dimensional plot of this relationship, use the Plot3D command.
![[Graphics:Images/index_gr_20.gif]](Images/index_gr_20.gif)
Here's how it works
![[Graphics:Images/index_gr_22.gif]](Images/index_gr_22.gif)
Another kind of plotting uses the command "ContourPlot".
![[Graphics:Images/index_gr_25.gif]](Images/index_gr_25.gif)
This command plots the level curves of a function of 2 variables in the two-dimensional plane. Indifference curves, isoquants and other "iso-entities" are all level curves of functions.
Suppose, for example, the utility function is
U= x^(1/2)*y^(1/2)
To plot some level curves of this function, you supply the function, the range of x-values and the range of y-values. Here, x goes from 0 to 10 , and so does y.
![[Graphics:Images/index_gr_27.gif]](Images/index_gr_27.gif)
To get rid of the shading and see just the curves, add the option ContourShading->False, as below:
![[Graphics:Images/index_gr_30.gif]](Images/index_gr_30.gif)
To get just one specific contour --- say the one that keeps the value of the function at 5 --- add the Contours option as follows
![[Graphics:Images/index_gr_33.gif]](Images/index_gr_33.gif)
To get two or more, just add them to the list in the Contours argument.
![[Graphics:Images/index_gr_36.gif]](Images/index_gr_36.gif)
Let's say we want to graph a straight line
y = -5*x + 20
and the level curves of a utility function
U = x^(1/2)*y^(1/2)
on the same set of axes.
First, assign the name "line" to the plot of the line:
![[Graphics:Images/index_gr_39.gif]](Images/index_gr_39.gif)
Then assign the name "curves" to the level curves:
![[Graphics:Images/index_gr_43.gif]](Images/index_gr_43.gif)
To superimpose them, you can put them both in a Show[ ] commmand
![[Graphics:Images/index_gr_46.gif]](Images/index_gr_46.gif)
See?
![[Graphics:Images/index_gr_48.gif]](Images/index_gr_48.gif)
Suppose you want to solve the following equation for the variable y:
a*y^2 = b/x
You can use the Solve command:
![[Graphics:Images/index_gr_51.gif]](Images/index_gr_51.gif)
To apply it, just supply the equation to be solved with a double equal sign, then follow that with the variable you want to solve for.
![[Graphics:Images/index_gr_53.gif]](Images/index_gr_53.gif)
Sometimes there are multiple solutions. Solve will give you all it can find. Remember the quadratic formula?
![[Graphics:Images/index_gr_55.gif]](Images/index_gr_55.gif)
Beware: Sometimes it is hard to see the minus sign out in front. Can you see it in this next one?
![[Graphics:Images/index_gr_57.gif]](Images/index_gr_57.gif)
To solve two equations in two unknowns, just put both equations (with double equal signs), separated by a comma , inside braces { } and specify the variables to solve for.
For example, so solve the two equations
y/x = 15
x+y =25
for the variables x and y, do this:
![[Graphics:Images/index_gr_59.gif]](Images/index_gr_59.gif)
You can keep adding more equations, too.
To find the derivative of a function, use the command D[ ]
![[Graphics:Images/index_gr_61.gif]](Images/index_gr_61.gif)
For example,
![[Graphics:Images/index_gr_63.gif]](Images/index_gr_63.gif)
![[Graphics:Images/index_gr_65.gif]](Images/index_gr_65.gif)
To find integrals, use Integrate
![[Graphics:Images/index_gr_67.gif]](Images/index_gr_67.gif)
For example,
![[Graphics:Images/index_gr_69.gif]](Images/index_gr_69.gif)
To find the value of x that maximizes or minimizes some function one can often take the derivative, set it equal to zero, and solve for x. Mathematica can help with that.
For example, to find the value of x which maximizes
-3*x^2 + 2*x + 4
Combine Solve[ ] and D[ ] like this:
![[Graphics:Images/index_gr_71.gif]](Images/index_gr_71.gif)
To verify if this is correct, we can plot the function and take a look:
![[Graphics:Images/index_gr_73.gif]](Images/index_gr_73.gif)
Looks about right.
Then explore the tutorials by D' Andria and Withoff at http://library.wolfram.com/infocenter/Conferences/300/