Mathematical Tools for Materials Scientists and Engineers

Learning to use Mathematica as a tool.

Mathematica is a tool for exploring mathematics and solving problems that can be posed as a mathematical problem.  Mathematica's coverage of mathematics and its applications is both very wide and very deep.   The depth of Mathematica is such that years must be invested before it can wielded masterfully.  However, students must begin to use Mathematica immediately.  This means that you must use this tool before you can master it.   Don't worry—you can't master this tool unless you use it!

There are several software programs like Mathematica (Maple, Matlab, Macsyma, to mention a few).  These programs allow you to solve equations, perform mathematical operations, and visualize mathematics and data.  Each one has it benefits.  Mathematica, perhaps, has a steep learning curve because it integrates so many aspects of mathematics.  Nevertheless, I believe that your intellectual and time investment in learning Mathematica will be have very profitable returns on both your future intellect and your future time.

Finally, just as there are many good ways to solve a mathematics problem, there are many different ways to solve a particular problem using Mathematica.   Some methods are perhaps more elegant than others; some methods are perhaps more clever than others—these judgements are subjective.  What is important, in the end, is 1) that the solution method works, 2) the method and solution can be communicated to others, and 3) the solution or the knowledged obtained is as valuable as the time spent acquiring it.

Starting up Mathematica

First you must locate or obtain Mathematica and permission to use it.
    
    As an MIT student, you have an Athena account from which you can run Mathematica.  There are a number of
ways to open and run a Mathematica session.  Of course,you must first login, and then one method would be to:
	1. open a shell
	2. Add the Mathematica locker by typing: add math
	 2. At the shell prompt, type mathematica.  (An interface to mathematica's software (properly known as Mathematica's  kernel) called the Front End will open as well as menus and palettes).
	 3. Solve problems by defining symbols, performing mathematical operations, employing Mathematica's functions,defining your own functions, and graphically displaying results.
    
    Also, as an MIT student, you are entitled to download a  copy and license for a modest fee so that you can run Mathematica on your own computer.  Instructions can be found at this URL: http://itinfo.mit.edu/article.php?id=6842
    The colors on your sceen may not appear to be the same as what is presented in the lectures. I use my own style sheet, you may download my style sheet from here.  Information on where to put the style sheet can be found below.  Let's get started with some simple Mathematica commands.
    If you are reading this in the Mathematica FrontEnd, then you can go ahead and familiarize yourself with some basics by executing the following lines which are Mathematica Input.  Typically, Mathematica's FrontEnd asks Mathematica's Kernal to do its job of evaluating by hitting ⇧—⌤ while the mouse in an "Input Cell." Input Cells can be identified with the  ⥡-thingy at the right.  One can evaluate one or more cells by selecting their  ⥡-thingies and hitting ⇧—⌤.

    Try executing the cells below.  Try to guess what the output might be or represent—and observe carefully whether Mathematica is doing what you would anticipate.  Notice that answers can depend on the history of commands that precede it.

Variable Assignment and Variable Types

Assigning  values to symbols

a =(( 4 π)/3)

UnitSphereVolume = a

2 a

ANewVariable =(2 a + b)^2

ANewVariable^2

b = ((4 (3.14159265358979323846264338327950288419716939937))/3)

UnitSphereNumericalVolume = b

ANewVariable

Differences between exact expressions and numerical expressions

UnitSphereVolume - UnitSphereNumericalVolume

a-((4ArcCos[-1])/3)

a-((4ArcCos[-1.0])/3)

2 Pi - 2 (3.141519)

N[5/6]

Distinction between Equality (= = ) and Assignment (=)

a == ((4ArcCos[-1])/3)

a == ((4 3.1415)/3)

Clearing Variables

?a

Clear[a]

?a

a-((4ArcCos[-1])/3)

clearing all defined variables

Clear["Global`*"]

Mathematica Functions and Basic Operations on Expressions

Mathematica Functions

a = 1/Exp[x]

b =Cos[x]

c = (a+b)^2

Alternative Syntax for Functions (There are many ways to do the same thing)

AnotherVersionofb = x//Cos

