Mathematica 7.0.1 The original Mathematica was a computer...

85
Mathematica 7.0.1 Overview: I The original Mathematica was a computer algebra system (CAS) released by Stephen Wolfram in 1988. I Modern releases have augmented the CAS with powerful numerical and graphical capabilities. I Emphasis is placed on allowing math to be incorporated into neat ‘final products’ - through fancy formatting, interactivity etc. I Mathematica is renowned as the world’s ultimate application for computations. But it’s much more - it’s the only development platform fully integrating computation into complete workflows, moving you seamlessly from initial ideas all the way to deployed individual or enterprise solutions.”

Transcript of Mathematica 7.0.1 The original Mathematica was a computer...

Page 1: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1

Overview:

I The original Mathematica was a computer algebra system (CAS)released by Stephen Wolfram in 1988.

I Modern releases have augmented the CAS with powerfulnumerical and graphical capabilities.

I Emphasis is placed on allowing math to be incorporated into neat‘final products’ - through fancy formatting, interactivity etc.

I “Mathematica is renowned as the world’s ultimate application forcomputations. But it’s much more - it’s the only developmentplatform fully integrating computation into complete workflows,moving you seamlessly from initial ideas all the way to deployedindividual or enterprise solutions.”

Page 2: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1

It’s clear who Wolfram is ultimately trying to entice:

“100% of the Fortune 50 companies rely on Mathematica to maintaintheir competitive edge in innovation.”

I mainly use the basic CAS only, for:

I simplification

I differentiation

I integration

I (quick) visualization

This talk focuses on the background needed to execute these tasksefficiently.

Page 3: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1

It’s clear who Wolfram is ultimately trying to entice:

“100% of the Fortune 50 companies rely on Mathematica to maintaintheir competitive edge in innovation.”

I mainly use the basic CAS only, for:

I simplification

I differentiation

I integration

I (quick) visualization

This talk focuses on the background needed to execute these tasksefficiently.

Page 4: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1

GUI:

I Mathematica (.nb) files are called notebooks.

I A notebook consists of input and output cells.

I Each input cell contains at least one command.

I Evaluating an input cell (Shift-Enter) produces an output cellimmediately below it.

Matlab analogy:

I Notebooks mix elements from m-files (saving/loading of multiplecommands) and the interactive command window (evaluationcell-by-cell).

Page 5: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1

GUI:

I Mathematica (.nb) files are called notebooks.

I A notebook consists of input and output cells.

I Each input cell contains at least one command.

I Evaluating an input cell (Shift-Enter) produces an output cellimmediately below it.

Matlab analogy:

I Notebooks mix elements from m-files (saving/loading of multiplecommands) and the interactive command window (evaluationcell-by-cell).

Page 6: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1

GUI:

I Mathematica (.nb) files are called notebooks.

I A notebook consists of input and output cells.

I Each input cell contains at least one command.

I Evaluating an input cell (Shift-Enter) produces an output cellimmediately below it.

Matlab analogy:

I Notebooks mix elements from m-files (saving/loading of multiplecommands) and the interactive command window (evaluationcell-by-cell).

Page 7: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Basics

Basic mathematical operations:

In[1]:= 2+3

2-3

2/3

2*3

2^3

Evaluate whole cell by pressing Shift-Enter

Page 8: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Basics

Basic mathematical operations:

In[1]:= 2+3

2-3

2/3

2*3

2^3 Evaluate whole cell by pressing Shift-Enter

Page 9: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Basics

Basic mathematical operations:

In[1]:= 2+3

2-3

2/3

2*3

2^3

Out[1]= 5

Out[2]= -1

Out[3]= 2/3

Out[4]= 6

Out[5]= 8

Page 10: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Basics

Basic mathematical operations:

In[1]:= 2+3

2-3

2/3

2*3

2^3

Out[1]= 5

Out[2]= -1

Out[3]= 2/3

Out[4]= 6

Out[5]= 8

We can modify our input to return a decimal using the N[...]

function.

Page 11: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Basics

Basic mathematical operations:

In[1]:= 2+3

2-3

N[2/3] Alter this line only...

2*3

2^3

Out[1]= 5

Out[2]= -1

Out[3]= 2/3

Out[4]= 6

Out[5]= 8

Page 12: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Basics

Basic mathematical operations:

In[1]:= 2+3

2-3

N[2/3]

2*3

2^3 ...then re-evaluate this whole cell with Shift-Enter

Out[1]= 5

Out[2]= -1

Out[3]= 2/3

Out[4]= 6

Out[5]= 8

Page 13: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Basics

Basic mathematical operations:

In[6]:= 2+3

2-3

N[2/3]

2*3

2^3

Out[6]= 5

