click here to view A Brief Introduction to Mathematica
Chapter One - Getting Started
Section One - Starting Mathematica
Section Two - Input and Output
Section Three - Brackets and Braces
Section Four - Exact and Approximate numbers and Built-in Constants
Section Five - Loading in Additional Packages
Chapter One Exercises
Chapter Two - Mathematical Functions
Section One - Built-In Functions
Section Two - Defining Functions and Equalities
Chapter Two Exercises
Chapter Three - Lists and Matrices
Section One - Lists
Section Two - Generating Lists
Section Three - Functions Involving Lists
Section Four - Displaying Tables and Matrices
Section Five - Plugging Into Expressions
Chapter Three Exercises
Chapter Four - Mathematica and Algebra
Chapter Four Exercises
Chapter Five - Solving Equations
Chapter Five Exercises
Chapter Six - Calculus
Section One - Limits
Section Two - Derivatives
Section Three - Integrals
Section Four - Series
Section Five - Differential Equations
Chapter Six Exercises
Chapter Seven - Linear Algebra
Chapter Seven Exercises
Chapter Eight - Two-Dimensional Plots
Section One - Basic Plots
Section Two - Plot Options
Section Three - Parametric Plots
Section Four - Plotting the Graphs of Equations
Chapter Eight Exercises
Chapter Nine - Three-Dimensional Plots
Section One - Basic 3-D Plots
Section Two - Plot3D Options
Section Three - Parametric 3D Plots
Chapter Nine Exercises
Solutions to Exercises
PermutationMult
CouchPlot
EulerPlot
and EulerPlot2
D4Plot
CurveVectors
TaylorPolynomial
and TaylorPlot
OsculatingPlot
PolarPlot
FirstDerivativeTest
NewtonsMethod
MeanValuePlot
NewtonMovie
DerivativeMovie
SpringSystem
TruthTable and
LogicalTypeCheck
WeirdDice and WeirdDiceNumber
RiemannPlot
PiByRelativelyPrime
ModularDisplay
Josephus
InfinityPlot
ConicInfo
CouchPlot is a program which animates the problem of trying to get a couch around an "L" corner in the hallways. The format is CouchPlot[a,b,w,n], where a and b are the hallway widths (a<b)m w is the couch width, and n is the number of animation frames. The longest couch that will make it around is displayed in red, and is present in all animation frames. To the right of the diagram is a graph of the current couch length. This animation uses the fact that the longest couch that will make it around the corner is also the shortest one that would get jammed in the hallway, so the red couch is actually a minimum. Here is a picture of CouchPlot, a Quicktime movie of the animation, and the actual notebook.

To see the CouchPlot movie, click here.
PermutationMult is a routine for multiplying permutations in their cycle form. The format for entering the permutations is as a list {perm1 , perm2, ... } where each permutation is given in the form {cycle1 , cycle2, ... }. For example, to multiply the permutations (1432)(568) by (132)(45)(678), you would use the command PermutationMult[ { {{1,4,3,2},{5,6,8}}, {{1,3,2},{4,5},{6,7,8}} }]. You do not have to enter any 1-cycles, although any 1-cycles inthe result will be listed. Before you can use PermutationMult, the package Permutations.nb in the DiscreteMath grouping must be loaded - the command for this is in the notebook. Here is an example of PermutationMult works:

EulerPlot and EulerPlot2 are commands for producing animated plots which illustrate Euler's method for approximating solutions to differential equations of the form y'=f(x,y) (essentially, the solution is assumed to be a straight line segment over a small interval, and the approximation is formed by joining these small line segments together). Both commands create a sequence of plots which show the approximations being built step-by-step; the difference in the two commands is that EulerPlot2 superimposes the solution onto the vector field for f(x,y) (this uses the PlotField from the Graphics group - the command to load this is in the notebook). To use EulerPlot to view y'=function in the plane from x=a to x=b and y=c to y=d, starting at the point (a,y0) and using x-intervals of width dx, use the command EulerPlot[ function ,{x,a,b,dx},{y,c,d,y0}] (EulerPlot2 is set up exactly the same way). Here is a sample output frame from EulerPlot and Quicktime movies of animations from EulerPlot and EulerPlot2:

