Intro Ducci On Mathematica
Intro Ducci On Mathematica
to Mathematica 8
Author: Harald Hller
version: English version v1.0
last modified: 12.01.2012
Licence: Creative Commons Licence by-nc-sa 3.0 at
This introductory tutorial to Mathematica 8 is designed as interactive course material and should ideally be worked
through together with students at PCs. Each student should progress sequentially through all Input/Output. Duration: approx. 90min.
Data types
The standard data type, the Notebook (.nb) provides an interactive interface in which calculations are
possible. Under File -> Save As there are some further data formats to which the notebooks can be
exported (.tex, .html, .txt, .pdf). Also single expressions can be copied as LATEX code and be pasted
into a .tex-file. Notebooks can be opened by Mathematica (interactive) or the MathReader (read
only) respectively the Wolfram CDF Player which is available as free internet browser plugin.
The forward- and backward-compatibility is given partially, which means that notebooks created in
Mathematica 7 will usually run in Mathematica 8, the opposite direction will rather cause problems.
introductory_mathematica_8_tutorial_expand.nb
Wolfram|Alpha
Wolfram|Alpha is a net-based frontend for Mathematica usage with a huge database of knowledge.
Describing as scientific Google does not really cover its whole power. Either you access it via the
website www.wolframalpha.com or there is even an integration to Mathematica. Beginning an Input
with the = sign is interpreted as Wolfram|Alpha query. E.g: = cosmological redshift z=3
cosmological redshift z = 3
Result
Assuming redshift-wavelength formula Use cosmological redshift instead
Calculate emitted wavelength
observed wavelength:
575 nm
Also include: dark energy density, matter density and radiation density
Input information:
redshift-wavelength formula
redshift
observed wavelength
575 nm nanometers
Result:
More units
emitted wavelength
143.8 nm nanometers
5.659 106 inches
0.1438 m micrometers
Equation:
1z
introductory_mathematica_8_tutorial_expand.nb
1z
emitted wavelength
redshift
observed wavelength
Cosmological results:
More
distance comoving
2 1023 km kilometers
1.24 1023 miles
0.453
scale factor
epoch
radiation temperature
10.9 K kelvins
based on 5year WMAP data and LambdaCDM model; current universe age: 13.7
billion years
Timeline:
Big Bang
5 billion years
emitted wavelength
10 billion years
present
Earth forms
143.8 nm nanometers
5.659 106 inches
0.1438 m micrometers
Input/Output I
The input of commands in Mathematica is done via the Enter key (not Return), which is either
located at the numeric keypad or it can be typed in as Shift + Return. Each Output and Input is numbered by Mathematica.
introductory_mathematica_8_tutorial_expand.nb
The input of commands in Mathematica is done via the Enter key (not Return), which is either
located at the numeric keypad or it can be typed in as Shift + Return. Each Output and Input is numbered by Mathematica.
3
3
In this way one can refer to previous In- and Output
In2 Out2
6
respectively one can refer to the last output via %.
xmax
f d x.
xmin
xmax
xmin
d x
ymax
ymin
dy f .
introductory_mathematica_8_tutorial_expand.nb
? Integ*
System`
Integer
IntegerDigits
IntegerExponent
IntegerPart
IntegerQ
IntegerString
IntegerLength
IntegerPartitions
Integers
Integral
Integrate
The Kernel
Mathematica "remembers" all definitions, In- and Outputs inside a Notebook. As described some
lines before, one can refer to previous terms easily. As long as the Kernel is running, all these definitions are available.
? Random
Random gives a uniformly distributed pseudorandom Real in the range 0 to 1.
Randomtype, range gives a pseudorandom number of the specified type, lying in the
specified range. Possible types are: Integer, Real and Complex. The default range is 0 to 1. You
can give the range min, max explicitly; a range specification of max is equivalent to 0, max.
a RandomInteger, 100
b RandomInteger, 100
c RandomInteger, 100
22
53
3
abc
78
If you want to delete entires in this memory of definitions, the Clear[Arguments] command can be
used. If you want to clear all kernel memory, i.e. kill and restart the kernel, then go to Evaluation ->
Quit Kernel -> Local. This also terminates running calculations which comes in handy, when you
realize that a calculation seems to have got stuck and you dont want to wait any longer.
introductory_mathematica_8_tutorial_expand.nb
? Clear
Clearsymbol1 , symbol2 , clears values and definitions for the symboli .
Clear" form1 ", " form2 ", clears values and
definitions for all symbols whose names match any of the string patterns formi .
Cleara, b, c
abc
abc
If one wishes not to quit ther kernel but delete all previous definitions, (of all currently opened Mathematica-Notebooks) the syntax is as follows.
Clear"Global`"
Comments
Comments (i.e. non to be executed, read-only text parts) inside Input-lines can by typed inside round
brackets and stars.
Sqrt2
True
Shortcuts
There is a number of shortcuts and hotkeys in order to simplify typing formulas to the notebook.
Some examples:
ai Subscript via "Ctrl " ;
1
Fraction lines via "Ctrl " ;
2
introductory_mathematica_8_tutorial_expand.nb
Syntax Highlighting
When typing formulae in a Mathematica notebook, syntax highlighting is very convenient. Known
Functions, trailing brackets, arguments etc. are recognoized and highlighted; either as positive feedback that everything is alright or - usually even more helpful - as negative feedback that there is some
syntactic problem. In case the syntax is faulty, klick on the plus-sign on the right hand side of the
input line to get more information about what might be wrong.
SolveSinx_ 3 Cosx_ 1, y
l1 , l2 , r1 , r2 , evaluates the ri , and assigns the results to be the values of the corresponding li .
d1
1
One can surpress the otput of an assignment by adding a colon. This assigment is evaluated not until
the definition is being used somewhere later in the Notebook. This assignment is especially useful
when the right hand side is somewhat elongate and evaluation costs computation time.
introductory_mathematica_8_tutorial_expand.nb
? :=
lhs : rhs assigns rhs to be the delayed value of lhs. rhs is maintained in
an unevaluated form. When lhs appears, it is replaced by rhs, evaluated afresh each time.
f : 1
Functions + Pattern
One main powerfulness of CAS such as Mathematica is symbolic calculus, i.e. working with functions. There is one little syntax peculiarity of Mathematica concerning this topic. Objects with arguments in the form f[x] are static; if you want the argument to be variable, then definition of the function must add an underscore (see Mathematica documentation center under keyword Pattern) to
each argument that should be a variable.
DONT :
hx : Sinx
h1
h1
DO :
gx_ : Sinx
g1
Sin1
As you can see, Mathematica does not necessarily output numerical values. In this case, the result is
an irrational number and one needs to specify further if and what numerical outoput is wanted.
Input/Output III
In order to force numerical output, one needs to type N[Argument,Digits].
introductory_mathematica_8_tutorial_expand.nb
Ng1, 100
0.8414709848078965066525023216302989996225630607983710656727517099
919104043912396689486397435430526959
There is also the possibility to append functions and objetcs that operate on the whole expression by
a double slash.
g1 N
0.841471
10
introductory_mathematica_8_tutorial_expand.nb
Clear"Global`"
please enter this input to delete all previous definitions
which would partially conflict with the upcoming section
When we compute the first derivative of a general function F[x], we get the output F'[x]. As described
in the Mathematica documentation, the arguments (function and variable) of this operation are
separated by a comma.
DFx, x
F x
We have to further specify the function to be derived in order to get a calculated output of course. As
an example we define a function G in and compute ther first partial derivative with respecto to one
variable,
Gx_, y_ : x y
DGx, y, y
x
introductory_mathematica_8_tutorial_expand.nb
? FullSimplify
FullSimplifyexpr tries a wide range of transformations on
expr involving elementary and special functions, and returns the simplest form it finds.
FullSimplifyexpr, assum does simplification using assumptions.
? Expand
Expandexpr expands out products and positive integer powers in expr.
Expandexpr, patt leaves unexpanded any parts of expr that are free of the pattern patt.
E.g.: Polynom
x x 1^3 x^2 3 x^5 x 1 x^2 x x^2 x 1^2^2
1 x x2 x 1 x3 1 x2 x x2 3 x x2
2
11
12
introductory_mathematica_8_tutorial_expand.nb
FullSimplify
2 x2 5 x 3 x 1 3 x5 x
Expand
2 5 x2 3 x3 x4 243 x5 405 x6 270 x7 90 x8 15 x9 x10
Plot
Plot3Matrix
PlotJoined
PlotLayout
PlotPoints
PlotRangeClipping
Plot3D
PlotDivision
PlotLabel
PlotMarkers
PlotRange
PlotRangePadding
PlotRegion
PlotStyle
introductory_mathematica_8_tutorial_expand.nb
Plot Functions
PlotExpx, x, 0, 10
8000
6000
4000
2000
10
PlotSinx x, x, 10, 10
1.0
0.8
0.6
0.4
0.2
10
5
0.2
10
13
14
introductory_mathematica_8_tutorial_expand.nb
10
10
Dynamic Graphics
The two major commands for interactice plotting are:
? Dynamic
Dynamicexpr represents an object that displays as the dynamically updated current value
of expr. If the displayed form of Dynamicexpr is interactively changed or edited, an assignment
expr val is done to give expr the new value val that corresponds to the displayed form.
Dynamicexpr, None does not allow interactive changing or editing.
Dynamicexpr, f continually evaluates f val, expr during interactive changing or editing of val.
Dynamicexpr, f , fend also evaluates fend val, expr when interactive changing or editing is complete.
Dynamicexpr, fstart , f , fend also evaluates fstart val, expr when interactive changing or editing begins.
? Manipulate
Manipulateexpr, u, umin , umax generates a version
of expr with controls added to allow interactive manipulation of the value of u.
Manipulateexpr, u, umin , umax , du allows the value of u to vary between umin and umax in steps du.
Manipulateexpr, u, uinit , umin , umax , takes the initial value of u to be uinit .
Manipulateexpr, u, uinit , ulbl , labels the controls for u with ulbl .
Manipulateexpr, u, u1 , u2 , allows u to take on discrete values u1 , u2 , .
Manipulateexpr, u, , v, , provides controls to manipulate each of the u, v, .
Manipulateexpr, cu u, , cv v, ,
links the controls to the specified controllers on an external device.
introductory_mathematica_8_tutorial_expand.nb
ManipulatePlota Sina x x,
x, 7, 7, PlotRange 15, 15, a, 0, 10, 1
15
10
10
15
? Show
Showgraphics, options shows graphics with the specified options added.
Showg1 , g2 , shows several graphics combined.
15
16
introductory_mathematica_8_tutorial_expand.nb
ShowPlotSinx, x, 0, Pi,
AspectRatio Automatic, PlotStyle Thick, Gray,
Background White, PlotRange 0, 2.5,
PlotExpx x x^2, x, 0, Pi, AspectRatio Automatic,
PlotStyle Thick, Blue,
Background White, PlotRange 0, 2.5,
GraphicsThick, Gray, Arrow0.2, Sin0.2, 0.2, 2,
GraphicsThick, Gray, Arrow.5, Sin.5, .5, 2,
GraphicsThick, Gray, Arrow.8, Sin.8, .8, 2,
GraphicsThick, Gray, Arrow1.1, Sin1.1, 1.1, 2,
GraphicsThick, Gray, Arrow1.1, Sin1.1, 1.1, 2,
GraphicsThick, Blue, Arrow1.7, Exp1.7 1.7 1.7^2,
2.5, Exp1.7 1.7 1.7^2,
GraphicsThick, Blue, Arrow1.8, Exp1.8 1.8 1.8^2,
2.5, Exp1.8 1.8 1.8^2,
GraphicsThick, Blue, Arrow1.9, Exp1.9 1.9 1.9^2,
2.5, Exp1.9 1.9 1.9^2,
GraphicsThick, Blue, Arrow2, Exp2 2 2^2,
2.5, Exp2 2 2^2,
GraphicsThick, Red, Circle2, 1,
GraphicsThick, Red, Circle2, 1, 1.1, Pi 8, 0,
GraphicsThick, Red, Circle2, 1, 1.1, Pi 8, 2 Pi 8,
GraphicsThick, Red, Circle2, 1, 1.1, 3 Pi 8, 4 Pi 8,
GraphicsThick, Red, Circle2, 1, 1.1, 5 Pi 8, 6 Pi 8,
GraphicsThick, Red, Circle2, 1, .9, Pi 8, 0,
GraphicsThick, Red, Circle2, 1, .9, Pi 8, 2 Pi 8,
GraphicsThick, Red, Circle2, 1, .9, 3 Pi 8, 4 Pi 8,
GraphicsThick, Red, Circle2, 1, .9, 5 Pi 8, 6 Pi 8
introductory_mathematica_8_tutorial_expand.nb
17
2.5
2.0
1.5
1.0
0.5
0.0
0.5
1.0
1.5
2.0
2.5
3.0
18
introductory_mathematica_8_tutorial_expand.nb
? Dimensions
Dimensionsexpr gives a list of the dimensions of expr.
Dimensionsexpr, n gives a list of the dimensions of expr down to level n.
Dimensionsvec
4
Of course this concept can be used to arbitrarily interlace lists of lists etc.
tensor : a, b, c, a, b, c, a, b, c, a, b, c,
a, b, c, a, b, c, a, b, c, a, b, c
Dimensionstensor
2, 4, 3
E.g.: The Identity Matrix
? IdentityMatrix
IdentityMatrixn gives the n n identity matrix.
M : IdentityMatrix10
DimensionsM
10, 10
introductory_mathematica_8_tutorial_expand.nb
Tableexpr, i, imin , imax , j, jmin , jmax , gives a nested list. The list associated with i is outermost.
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
1
10
1
11
1
12
1
13
1
14
1
15
1
16
1
3
1
4
1
5
1
6
1
7
1
8
1
9
1
10
1
11
1
12
1
13
1
14
1
15
1
16
1
17
1
4
1
5
1
6
1
7
1
8
1
9
1
10
1
11
1
12
1
13
1
14
1
15
1
16
1
17
1
18
1
5
1
6
1
7
1
8
1
9
1
10
1
11
1
12
1
13
1
14
1
15
1
16
1
17
1
18
1
19
1
6
1
7
1
8
1
9
1
10
1
11
1
12
1
13
1
14
1
15
1
16
1
17
1
18
1
19
1
20
1
7
1
8
1
9
1
10
1
11
1
12
1
13
1
14
1
15
1
16
1
17
1
18
1
19
1
20
1
21
? Subscript
Subscriptx, y is an object that formats as x y .
Subscriptx, y1 , y2 , formats as x y1 ,y2 , .
1
8
1
9
1
10
1
11
1
12
1
13
1
14
1
15
1
16
1
17
1
18
1
19
1
20
1
21
1
22
1
9
1
10
1
11
1
12
1
13
1
14
1
15
1
16
1
17
1
18
1
19
1
20
1
21
1
22
1
23
1
10
1
11
1
12
1
13
1
14
1
15
1
16
1
17
1
18
1
19
1
20
1
21
1
22
1
23
1
24
1
11
1
12
1
13
1
14
1
15
1
16
1
17
1
18
1
19
1
20
1
21
1
22
1
23
1
24
1
25
1
12
1
13
1
14
1
15
1
16
1
17
1
18
1
19
1
20
1
21
1
22
1
23
1
24
1
25
1
26
1
13
1
14
1
15
1
16
1
17
1
18
1
19
1
20
1
21
1
22
1
23
1
24
1
25
1
26
1
27
1
14
1
15
1
16
1
17
1
18
1
19
1
20
1
21
1
22
1
23
1
24
1
25
1
26
1
27
1
28
1
15
1
16
1
17
1
18
1
19
1
20
1
21
1
22
1
23
1
24
1
25
1
26
1
27
1
28
1
29
19
20
introductory_mathematica_8_tutorial_expand.nb
TableSubscriptm, i, j, i, 3, j, 3 MatrixForm
m1,1 m1,2 m1,3
m2,1 m2,2 m2,3
m3,1 m3,2 m3,3
introductory_mathematica_8_tutorial_expand.nb
21
JacobianMatrixSpherical MatrixForm
Cos Sin r Cos Cos r Sin Sin
Sin Sin r Cos Sin r Cos Sin
Cos
r Sin
0
Just as further example for some functionalities of that package, we calculate the unit volume of a
cylindre with radius and height one by the differential geometric rule as the integral over the Jacobian determinant.
SetCoordinatesCylindricalr, , z
Cylindricalr, , z
IntegrateJacobianDeterminantCylindrical,
r, 0, 1, , 0, 2 , z, 0, 1
Just to check, we compute the divergence of the unit vector in x-direction for cartesian coordinates
SetCoordinatesCartesian
CartesianXx, Yy, Zz
Div1, 0, 0
0
which vanishes of course.
22
introductory_mathematica_8_tutorial_expand.nb
vec.vec
a2 b2 c2
With the star * the entries of the list are multiplied pairwise.
vec vec
a2 , b2 , c2
The cross profuct (vector product) is set with the command Cross.
Crossvec, vec
0, 0, 0
Since a vector is parallel to itself, the cross product has to vanish.
Cross1, 0, 0, 0, 1, 0
0, 0, 1
The cross product between two unit base vectors in three dimensions yields the third unit base vector.
introductory_mathematica_8_tutorial_expand.nb
23
? LinearSolve
LinearSolvem, b finds an x which solves the matrix equation m.x b.
LinearSolvem generates a LinearSolveFunction which can be applied repeatedly to different b.
24
introductory_mathematica_8_tutorial_expand.nb
? Det
Detm gives the determinant of the square matrix m.
DetH N
1.05854 10124
The determinant of the 15-dim. Hilbert-Matrix is practically zero. The higher dimensional H, the
smaller gets its determinant and the more difficult gets its inversion.
? HilbertMatrix
HilbertMatrixn gives the nn Hilbert matrix with elements of the form 1 i j 1.
HilbertMatrixm, n gives the mn Hilbert matrix.
DetHilbertMatrix50 N
1.392615568935140 101466
Clear"Global`"
in which documentation entry it states already indicatively that it attempts to solve the problem
posed. Mathematica has implemented a variety of algorithms that are tried out.
introductory_mathematica_8_tutorial_expand.nb
1
2
, b
3
2
, c 1
25
26
introductory_mathematica_8_tutorial_expand.nb
, b
2
a
, b
2
a
1
4
1
4
1
4
1
4
1
4
1
4
1
4
1
4
234
3
234
3
4
3
4
3
4
3
4
3
4
3
4
, b
, b
, b
, b
1
2
1
2
2
3
1
2
1
2
1
1
2
3
3
234
1
1
, b
, b
, b
, b
34
34
34
34
1
1
, c
, c
34
34
34
34
, c
, c
, c 1,
, c 1,
234
, c 1, a
, b
, c 1, a
, b
1
2
1
2
1
2
1
2
, c
, c
, c
, c
1
2
1
2
1
2
3 ,
3 ,
3 ,
3 ,
3 ,
3 ,
3 ,
3
Mathematica will list all found solutions also if they sometimes not usable for our purposes because
they are unphysical or violate some other conditions. In this case we frequently have to come back to
pen and paper in order to pick the right results.
introductory_mathematica_8_tutorial_expand.nb
27
Mathematica will list all found solutions also if they sometimes not usable for our purposes because
they are unphysical or violate some other conditions. In this case we frequently have to come back to
pen and paper in order to pick the right results.
Some more useful commands concerning linear algebra:
? RandomReal
RandomReal gives a pseudorandom real number in the range 0 to 1.
RandomRealxmin , xmax gives a pseudorandom real number in the range xmin to xmax .
RandomRealxmax gives a pseudorandom real number in the range 0 to xmax .
RandomRealrange, n gives a list of n pseudorandom reals.
A RandomReal1, 1, 5, 5
0.474727, 0.388645, 0.461371, 0.938493, 0.950533,
0.830478, 0.139342, 0.801181, 0.0834233, 0.259048,
0.606089, 0.750426, 0.0652498, 0.50112, 0.928461,
0.903335, 0.207855, 0.368359, 0.051829, 0.0604615,
0.0480989, 0.359201, 0.128467, 0.236191, 0.0770996
? MatrixRank
MatrixRankm gives the rank of the matrix m.
MatrixRankA
5
? Eigenvalues
Eigenvaluesm gives a list of the eigenvalues of the square matrix m.
Eigenvaluesm, a gives the generalized eigenvalues of m with respect to a.
Eigenvaluesm, k gives the first k eigenvalues of m.
Eigenvaluesm, a, k gives the first k generalized eigenvalues.
EigenvaluesA
0.195529 1.07151 , 0.195529 1.07151 ,
0.325532 0.509743 , 0.325532 0.509743 , 0.269558
28
introductory_mathematica_8_tutorial_expand.nb
? Eigenvectors
Eigenvectorsm gives a list of the eigenvectors of the square matrix m.
Eigenvectorsm, a gives the generalized eigenvectors of m with respect to a.
Eigenvectorsm, k gives the first k eigenvectors of m.
Eigenvectorsm, a, k gives the first k generalized eigenvectors.
EigenvectorsA
0.144597 0.32199 , 0.647119 0. , 0.0223833 0.456948 ,
0.391941 0.0945935 , 0.127755 0.261649 ,
0.144597 0.32199 , 0.647119 0. , 0.0223833 0.456948 ,
0.391941 0.0945935 , 0.127755 0.261649 ,
0.0352433 0.480426 , 0.327103 0.0011468 ,
0.259849 0.380617 , 0.542821 0. , 0.276221 0.278583 ,
0.0352433 0.480426 , 0.327103 0.0011468 ,
0.259849 0.380617 , 0.542821 0. , 0.276221 0.278583 ,
0.320862, 0.369529, 0.656308, 0.272299, 0.505578
? CharacteristicPolynomial
CharacteristicPolynomialm, x gives the characteristic polynomial for the matrix m.
CharacteristicPolynomialm, a, x gives the generalized characteristic polynomial with respect to a.
CPx_ CharacteristicPolynomialA, x
0.116983 0.603626 x 0.979111 x2 1.36765 x3 0.529564 x4 x5
The eigenvalues of a matrix (resp. a linear map) are the zeros of the characteristical polynomial
which we can probe:
CPEigenvaluesA
2.22045 1016 0. , 2.22045 1016 0. ,
2.77556 1017 5.55112 1017 ,
2.77556 1017 5.55112 1017 , 1.73472 1017
... is approximately zweo.
introductory_mathematica_8_tutorial_expand.nb
29
e^i pi 1
ei pi 1
DO :
E^I Pi 1
True
?E
E is the exponential constant e base of natural logarithms, with numerical value 2.71828.
?I
I represents the imaginary unit
1 .
? Pi
Pi is , with numerical value 3.14159.
30
introductory_mathematica_8_tutorial_expand.nb
? Infinity
Infinity or is a symbol that represents a positive infinite quantity.
introductory_mathematica_8_tutorial_expand.nb
31
? Log
Logz gives the natural logarithm of z logarithm to base e.
Logb, z gives the logarithm to base b.
? Gamma
Gammaz is the Euler gamma function z.
Gammaa, z is the incomplete gamma function a, z.
Gammaa, z0 , z1 is the generalized incomplete
? DiracDelta
DiracDeltax represents the Dirac delta function x.
DiracDeltax1 , x2 , represents the multidimensional Dirac delta function x1 , x2 , .
Series
In order to get used to handling series, we examine a frequent application, namely determining the
limit of a series.
Clear"Global`"
please enter this input to delete all previous definitions
which would partially conflict with the upcoming section
We can define series analogously to functions
an_ 1 1 n^n
or recursively
bn_ : bn 1 bn 2
b0 : 1
b1 : 2
b2 : 2
32
introductory_mathematica_8_tutorial_expand.nb
Limitan, n Infinity
Tablebn, n, 0, 10
1, 2, 2, 4, 8, 32, 256, 8192,
2 097 152, 17 179 869 184, 36 028 797 018 963 968
Of course also sums are implemented im Mathematica
? Sum
Sum f , i, imax evaluates the sum f .
imax
jmax
iimin j jmin
? BesselI
BesselIn, z gives the modified Bessel function of the first kind In z.
introductory_mathematica_8_tutorial_expand.nb
Sumx^k k, k, 0, n
x Gamma1 n, x
n
and especially useful is also the Series command which expands a function into its Taylor series.
? Series
Series f , x, x0 , n generates a power series expansion for f about the point x x0 to order x x0 n .
SeriesSinx, x, 0, 15
x
x3
x5
x7
x9
Ox16
39 916 800 6 227 020 800 1 307 674 368 000
6
120
11
x
xmax
f d x.
xmin
xmax
xmin
d x
ymax
ymin
dy f .
33
34
introductory_mathematica_8_tutorial_expand.nb
Erfix
? Erfi
Erfiz gives the imaginary error function erfiz i.
Differential Equations
Solving Ordinary Differential Equations (ODEs)
Solving differential equations is another major strenght of CAS. While solving an ODE can require a
sophisticated ansatz and several analytic techniques, Mathematica is a lot faster in giving results
with help of the command DSolve.
Clear"Global`"
please enter this input to delete all previous definitions
which would partially conflict with the upcoming section
introductory_mathematica_8_tutorial_expand.nb
35
DSolvey'x yx 0, yx, x
yx x C1
E.g.: Solving ODEs with boundary condition
DSolvez'x zx 0, z0 1, zx, x
zx x
E.g.: Solving systems of ODEs
eqn1 : s'x tx 0
eqn2 : t'x sx 0
DSolveeqn1, eqn2, sx, tx, x
sx
1
2
tx
x 1 2 x C1
1
2
1
2
x 1 2 x C1
x 1 2 x C2,
1
2
x 1 2 x C2
36
introductory_mathematica_8_tutorial_expand.nb
there is the possibility to look for solutions numerically. Iterative algorithms implemented in Mathematica are capable of finding numerical solutions of ODEs.
? NDSolve
NDSolveeqns, y, x, xmin , xmax finds a numerical solution to the ordinary differential
equations eqns for the function y with the independent variable x in the range xmin to xmax .
NDSolveeqns, y, x, xmin , xmax , t, tmin , tmax finds a numerical solution to the partial differential equations eqns.
NDSolveeqns, y1 , y2 , , x, xmin , xmax finds numerical solutions for the functions yi .
1.0
0.5
10
12
14
0.5
1.0
1.5
CAS: Alternatives
Mathematica is a comprehensive computer algebra system, however it is a proprietary product.
There are several free open source alternatives:
Axiom:
Scilab:
Octave:
Maxima:
Wiris:
Geogebra:
http://axiom-wiki.newsynthesis.org/FrontPage
http://www.scilab.org/
http://www.gnu.org/software/octave/
http://maxima.sourceforge.net/
http://www.wiris.com/
http://www.geogebra.org/cms/
Axiom:
Scilab:
Octave:
Maxima:
Wiris:
Geogebra:
http://axiom-wiki.newsynthesis.org/FrontPage
http://www.scilab.org/
http://www.gnu.org/software/octave/
http://maxima.sourceforge.net/
http://www.wiris.com/
http://www.geogebra.org/cms/
37