Out[7]= -1

Out[8]= 0.666667

Out[9]= 6

Out[10]= 8

The new input and output cells visually replace the old ones.

Page 14: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Basics

Storing/accessing output:

I Variable assignments are straightforward:

In[1]:= a=3

a+4

Out[1]= 3

Out[2]= 7

I The most recent output value is stored in % (like Matlab’s ans):

In[3]:= %+5

Out[3]= 12

I Earlier output values are accessed using Out[...]:

In[4]:= %+Out[1]

Out[4]= 15

Page 15: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Basics

Storing/accessing output:

I Variable assignments are straightforward:

In[1]:= a=3

a+4

Out[1]= 3

Out[2]= 7

I The most recent output value is stored in % (like Matlab’s ans):

In[3]:= %+5

Out[3]= 12

I Earlier output values are accessed using Out[...]:

In[4]:= %+Out[1]

Out[4]= 15

Page 16: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Basics

Storing/accessing output:

I Variable assignments are straightforward:

In[1]:= a=3

a+4

Out[1]= 3

Out[2]= 7

I The most recent output value is stored in % (like Matlab’s ans):

In[3]:= %+5

Out[3]= 12

I Earlier output values are accessed using Out[...]:

In[4]:= %+Out[1]

Out[4]= 15

Page 17: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Basics

General syntax rules:

I Constants and built-in functions are always capitalized.Multi-word functions use multiple capital letters.

I Function arguments go inside brackets.

I Functions can be nested.

Examples:

I Constants: E, I, Pi, Infinity.

I Basic math functions: N[...], Exp[...], Log[...], Sin[...],Cos[...], Tan[...], Abs[...], etc.

I Manipulation functions: Factor[...], Expand[...],FullSimplify[...], TeXForm[...].

Page 18: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Basics

General syntax rules:

I Constants and built-in functions are always capitalized.Multi-word functions use multiple capital letters.

I Function arguments go inside brackets.

I Functions can be nested.

Examples:

I Constants: E, I, Pi, Infinity.

I Basic math functions: N[...], Exp[...], Log[...], Sin[...],Cos[...], Tan[...], Abs[...], etc.

I Manipulation functions: Factor[...], Expand[...],FullSimplify[...], TeXForm[...].

Page 19: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Functions

Built-in function use:

In[1]:= N[Cos[2]]

Out[1]= -0.416147

In[2]:= Expand[(-10 + x)(7 + x)]

Out[2]= -70 - 3x + x^2

Note: * operator only needed to avoid ambiguity!

In[3]:= TeXForm[x/(x+1)]

Out[3]= \frac{x}{x+1}

Page 20: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Functions

Built-in function use:

In[1]:= N[Cos[2]]

Out[1]= -0.416147

In[2]:= Expand[(-10 + x)(7 + x)]

Out[2]= -70 - 3x + x^2

Note: * operator only needed to avoid ambiguity!

In[3]:= TeXForm[x/(x+1)]

Out[3]= \frac{x}{x+1}

Page 21: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Functions

Built-in function use:

In[1]:= N[Cos[2]]

Out[1]= -0.416147

In[2]:= Expand[(-10 + x)(7 + x)]

Out[2]= -70 - 3x + x^2

Note: * operator only needed to avoid ambiguity!

In[3]:= TeXForm[x/(x+1)]

Out[3]= \frac{x}{x+1}

Page 22: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Functions

Misc. syntax tips:

I To get help on a function use ?FunctionName or??FunctionName:

In[1]:= ?Cos

Out[1]= Cos[z] gives the cosine of z.

I Incorrectly-typed function names appear blue:

In[2]:= texform[x/(x+1)]

TeXForm[x/(x+1)]

Out[2]= texform[x/(x+1)]

Out[3]= \frac{x}{x+1}

I As in Matlab, output is suppressed by a semi-colon:

In[4]:= 2+3; Out[4] is defined, just hidden.

Page 23: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Functions

Misc. syntax tips:

I To get help on a function use ?FunctionName or??FunctionName:

In[1]:= ?Cos

Out[1]= Cos[z] gives the cosine of z.

I Incorrectly-typed function names appear blue:

In[2]:= texform[x/(x+1)]

TeXForm[x/(x+1)]

Out[2]= texform[x/(x+1)]

Out[3]= \frac{x}{x+1}

I As in Matlab, output is suppressed by a semi-colon:

In[4]:= 2+3; Out[4] is defined, just hidden.

Page 24: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Functions

Misc. syntax tips:

I To get help on a function use ?FunctionName or??FunctionName:

In[1]:= ?Cos

Out[1]= Cos[z] gives the cosine of z.

I Incorrectly-typed function names appear blue:

In[2]:= texform[x/(x+1)]

TeXForm[x/(x+1)]

Out[2]= texform[x/(x+1)]

Out[3]= \frac{x}{x+1}

I As in Matlab, output is suppressed by a semi-colon:

In[4]:= 2+3; Out[4] is defined, just hidden.

Page 25: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Functions

User-defined functions:

In[1]:= f[x_]:=x^2 Delayed assignment - no output.

In[2]:= f[3]

f[t]

Out[2]= 9

Out[3]= t^2

In[4]:= g[x_,y_]:=Abs[x-y]

g[-3,3]

g[s+h,s-h]

Out[5]= 6

Out[6]= 2 Abs[h]

Page 26: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Functions

User-defined functions:

In[1]:= f[x_]:=x^2 Delayed assignment - no output.

In[2]:= f[3]

f[t]

Out[2]= 9

Out[3]= t^2

In[4]:= g[x_,y_]:=Abs[x-y]

g[-3,3]

g[s+h,s-h]

Out[5]= 6

Out[6]= 2 Abs[h]

Page 27: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Functions

User-defined functions:

In[1]:= f[x_]:=x^2 Delayed assignment - no output.

In[2]:= f[3]

f[t]

Out[2]= 9

Out[3]= t^2

In[4]:= g[x_,y_]:=Abs[x-y]

g[-3,3]

g[s+h,s-h]

Out[5]= 6

Out[6]= 2 Abs[h]

Page 28: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Functions

(Advanced) ‘Patterns’ are used to restrict domains:

In[1]:= g[x_?IntegerQ]:=x^2

g[2]

g[2.5]

Out[2]= 4

Out[3]= g[2.5]

In[4]:= h[x_?NumericQ]:=x^3 Sometimes needed for plotting.

h[2]

h[2.5]

h[t]

Out[5]= 8

Out[6]= 15.625

Out[7]= h[t]

Patterns will only redefine a function on the restricted domain.

Page 29: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Functions

(Advanced) ‘Patterns’ are used to restrict domains:

In[1]:= g[x_?IntegerQ]:=x^2

g[2]

g[2.5]

Out[2]= 4

Out[3]= g[2.5]

In[4]:= h[x_?NumericQ]:=x^3 Sometimes needed for plotting.

h[2]

h[2.5]

h[t]

Out[5]= 8

Out[6]= 15.625

Out[7]= h[t]

Patterns will only redefine a function on the restricted domain.

Page 30: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Lists

Lists:

I Syntax: {1,3,9,27}

I Elements are extracted using double brackets:

In[1]:= {1,3,9,27}[[2]]

Out[1]= 3

I Nesting forms arrays:

In[2]:= {{1,3},{9,27}}[[2,1]]

Out[2]= 9

I The Range[...] function can be used to generate lists:

In[3]:= Range[1,9,2]

Out[3]= {1,3,5,7,9}

Page 31: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Lists

Lists:

I Syntax: {1,3,9,27}

I Elements are extracted using double brackets:

In[1]:= {1,3,9,27}[[2]]

Out[1]= 3

I Nesting forms arrays:

In[2]:= {{1,3},{9,27}}[[2,1]]

Out[2]= 9

I The Range[...] function can be used to generate lists:

In[3]:= Range[1,9,2]

Out[3]= {1,3,5,7,9}

Page 32: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Lists

Lists:

I Syntax: {1,3,9,27}

I Elements are extracted using double brackets:

In[1]:= {1,3,9,27}[[2]]

Out[1]= 3

I Nesting forms arrays:

In[2]:= {{1,3},{9,27}}[[2,1]]

Out[2]= 9

I The Range[...] function can be used to generate lists:

In[3]:= Range[1,9,2]

Out[3]= {1,3,5,7,9}

Page 33: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Lists

Lists:

I Syntax: {1,3,9,27}

I Elements are extracted using double brackets:

In[1]:= {1,3,9,27}[[2]]

Out[1]= 3

I Nesting forms arrays:

In[2]:= {{1,3},{9,27}}[[2,1]]

Out[2]= 9

I The Range[...] function can be used to generate lists:

In[3]:= Range[1,9,2]

Out[3]= {1,3,5,7,9}

Page 34: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Lists

Lists as inputs:

In[1]:= Sin[{0,Pi/2}]

Out[1]= {0,1}

In[2]:= N[Cos[Range[1,3]]]

Out[2]= {0.540302,-0.416147,-0.989992}

Lists as options:

In[3]:= Sum[n,{n,1,9,2}] Sum of odd #s between 1 and 9.

Out[3]= 25

In[4]:= Series[Exp[w],{w,0,2}] Taylor series of Exp[w] about