To see the EulerPlot movie, click here. (you may have to hit "reload" to see the movie)
To see the EulerPlot2 movie, click here. (you may have to hit "reload" to see the movie)
D4Plot allows you to visualize the actions of the elements of the group D4 by creating an sequence of plots which when animated shows the motion of the square as it is rotated and reflected. The corners are colored to keep track of them, and at the end the resultant symmetry is shown and identified. The symmetries are r0, r90, r180, r270, h, v, d, and d1. In keeping with the standard notation for D4, the symmetries are applied starting with the rightmost and rotations are counterclockwise. For example, D4Plot[{h,d1,r90}] would apply a 90 degree counterclockwise rotation, a flip around the off-diagonal, and then a flip around the horizontal axis (the list of symmetries canbe as long as you want, but long ones may force the front end or kernel to run out of memory). Below is a picture of the final symmetry and a Quicktime movie of the animation for D4Plot[{h,d1,r90}]:

To see the movie, click here. (you may have to hit "reload" to see the movie)
When learning multivariate calculus, one of the hardest things to visualize are the unit tangent vector, principal normal vector, and binormal vector to a curve at a point. CurveVectors[{f,g,h},{t,a,b},n] creates an animated sequence of plots of the curve defined parametrically by x=f(t), y=g(t), z=h(t) as t goes from a to b using n frames of animation. The tangent vector is light blue, the principal unit normal vector is purple, and the binormal vector is in red. Below is a frame from the animation and a Quicktime movie of the entire animation:

To see the movie, click here. (you may have to hit "reload" to see the movie)
TaylorPolynomial and TaylorPlot
When using the Series command to find Taylor polynomials, Mathematica includes an error term of the appropriate order - which is great for theory but a bit difficult to manipulate for students just getting started. TaylorPolynomial[ f,{x,x0,n}] creates the n-th order Taylor Polynomial to f(x) at x=x0 with the error term stripped out. TaylorPlot[ f,{x,a,b},{x0,n}] creates a plot of the function and the n-th order Taylor polynomial at x=x0 (used in a Do loop, TaylorPlot can show the convergence of Taylor polynomials to the original function). The original funciton is in black, and the Taylor approximation is in light blue. Here is an example of TaylorPolynomial and TaylorPlot:

OsculatingPlot plots the osculating circle (the "best approximating circle") to a given curve at a given point. To plot the function f(x) over the range x=c to x=d and its osculating circle at x=x0, use OsculatingPlot[ f,{x,c,d},x0]. If the radius of the osculating circle is large (which happens often), OsculatingPlot will increase the x-range plotted to the entire circle can be seen. Here is an example of OsculatingPlot:

PolarPlot is a program I wrote to illuistrate graphing in polar coordinates. PolarPlot[f,{t,a,b}] does a polar plot of r(t) as t goes from a to b. PolarMovie[r,{t,a,b},n] creates a sequence of polar plots of r(t) from a to a value which goes up to b as the sequence progresses. These plots can then be animated to show how the polar graph is sketched out as the angle changes. This is especially helpful when fidning areas in polar coordinates, because it allows you to visually spot when a portion of a region is sketched out more than once. Here is an example of a frame from PolarMovie and a full Quicktime movie:

To see the movie, click here. (you may have to hit "reload" to see the movie)
FirstDerivativeTest is a program I wrote to apply the first derivative test for identifying local maxima and minima of functions. The critical points tested are where the first derivative is 0 (I couldn't figure out a way to find the places where the derivative does not exist), and the sign of the derivative is tested numerically at .000001 to either side of a critical point. A table of the results is printed along with a graph of the function. FirstDerivativeTest[ f,{x,a,b}] applies the test to a function f as x goes from a to b. Because solving the equation f'=0 may not be possible algebraically, the option Intervals->n will use Newton's method to identify the critical points, using n equally spaced seed values in the interval [a,b] (so setting Intervals->100 has an excellent chance of catching the critical points). Because if the numerical estimation involved FirstDerivativeTest may not always return all of the local maximum, but if the function is relatively well-behaved it tends to work fairly well. Here are to examples of FirstDerivativeTest at work:

NewtonsMethod is a variant on a short program I wrote for our computer lab to apply Newton's method for estimating a solution to the equation f(x)=0. This way the computer handles all of the calculations and allows the students to see how quickly Newton's method works and how it can fail. The program prints out the estimate and the function value at the estimate during each iteration, and the value returned at the end is the final estimate for the solution. To apply Newton's method to function=0 with initial value seed and n iterations, use NewtonsMethod[function, {x,seed},n]. You can increase the number of digits of accuracy used in the calculations to any number n with the option Digits->n (the default is 10 - digits may be lost in the calculations, though). An example of using this program to estimate the root of x2-2=0 with 20 digits of initial accuracy, 6 iterations, and seed value 2 is given below.

I wrote MeanValuePlot to give a graphical illustration of the Mean Value Theorem. MeanValuePlot[function,{x,a,b}] creates a combined plot of the graph of y=function, the secant line whose slope is the average rate of change of function from x=a to x=b, and any tangent lines whose slope is the same as the average rate of change. The function itself is colored black, the average rate of change line is colored red, and the tangent lines are colored blue. A little care has to be taken when choosing functions and intervals - to preserve slopes, the AspectRatio of the plot its set to Automatic, so if the function takes on large vlaues the graphs may be hard to read. Below is an example of the output for MeanValuePlot[x^3-3x,{x,-1,1}].

I wrote the command NewtonMovie to create animated movies which illustrate the idea behind Newton's method of approximating roots to equations of the form f(x)=0. For example, NewtonMovie[ 2Sin[x]-.3,1,5,{x,-Pi,Pi},{y,-3,2}] creates a series of plots which show 5 iterations of Newton's method for the equation 2 sin(x)-.3=0, with the x-values from -pi tp pi and y-values from -3 to 2 shown in each plot. Adding the option RootTable->True at the end of the command will add a table of root estimates and function values, but this may distort the plots a bit. NewtonMovie works really well with the "Convert to Quicktime" command - you can generate the graphics whenever you want and then convert them to black-and-white Quicktime files which are very small and can be played on virtually any computer.
To see the movie, click here. (you may have to hit "reload"
to see the movie)
I wrote the command DerivativeMovie to create animated movies of how the derivative and tangent line to a curve is the limit of secant lines. This program creates a movie with a fixed x-range and y-range which shows the tangent line and a secant line in each frame which is defined by an x-coordinate difference given in a list. For example, the command DerivativeMovie[ Sin[x],Pi/4,{x,0,2Pi},{y,-2,2},{.4,.3,.2,.1}] would create a sequence of plots which show the tangent line to y=sin(x) at Pi/4 and the secant lines to the graph using x=Pi/4 and x=Pi/4+.4, Pi/4+.3, Pi/4+.2, and Pi/4+.1 for the two points which determine the line. Using the options EstimateLabel and Points numerical estimates for the slopes can be placed in the plots and the sizes of the two plotted points can be changed. This works really well with the "Convert to Quicktime" command - you can generate the graphics whenever you want and then convert them to black-and-white Quicktime files which are very small and can be played on virtually any computer.
To see the movie, click here. (you may have to hit "reload" to see the movie)
I wrote the command SpringSystem for a course in differential equations I taught at Kenyon college. At the time we were studying the standard 1-dimensional mass-spring system (linear friction and arbitrary forcing function and intitial conditions). One of the problems was about 2 masses and 2 springs hooked up spring-mass-spring-mass. The behavior of these gets pretty complicated, so I wrote this program which creates a "movie" (basically a list of graphics which you can animate) of the behavior of the system. You can add a forcing function (to study resonance, for example), place tick marks for the rest positions of the masses, and place a "total mechanical energy" meter to the right of the graphics (so you can see energy leached away by friction). This works really well with the "Convert to Quicktime" command - you can generate the graphics whenever (and it does take some time, even on powerful machines), and then convert them to black-and-white Quicktime files which are very small and can be played on virtually any computer.
Here is an example of what one of the animation frames looks
like, showing the rest positions and an energy meter:
The programs TruthTable and LogicalTypeCheck were written to help me grade in my Foundations of Mathematics class in Fall 1997.
TruthTable[ expression-list,variablelist] creates a full truth table whose columns start with the variables from variable-list followed by the logical expressions from expression-list. For example, TruthTable[ {p&&q, p||q},{p,q}] would create a "standard" truth table whose last two columns correspond to "p and q" and "p or q".
LogicalTypeCheck[ logicalexpression, variable-list] returns
whether logicalexpression is a tautology, contradiction, or a contigency (based on
the variables in variable-list). LogicalTypeCheck[ {p&&q},{p,q}] would
tell you that p&&q is a contigency, and LogicalTypeCheck[ {p || (!p)},{p}]
would tell you p || (!p) is a tautology.
Here is an example of these programs:

A pair of weird 6-sided dice is a pair of six-sided dice
whose sides are labelled with positive integers with the following properties:
1) They are not labelled {1,2,3,4,5,6}.
2) When you roll them and add the numbers,
you have the same probability of getting sums (2-12) as with regular dice.
(see Contemporary Abstract Algebra by Joseph Gallian - a great text on abstract
algebra)
It's not clear that such a pair exists (actually, there
is just one). You can generalize this - you could talk about weird 20-sided
dice, for example. WeirdDice[n] finds all pairs of weird n-sided dice (using
the unique factorization trick from Gallian's book). WeirdDiceNumber[n]
finds the number of pairs of weird n-sided dice, which is useful for exploring the
distribution of how many there are (for example, for any prime p there are no weird
dice).
Here are all pairs of weird 8-sided dice:
WeirdDice[8]
{1, 3, 5, 5, 7, 7, 9, 11}
{1, 2, 2, 3, 3, 4, 4, 5}
{1, 3, 3, 5, 5, 7, 7, 9}
{1, 2, 2, 3, 5, 6, 6, 7}
{1, 2, 5, 5, 6, 6, 9, 10}
{1, 2, 3, 3, 4, 4, 5, 6}
RiemannPlot is a command to illustrate Riemann sums as an
approximation of area. RiemannPlot[f[x],{x,a,b},options] creates a plot of the graph
of y=f[x] on the interval [a,b] and displays rectangles which approximate the signed
area under the curve. The default settings generate 10 rectangles whose heights are
given by the curve at left-hand endpoints. The number of rectangles can be
changed by the option Intervals (Intervals->10 is default). The option HeightPoints
(with valid values LeftPoints, RightPoints, Midpoints) changes where the rectangles
get their height. The option Estimate->True returns a numerical estimate
of the area as well. The option PointPosition->a (a between 0 and 1) overrides
Heightpoints to use the points which are a-th of the way across each subinterval.
RiemannPlot also accepts all of the options for the Plot command, such as Ticks,
PlotRange, and PlotLabel.
For example, you could use RiemannPlot[x^2,{x,0,4},Intervals-> 10,HeightPoints->RightPoints,Estimate->True]
to get a visual display of the Riemann sum for x^2 on [0,4] using 10 equal subintervals,
the "selection" of right-hand endpoints, and get a numerical estimate of
the area as well.
Here is the graphical portion of the output for the Riemann
sum above:

This somewhat silly program tries to estimate pi by approximating
the probability that 2 randomly chosen integers are relatively prime (the ideal probability
is 6/p^2).
This is one of the worst ways I know to try to find pi. PiByRelativelyPrime[n,ran]
uses n pairs of integers chosen from -ran to ran (ran should be large, like 10^12).
With one run of PiByRelativelyPrime[10000,10^12], the output was:
Out of 10000 random pairs of integers, 6146 were relatively prime.
The percentage of relatively prime pairs is approximately 61.46000000000000
The approximation to Pi is 3.124491497840584552
ModularDisplay[formula,a,b,n] creates a color-coded table of the values of -formula- with respect to the variables a and b modulo n. (with legend). For example, to create a color-coded table of addition mod 5, use ModularDisplay[a+b,a,b,5]. To investigate the zero-divisors mod 12, use ModularDisplay[a*b,a,b,12]. Zero is always indicated by a black square. I wrote this (but did not have a chance to really use it) for the Foundations class I taught in Fall 1997. I hope to use it in the Number Theory course I'm teaching this summer.
Here is a picture using ModularDisplay[a^2+b^2,a,b,17]. Notice the zeroes in the picture, which tell you 17 can be written as the sum of 2 squares.

The Josephus problem (which I learned about from a talk
given by a visiting speaker at a Math Club meeting in Fall 1997) is the following:
a group of n people arrange themselves in a circle. Starting with person number
a in the circle, every m-th person commits suicide (a grim problem) until there are
less than m people left (they chicken out). Which positions in the original
circle are left? (in other words, where do you stand?). The answer is given
by Josephus[peoplelist,m,a]. For example, to find out where to stand ina 300
person circle where every 6th person commits suicide starting with person #27, use
Josephus[Range[300],6,27]. (this is a very grim problem, but apparently it's a historical
one based on a suicide pact of Jewish rebels fighting against the romans).
The places you'd like to stand in the 300-person example above are {68,124,176,227,269}.
InfinityPlot[ f,t,n] creates a strange sort of plot which you can use to detect limits of f as t goes to plus and minus infinity and vertical asymptotes. A bounding box is drawn around the plot, and the points on this boundary correspond to infinity. So if the graph "goes" to a value at the left or right edge, a limit as t goes to infinity exists there. If the graph touches the top or bottom (but not the corners), that represents a vertical asymptote. One warning - the actual values where the boundary is touched do NOT correspond to the correct values of the limits, so it just tells you limits exist, not what they are (or where they are for vertical asymptotes). This works by plotting arctan(f(tan(theta))) as theta goes from -Pi/2 to Pi/2.
Here is the "infinity plot" for x^2/(x^2-1):

I developed ConicInfo to handle the rotation and shifts of conic sections in the Analytic Geometry course (I didn't like slogging through the algebra any more than my students did). Given a conic and the underlying variables, it gives the angle of rotation for the conic, some appropriate information (foci, axes, the directrix of a parabola), detect for degeneracy (and give line pairs if they happen), and plot the conic. I wrote a usage statement for this one, so see it for the syntax. This one is a bit more complex than my other programs and I didn't have a lot of extra time when I wrote it, so you may want to consider it a "beta". It correctly processed every example from a Calculus and an Analytic Geometry I had, though.
To investigate the conic -70 + 9*x^2 + 8*x*y - 6*y^2 = 0,
I used the command
ConicInfo[ 9x^2+8x y-6y^2-70,{x,-4,4},y,AspectRatio->Automatic,PlotRange->{-10,10}]
and the result was:


Return to the SOSU School of Sciences
and Technology Page
Return to SOSU's homepage
NOTE: While every effort is made to ensure the accuracy of these pages, errors may occur on occasion. Please verify any information obtained on these pages with the relevant department before relying on the information for anything critical.