January 26, 1996 and February 2, 1996

DSP Design Group Meeting

- Mathematica
- algebraic expressions
In[1]:= x^2 + 2 x + K x 2 Out[1]= 2 x + K x + x

- represents expressions as trees, with nodes being functions
In[2]:= TreeForm[ x^2 + 2 x + K x ] Out[2]//TreeForm= Plus[| , | , | ] Times[2, x] Times[K, x] Power[x, 2]

- user sees a multitude of data types and functions, but one common
format for data and functions that follows a Lisp-style
representation (data is an undefined function):
*head*[*arg1*,*arg2*, ... ] - Lisp-style primitives and prefix notation:
In[3]:= Map[ Function[x, x^2], {1, 2, 3} ] Out[3]= {1, 4, 9} In[4]:= {1, 2, 3}^2 Out[4]= {1, 4, 9}

- Lisp-style programming paradigms: procedural, functional,
data-directed, tagged, pattern matching, and rule-based.
In[5]:= Log[2 x y] //. { Log[a_ b_] :> Log[a] + Log[b] } Out[5]= Log[2] + Log[x] + Log[y]

- scripting language
In[6]:= fstream = OpenWrite["x.dat"] Out[6]= OutputStream[x.dat, 3] In[7]:= Put[x, fstream] In[8]:= Close[fstream] Out[8]= x.dat In[9]:= !!x.dat x

- infix/postfix operators added, e.g., C/C++ syntactic sugar:
In[11]:= sum = 0; For [ i = 0, i < 100, i++, sum += i ]; sum Out[11]= 4950

- no pointers, no data structures, automatic memory allocation/deallocation
- single return values for the same function
- Mathematica load packages from its path.
The following example computes a Fourier series for a sawtooth signal
having period T:
In[15]:= Needs[ "Calculus`Master`" ] In[16]:= FourierTrigSeries[x, {x, 0, T}, 3] 2 Pi x 4 Pi x 6 Pi x T Sin[------] T Sin[------] T Sin[------] T T T T Out[16]= - - ------------- - ------------- - ------------- 2 Pi 2 Pi 3 Pi

The Needs command tells Mathematica what packages you might use. Then, we you use a command from one of the packages, Mathematica will automatically load in the package. Mathematica packages are the same as Lisp packages. They have their own contexts (name spaces) for variables.By loading in the Master file for a package, Mathematica gets a list of all of the new routines and what file they are in. To find the value of the path:

In[17]:= $Path Out[17]= {., ~, /usr/tools/tools2/mathematica/Install/Preload, > /usr/tools/tools2/mathematica/StartUp, > /usr/tools/tools2/mathematica/Packages, > /usr/tools/tools2/mathematica/Applications, > /usr/tools/lib/mathematica/Packages}

These > markers indicate the output takes multiple lines and appear at the beginning of each line. The > markers can be changed by setting a global variable. - For an introduction to Mathematica, type in Unix:
mathematica /usr/tools/lib/mathematica/Notebooks/StrumAndKirk/introduction.ma

which will run the X windows front end and open the "introduction.ma" notebook. Notebooks are explained next.

- algebraic expressions
- Notebooks
- a word processing interface for Mathematica
- formatted text, tables, graphics, plus Mathematica commands, sound, and animation
`math2html`

converts notebooks to "outline-form" Web documents

- Packages
- come with Mathematica: algebra, calculus, discrete math, graphics, number theory
- great third party support: third-party freely distributable packages are in one FTP site, which can be browsed and searched from the Web called MathSource

- Application Packs
**Electrical Engineering**design examples INSTALLED**Signals and Systems**1-D/m-D transforms, convolution, plotting INSTALLED**Optics****Controls Systems****Nodal**symbolic circuit analysis- Complete Listing

- Future
- Mathematica 3: live formatted equations
- Compiled packages for fast loading

- Courseware
- Calculus and Mathematica
- Notebooks to Accompany
*Contemporary Linear Systems Using MATLAB* - EECS 20 lectures given in the Hogan room

- MathLink
- Interface C/C++ programs with the Mathematica kernel
- Have Mathematica call external C programs
**InterCall**is a MathLink program giving access to NAG, IMSL, and other numerical libraries from within Mathematica- Ptolemy/Mathematica interface for parameter calculation

- Some Local Research Uses
- Code generation / program synthesis
- Algorithm Derivation
- Algebraic analysis
- Factoring resampling matrices
- Simplifying and rewriting subsystems

- Local Installation Information

Last modified 04/10/97.