Out[4]= 1 + w + w^2/2 + O[w^3] w = 0, up to order 2.

Page 35: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Lists

Lists as inputs:

In[1]:= Sin[{0,Pi/2}]

Out[1]= {0,1}

In[2]:= N[Cos[Range[1,3]]]

Out[2]= {0.540302,-0.416147,-0.989992}

Lists as options:

In[3]:= Sum[n,{n,1,9,2}] Sum of odd #s between 1 and 9.

Out[3]= 25

In[4]:= Series[Exp[w],{w,0,2}] Taylor series of Exp[w] about

Out[4]= 1 + w + w^2/2 + O[w^3] w = 0, up to order 2.

Page 36: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Lists

Lists as inputs:

In[1]:= Sin[{0,Pi/2}]

Out[1]= {0,1}

In[2]:= N[Cos[Range[1,3]]]

Out[2]= {0.540302,-0.416147,-0.989992}

Lists as options:

In[3]:= Sum[n,{n,1,9,2}] Sum of odd #s between 1 and 9.

Out[3]= 25

In[4]:= Series[Exp[w],{w,0,2}] Taylor series of Exp[w] about

Out[4]= 1 + w + w^2/2 + O[w^3] w = 0, up to order 2.

Page 37: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Lists

Lists as inputs:

In[1]:= Sin[{0,Pi/2}]

Out[1]= {0,1}

In[2]:= N[Cos[Range[1,3]]]

Out[2]= {0.540302,-0.416147,-0.989992}

Lists as options:

In[3]:= Sum[n,{n,1,9,2}] Sum of odd #s between 1 and 9.

Out[3]= 25

In[4]:= Series[Exp[w],{w,0,2}] Taylor series of Exp[w] about

Out[4]= 1 + w + w^2/2 + O[w^3] w = 0, up to order 2.

Page 38: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Differentiation

Differentiation:

Of undefined functions:

In[1]:= D[f[x],x]

D[f[x],{x,2}]

Out[1]= f’[x]

Out[2]= f’’[x]

Of given functions:

In[3]:= g[x_]:=Exp[-x^2]

D[g[t],t]

D[g[t],{t,2}]

Out[4]= -2 t Exp[-t^2]

Out[5]= -2 Exp[-t^2] + 4 t^2 Exp[-t^2]

Page 39: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Differentiation

Differentiation:

Of undefined functions:

In[1]:= D[f[x],x]

D[f[x],{x,2}]

Out[1]= f’[x]

Out[2]= f’’[x]

Of given functions:

In[3]:= g[x_]:=Exp[-x^2]

D[g[t],t]

D[g[t],{t,2}]

Out[4]= -2 t Exp[-t^2]

Out[5]= -2 Exp[-t^2] + 4 t^2 Exp[-t^2]

Page 40: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Differentiation

To define the resulting expression as a new function, use immediateassignment:

In[1]:= h[t_]=D[Exp[-t^2],{t,2}]

h[0]

Out[1]= -2 Exp[t^2] + 4 t Exp[t^2]

Out[2]= -2

Delayed assignment will not work here!

In[3]:= k[t_]:=D[Exp[-t^2],{t,2}]

k[0]

General::ivar: 0 is not a valid variable.

Out[4]= D[1,{0,2}]

Page 41: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Differentiation

To define the resulting expression as a new function, use immediateassignment:

In[1]:= h[t_]=D[Exp[-t^2],{t,2}]

h[0]

Out[1]= -2 Exp[t^2] + 4 t Exp[t^2]

Out[2]= -2

Delayed assignment will not work here!

In[3]:= k[t_]:=D[Exp[-t^2],{t,2}]

k[0]

General::ivar: 0 is not a valid variable.

Out[4]= D[1,{0,2}]

Page 42: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Immediate/Delayed Assignment

Short version:

I Use := to define functions with known expressions.

I Use = to define functions resulting from other manipulations, andall constants.

(Advanced) Longer version:

I Immediate assignment (f[x_]=...) evaluates the RHS expressiononce (when first called) and assigns the result to f[x] forever.

I Delayed assignment (f[x_]:=...) evaluates the RHS expressioneach time f is called. The value of x is substituted into the RHSexpression before all algebraic and numerical manipulations areevaluated.

Page 43: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Immediate/Delayed Assignment

Short version:

I Use := to define functions with known expressions.

I Use = to define functions resulting from other manipulations, andall constants.

(Advanced) Longer version:

I Immediate assignment (f[x_]=...) evaluates the RHS expressiononce (when first called) and assigns the result to f[x] forever.

I Delayed assignment (f[x_]:=...) evaluates the RHS expressioneach time f is called. The value of x is substituted into the RHSexpression before all algebraic and numerical manipulations areevaluated.

