[an error occurred while processing this directive]

# Notes on Mathematica from Seminar on 11/11/97

## Starting up.

To open mathematica, type "mathematica" at a login prompt
(i.e. Bragg:> mathematica [return])

Use the Menu bar to save, open, print, ... files, format cells, etc.

For help, your best two places are:
1) Open the Function Browser from help menu
2) Look at the book Mathematica by Stephen Wolfram, it is on reserve
in the physics library.

## A sample problem - The Pendulum

Mathematica can quickly do algebra and calculus problems

Mathematica can do both partial and full derivatives. Dt is a total derivative, and D is a partial derivative.

Simplify is a command that combines terms algebraically.

Sometimes Mathematica gives more than is needed. Here we take out the term we know doesn't need to be there by hand.

The term {t, 2} in the above output means to take the second total derivative with respect to the variable t. The symbol "%" means to use the last output given. So below, "%" refers to Out[12]

NDSolve is a function which takes a differential equation and some initial conditions, and numerically solves the equation. The output is an InterpolatingFunction. An InterpolatingFunction represents an approximate function whose values are found by interpolation. We can Evaluate the function at some time t to find &thgr;[t].
The symbol "/." reads "ReplaceAll with". So Evaluate[&thgr;[t] /. diff] would give us &thgr; at time t using the function diff.

We can also write the differential equation in the more familiar form using primes.

We can use the solutions to plot the position, velocity, and acceleration vs. time. Plot is a function which plots the given equation over a specified range.

Mathematica can assign complicated functions to one variable to simplify what one needs to write.

We can use Mathematica to quickly create lists of numbers, and to plot them. Table evaluates a function at given intervals, and stores the numbers in a list. Sometimes Mathematica's output contains extra parentheses. Flatten will remove them. We can take individual elements of a list or matrix by using List[[element]]. ListPlot is a function which takes a list of numbers and plots a point for each one.

We can go back and let our differential equation be a function of several variables, length l, and starting angle &agr;. The symbol ":=" means define this function as follows. Note the "_" following all independent variables.

We can find the period by looking at the 1st two minimums of the above plot. FindMinimum finds the minimum of a function around a given point.

We can write a short program to find the period for varying length l. The output of Table will be a list of values of the periods. The Plot term will also give a group of figures. We can collapse the cells into one cell, and Mathematica can animate then sequentially.

We can do the same for fixed l, but vary the starting angle &agr;.

## Other Examples

Often in quantum mechanics, we work with complicated special functions. Mathematica can easily work with these. For example, one can plot a Bessel function where the independent variable is the order of the function.

Mathematica can quickly work with matrices, combining, inverting, etc. both symbolically and numerically. Below, M is a matrix one obtains when trying to find the conductance of a ring shaped conductor. Without going through this in detail, you can see how Mathematica inverts it, adds and subtract elements, and can pull out elements to plot.

Mathematica can also give series expansions for complicated functions.

[an error occurred while processing this directive]