YetAnotherVersionofb = Cos@x

YetEvenAnotherVersionofb =Function[z,Cos[z]][x]

YetStillAnotherVersionofb =Function[Cos[#]][x]

FinallyAnotherVersionofb =(Cos[#]&)[x]

ANewVariable[x]

Mathematica Operations on expressions

c
AnotherVersionofC =Expand[c]

c
Simplify[AnotherVersionofC]

Calculus

IntegralofC =Integrate[c,x]

Integrate[c/x,x]

Getting information (part 1)

?ExpIntegralEi

Basic Calculus and Plotting

D[ANewVariable[x],x]

Integrate[ANewVariable[x],x]

D[ANewVariable[x],z]

tempvar = Integrate[ANewVariable[x],{x,0,y}]

D[tempvar,x]

D[tempvar,y]

Clear[tempvar];

Factor[IntegralofC]

IntegralofC
AnotherVersionofIntegralofC =Integrate[AnotherVersionofC,x]

c
D[IntegralofC,x]

Factor[c]
Simplify[D[IntegralofC,x]]

Plotting Functions

Plot[IntegralofC,{x,0,10}]

Plot[{IntegralofC,c},{x,0,10}]

Plot[c,{x,0,10},PlotRange->{0,1}]

Options[Plot]

Plot[{IntegralofC,c},{x,0,10},PlotStyle->{{Red,Thickness[0.005]},{RGBColor[0.2,0.56,1],Thickness[0.0075]}},BaseStyle->{FontFamily->"Helvetica",FontSize->24},PlotLabel->" A Function (Pretty Sky Blue)\nand Its Integral (Red)\n",AxesLabel->{"Value","Argument"},ImageSize->800]

Lists {} and Matrices {{}} (Lists of Lists)

Note  that we have already used lists in Plot and in Integrate

Clear["Global`*"]

AList = {a, b,2,7,9, 1.3, (π/2), 0}

Length[AList]

Cos[AList]

AList
AList[[2]]

AList
AList[[{3,6}]]

AList
AList[[-2]]

Sort[AList]

Select[AList,NumberQ]

Reverse[Sort[Select[AList,NumberQ]]]

Select[AList,EvenQ]

Select[AList,PrimeQ]

Perms = Permutations[Select[AList,ExactNumberQ]]

Dimensions[Perms]

Transpose[Perms]//MatrixForm

TranPerms= Transpose[Perms];

TranPerms[[3]]

TranPerms[[4,1]]

TranPerms[[1,4]]

TranPerms[[5,1]]

TranPerms[[{1,2}]]

IntList = Table[i,{i,1,Length[TranPerms[[1]]]}]

Selecting  the odd numbered columns from a matrix

TranPerms//MatrixForm
TranPerms[[All,Select[IntList,OddQ]]]//MatrixForm

Rules  ->   and    Replacement /.
Getting Help...

ARule = a->(π/3)

a

AList
AList/.ARule

SomeRules = {ARule,b->(π/12)}

AList/.SomeRules

a = SomeOtherSymbol;

AList

StrangeRule = {Rational[x_,y_] :> y/x}

(AList/.SomeRules)/.StrangeRule

Getting Help

Several  methods of getting help are available.
    
   1.  Typing ?ExpIntegralEi  returned information about the symbol  ExpIntegralEi.  Typing ??FunctionName gives even more information—try ??Plot.  Wildcards can also by used as demonstrated below.  You can click on the resulting grid-list to pull up documentation.

?*Exp*

Each of the above is linked to Mathematica's Help Browser.

2.  Typing Options[Plot] returned a list of options that can be adjusted by the user until the result (in this case the appearance) of the plot is satisfactory.

Mathematica's Help Browser is a very useful tool and will probably become a primary resource for students.  It contains good tutorials and demonstrations that can be copied and pasted.  It has very good and concise descriptions of mathematics; in fact, exploring the Help Browser is a good way to explore mathematics as well as Mathematica.  For instance , the discussion of "Combinatorial Functions"  by typing "Combinatorial" at the help browser---you will get a list of results that points to tutorials and overvies.