Page 44: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Integration

Integration:

In[1]:= Integrate[t^2,{t,1,2}]

Integrate[Cos[t],{t,0,x}]

Integrate[Exp[-t^2],{t,0,Infinity}]

Integrate[Exp[-t^2],{t,0,1}]

Out[1]= 7/3

Out[2]= Sin[x]

Out[3]= Sqrt[Pi]/2

Out[4]= (Sqrt[Pi] Erf[1])/2

For integrals with no closed-form result, use NIntegrate:

In[5]:= NIntegrate[Exp[-t^2],{t,0,1}]

Out[5]= 0.746824

Quite a few functions have a numerical equivalent with similar syntax.

Page 45: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Integration

Integration:

In[1]:= Integrate[t^2,{t,1,2}]

Integrate[Cos[t],{t,0,x}]

Integrate[Exp[-t^2],{t,0,Infinity}]

Integrate[Exp[-t^2],{t,0,1}]

Out[1]= 7/3

Out[2]= Sin[x]

Out[3]= Sqrt[Pi]/2

Out[4]= (Sqrt[Pi] Erf[1])/2

For integrals with no closed-form result, use NIntegrate:

In[5]:= NIntegrate[Exp[-t^2],{t,0,1}]

Out[5]= 0.746824

Quite a few functions have a numerical equivalent with similar syntax.

Page 46: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Integration

Mathematica can (usually) handle ambiguous cases:

In[1]:= Integrate[t^n,{t,1,Infinity}]

Out[1]= ConditionalExpression[-1/(1+n), Re[n] < -1]

It is also possible to build assumptions in:

In[2]:= Integrate[t^n,{t,0,1},Assumptions->{Re[n] > -1}]

Out[2]= 1/(1+n)

Iterated integrals are performed from right to left:

In[3]:= Integrate[1,{x,0,1},{y,0,x}]

Out[3]= 1/2

Page 47: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Integration

Mathematica can (usually) handle ambiguous cases:

In[1]:= Integrate[t^n,{t,1,Infinity}]

Out[1]= ConditionalExpression[-1/(1+n), Re[n] < -1]

It is also possible to build assumptions in:

In[2]:= Integrate[t^n,{t,0,1},Assumptions->{Re[n] > -1}]

Out[2]= 1/(1+n)

Iterated integrals are performed from right to left:

In[3]:= Integrate[1,{x,0,1},{y,0,x}]

Out[3]= 1/2

Page 48: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Integration

Mathematica can (usually) handle ambiguous cases:

In[1]:= Integrate[t^n,{t,1,Infinity}]

Out[1]= ConditionalExpression[-1/(1+n), Re[n] < -1]

It is also possible to build assumptions in:

In[2]:= Integrate[t^n,{t,0,1},Assumptions->{Re[n] > -1}]

Out[2]= 1/(1+n)

Iterated integrals are performed from right to left:

In[3]:= Integrate[1,{x,0,1},{y,0,x}]

Out[3]= 1/2

Page 49: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Transformation Rules

Transformation Rules:

I Assumptions->{Re[n] > -1} is called a transformation rule.

I These are frequently found in function options or as output fromequation-solving functions.

I Transformation rules always have the form Variable->Value,e.g. x->2.

I Rules are applied to expressions using the /. operator:

In[1]:= 3^x/.x->2

Out[1]= 9

Page 50: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Transformation Rules

Transformation Rules:

I Assumptions->{Re[n] > -1} is called a transformation rule.

I These are frequently found in function options or as output fromequation-solving functions.

I Transformation rules always have the form Variable->Value,e.g. x->2.

I Rules are applied to expressions using the /. operator:

In[1]:= 3^x/.x->2

Out[1]= 9

Page 51: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Transformation Rules

Transformation Rules:

I Assumptions->{Re[n] > -1} is called a transformation rule.

I These are frequently found in function options or as output fromequation-solving functions.

I Transformation rules always have the form Variable->Value,e.g. x->2.

I Rules are applied to expressions using the /. operator:

In[1]:= 3^x/.x->2

Out[1]= 9

Page 52: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Transformation Rules

Transformation Rules:

I Assumptions->{Re[n] > -1} is called a transformation rule.

I These are frequently found in function options or as output fromequation-solving functions.

I Transformation rules always have the form Variable->Value,e.g. x->2.

I Rules are applied to expressions using the /. operator:

In[1]:= 3^x/.x->2

Out[1]= 9

Page 53: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Solving Equations

Solving algebraic equations:

I Solve[eqns,vars] solves the list of polynomialequations/inequalities eqns for the list of variables vars:

In[1]:= Solve[x^2+1 == 0,x]

Out[1]= {{x -> -I}, {x -> I}}

I All input equalities are written using ==.

I Solutions are returned as transformation rules:

In[2]:= x/.Out[1]

Out[2]= {-I,I}

Page 54: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Solving Equations

Solving algebraic equations:

I Solve[eqns,vars] solves the list of polynomialequations/inequalities eqns for the list of variables vars:

In[1]:= Solve[x^2+1 == 0,x]

Out[1]= {{x -> -I}, {x -> I}}

I All input equalities are written using ==.

I Solutions are returned as transformation rules:

In[2]:= x/.Out[1]

Out[2]= {-I,I}

Page 55: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Solving Equations

Solving algebraic equations:

I Solve[eqns,vars] solves the list of polynomialequations/inequalities eqns for the list of variables vars:

In[1]:= Solve[x^2+1 == 0,x]

Out[1]= {{x -> -I}, {x -> I}}

I All input equalities are written using ==.

I Solutions are returned as transformation rules:

In[2]:= x/.Out[1]

Out[2]= {-I,I}

Page 56: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Solving Equations

Solving algebraic equations:

I Solve[eqns,vars,dom] allows solution over restricted domains:

In[1]:= Solve[x^2+1 == 0,x,Reals] (or Integers.)

Out[1]= {}

I More generally, FindRoot[eqns,{{x,x0},{y,y0},...}]numerically solves the list of equations/inequalities eqns for thelist of variables {x,y,...} starting from {x0,y0,...}:

In[2]:= FindRoot[Cos[x] == x,{x,0}]

Out[2]= {x -> 0.739085}

Page 57: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Solving Equations

Solving algebraic equations:

I Solve[eqns,vars,dom] allows solution over restricted domains:

In[1]:= Solve[x^2+1 == 0,x,Reals] (or Integers.)

Out[1]= {}

I More generally, FindRoot[eqns,{{x,x0},{y,y0},...}]numerically solves the list of equations/inequalities eqns for thelist of variables {x,y,...} starting from {x0,y0,...}:

In[2]:= FindRoot[Cos[x] == x,{x,0}]

Out[2]= {x -> 0.739085}

Page 58: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Solving Equations

Solving differential equations:

I DSolve[eqns,{y1[x],y2[x],...},x] solves the list ofdifferential equations/inequalities eqns for the list of functions{y1[x],y2[x],...}:

In[1]:= DSolve[y’[x] == 1,y[x],x]

Out[1]= {{y[x] -> x+C[1]}}

I Including boundary conditions:

In[2]:= y[x]/.DSolve[{y’[x] == 1,y[1]==3},y[x],x][[1]]

Out[2]= 2+x

Page 59: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Solving Equations

Solving differential equations:

I DSolve[eqns,{y1[x],y2[x],...},x] solves the list ofdifferential equations/inequalities eqns for the list of functions{y1[x],y2[x],...}:

In[1]:= DSolve[y’[x] == 1,y[x],x]

Out[1]= {{y[x] -> x+C[1]}}

I Including boundary conditions:

In[2]:= y[x]/.DSolve[{y’[x] == 1,y[1]==3},y[x],x][[1]]

Out[2]= 2+x

Page 60: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Solving Equations

Solving differential equations:

I NDSolve[eqns,{y1[x],y2[x],...},{x,xmin,xmax}]

numerically solves the same system between xmin and xmax:

In[3]:= NDSolve[{y’[x]==Sin[x],y[0]==1},y[x],{x,0,10}]

Out[3]= {{y[x]->InterpolatingFunction[{{0.,10.}},<>][x]}}

I Boundary/initial conditions must be provided in this case.

Page 61: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Plotting

Basic plot:

Plot[Exp[-x],{x,0,5}]

1 2 3 4 5

0.2

0.4

0.6

0.8

1.0

Page 62: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Plotting

Parametric plot:

ParametricPlot[{2 Cos[t],Sin[t]},{t,0,2Pi}]

-2 -1 1 2

-1.0

-0.5

0.5

1.0

Page 63: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Plotting

Contour plot:

ContourPlot[Sin[x y],{x,-Pi,Pi},{y,-Pi,Pi}]

-3 -2 -1 0 1 2 3

-3

-2

-1

0

1

2

3

Page 64: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Plotting

Contour plot with specific curves:

ContourPlot[Sin[x y] == Range[0,1,0.1],{x,-Pi,Pi},{y,-Pi,Pi}]

-3 -2 -1 0 1 2 3

-3

-2

-1

0

1

2

3

Page 65: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Plotting

3D plot:

Plot3D[Sin[x y],{x,-Pi,Pi},{y,-Pi,Pi}]

Warning: high quality!

Page 66: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Plotting

(Advanced) List plot: (syntax is slightly more complex)

I ListPlot[{{x1,y1},{x2,y2},...}] plots the points (x1,y1),(x2,y2) etc.

I Suitable lists are usually either:

1. Generated using Table[...]

2. Constructed from separate lists {x1,x2,...} and {y1,y2,...}.

Table[...] is an extension of Range[...]:

In[1]:= Table[x^2,{x,1,9,2}]

Out[1]= {1,9,25,49,81}

Commands like Table[{f[x],g[x]},{x,0,2 Pi,0.1}] create lists ofpoints suitable for ListPlot[...].

Page 67: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Plotting

(Advanced) List plot: (syntax is slightly more complex)

I ListPlot[{{x1,y1},{x2,y2},...}] plots the points (x1,y1),(x2,y2) etc.

I Suitable lists are usually either:

1. Generated using Table[...]

2. Constructed from separate lists {x1,x2,...} and {y1,y2,...}.

Table[...] is an extension of Range[...]:

In[1]:= Table[x^2,{x,1,9,2}]

Out[1]= {1,9,25,49,81}

Commands like Table[{f[x],g[x]},{x,0,2 Pi,0.1}] create lists ofpoints suitable for ListPlot[...].

Page 68: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Plotting

(Advanced) List plot: (syntax is slightly more complex)

I ListPlot[{{x1,y1},{x2,y2},...}] plots the points (x1,y1),(x2,y2) etc.

I Suitable lists are usually either:

1. Generated using Table[...]

2. Constructed from separate lists {x1,x2,...} and {y1,y2,...}.

Table[...] is an extension of Range[...]:

In[1]:= Table[x^2,{x,1,9,2}]

Out[1]= {1,9,25,49,81}

Commands like Table[{f[x],g[x]},{x,0,2 Pi,0.1}] create lists ofpoints suitable for ListPlot[...].

Page 69: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Plotting

(Advanced) List plot (with Table):

ListPlot[Table[{2 Cos[t],Sin[t]},{t,0,2 Pi,0.1}]]

-2 -1 1 2

-1.0

-0.5

0.5

1.0

Page 70: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Plotting

(Advanced) List plot (with Transpose):

Suppose instead we wish to plot ydata={y1,y2,...} againstxdata={x1,x2,...} for given lists. We can mesh these separate liststogether correctly using Transpose[...]:

ListPlot[Transpose[{xdata,ydata}]]

will produce the desired result.

From the ‘2d Graphics Tips and Tricks’ sheet athttp://www.nhn.ou.edu/~morrison/Mathematica/index.shtml

Page 71: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Plotting

Plotting options:

I PlotRange->{{xmin,xmax},{ymin,ymax},{zmin,zmax}}

I AxesLabel->{"x-axis label","y-axis label"}

I PlotLabel->"plot label"

I PlotStyle->{Color,Linestyle,Linewidth}

I Axes->True/False

I Frame->True/False

I Joined->True (for ListPlot)

Page 72: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Plotting

Overlaid plots (using lists):

Plot[{Sin[x],Cos[x]},{x,0,2Pi},

PlotStyle->{{Red,Dashed},{Blue,Dotted}}]

1 2 3 4 5 6

-1.0

-0.5

0.5

1.0

Page 73: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Plotting

Overlaid plots (using Show[...]):

plot1 = ParametricPlot[{Cos[t]+0.1Cos[20t],Sin[t]+

0.1Sin[20t]},{t,0,2Pi}];

plot2 = ListPlot[Table[{Cos[t],Sin[t]},

{t,0,2Pi,Pi/4}],PlotStyle->{Red},

Joined->{True}];

Show[plot1,plot2]

-1.0 -0.5 0.5 1.0

-1.0

-0.5

0.5

1.0

Page 74: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Remote Access

Remote access:

I Command line: connect using

ssh -p 31415 [email protected]

then type math to run Mathematica. This mode is interactiveonly (no notebook-style formatting).

I Windowed (slow): connect using

ssh -p 31415 -Y [email protected]

then type Mathematica. The full Mathematica GUI is displayedin this mode.

Page 75: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Other Tricks

I To clear a definition, use Clear[...]

I To clear all definitions, use ClearAll["Global‘*"].(It is useful to place this line in the first input cell of every notebook.)

I To flatten nested lists, use Flatten[...]

I It is possible to combine some commands using a piping (akapostfix) structure. Commands are stacked using the // operator:

In[1]:= Pi/2 // N

1/Sqrt[2] // ArcSin // N

Out[1]= 1.5708

Out[2]= 0.785398

This works for most single-argument functions (FullSimplify,TeXForm etc.)

Page 76: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Other Tricks

I To clear a definition, use Clear[...]

I To clear all definitions, use ClearAll["Global‘*"].(It is useful to place this line in the first input cell of every notebook.)

I To flatten nested lists, use Flatten[...]

I It is possible to combine some commands using a piping (akapostfix) structure. Commands are stacked using the // operator:

In[1]:= Pi/2 // N

1/Sqrt[2] // ArcSin // N

Out[1]= 1.5708

Out[2]= 0.785398

This works for most single-argument functions (FullSimplify,TeXForm etc.)

Page 77: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Other Tricks

I To clear a definition, use Clear[...]

I To clear all definitions, use ClearAll["Global‘*"].(It is useful to place this line in the first input cell of every notebook.)

I To flatten nested lists, use Flatten[...]

I It is possible to combine some commands using a piping (akapostfix) structure. Commands are stacked using the // operator:

In[1]:= Pi/2 // N

1/Sqrt[2] // ArcSin // N

Out[1]= 1.5708

Out[2]= 0.785398

This works for most single-argument functions (FullSimplify,TeXForm etc.)

Page 78: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Other Neat Features

I Scientific data sets for e.g. weather, planet positions are built inan can be accessed using functions like WeatherData[...],AstronomicalData[...], etc.

I The generic Graphics[...] environment can be used to createdecent-looking diagrams.

I Mathematica can produce animations and manipulable graphicsusing Animate[...] and Manipulate[...] in combination withPlot and Graphics.

I See accompanying notebook for examples of these.

Page 79: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Other Neat Features

I Scientific data sets for e.g. weather, planet positions are built inan can be accessed using functions like WeatherData[...],AstronomicalData[...], etc.

I The generic Graphics[...] environment can be used to createdecent-looking diagrams.

I Mathematica can produce animations and manipulable graphicsusing Animate[...] and Manipulate[...] in combination withPlot and Graphics.

I See accompanying notebook for examples of these.

Page 80: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Other Neat Features

I Scientific data sets for e.g. weather, planet positions are built inan can be accessed using functions like WeatherData[...],AstronomicalData[...], etc.

I The generic Graphics[...] environment can be used to createdecent-looking diagrams.

I Mathematica can produce animations and manipulable graphicsusing Animate[...] and Manipulate[...] in combination withPlot and Graphics.

I See accompanying notebook for examples of these.

Page 81: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Other Neat Features

I Scientific data sets for e.g. weather, planet positions are built inan can be accessed using functions like WeatherData[...],AstronomicalData[...], etc.

I The generic Graphics[...] environment can be used to createdecent-looking diagrams.

I Mathematica can produce animations and manipulable graphicsusing Animate[...] and Manipulate[...] in combination withPlot and Graphics.

I See accompanying notebook for examples of these.

Page 82: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Quirks

Quirks to watch out for:

I ‘Undo’ button exists but rarely functions in any useful way.

I Highlighting with arrow keys is double ended :-S

I Mathematica always seems to try algebraic manipulation first.This can lead to problems when plotting functions withadditional (numerical) parameters. In this case, using a?NumericQ pattern typically avoids the issue.

I There is no equivalent of Matlab’s workspace - no easy way tocheck which variables are already defined.

Page 83: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Quirks

Quirks to watch out for:

I ‘Undo’ button exists but rarely functions in any useful way.

I Highlighting with arrow keys is double ended :-S

I Mathematica always seems to try algebraic manipulation first.This can lead to problems when plotting functions withadditional (numerical) parameters. In this case, using a?NumericQ pattern typically avoids the issue.

I There is no equivalent of Matlab’s workspace - no easy way tocheck which variables are already defined.

Page 84: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Quirks

Quirks to watch out for:

I ‘Undo’ button exists but rarely functions in any useful way.

I Highlighting with arrow keys is double ended :-S

I Mathematica always seems to try algebraic manipulation first.This can lead to problems when plotting functions withadditional (numerical) parameters. In this case, using a?NumericQ pattern typically avoids the issue.

I There is no equivalent of Matlab’s workspace - no easy way tocheck which variables are already defined.

Page 85: Mathematica 7.0.1 The original Mathematica was a computer …math.arizona.edu/~swig/documentation/mathematica/skent/mathem… · Mathematica 7.0.1 Overview: I The original Mathematica

Mathematica 7.0.1: Quirks

Quirks to watch out for:

I ‘Undo’ button exists but rarely functions in any useful way.

I Highlighting with arrow keys is double ended :-S

I Mathematica always seems to try algebraic manipulation first.This can lead to problems when plotting functions withadditional (numerical) parameters. In this case, using a?NumericQ pattern typically avoids the issue.

I There is no equivalent of Matlab’s workspace - no easy way tocheck which variables are already defined.