Sie sind auf Seite 1von 31

2014 - Steven Tschantz

Math 256 - Mathematica commands


Steven Tschantz
1/8/14

101 useful commands


Here are some of the most useful commands and functions in Mathematica. You can access the entire
Mathematica reference manual and numerous tutorials in the Documentation Center under the Help
menu. Highlight a command and select Help>Find Selected Function to get the full documentation on
any of these commands.

1. %
The symbol % refers to the last computed result. Beware, this may not be the result directly above the
cell with % if you evaluate cells out of order. The symbol %% is the result before the last result, %%%
the result before that. It is better to assign values you want to reuse to explicit variable names.
In[297]:=
Out[297]=

In[298]:=
Out[298]=

In[299]:=
Out[299]=

In[300]:=
Out[300]=

1+2
3
%+3
6
%+4
10
% + %% + %%%
19

2. List
Lots of functions allow and some require a list as one of its arguments, A list is usually delimited by
braces { }, but this is short-hand for the List function.
In[301]:=
Out[301]=

81, 2, 3, 4, 5<
81, 2, 3, 4, 5<

02.1-Commands.nb

In[302]:=
Out[302]=

List@1, 2, 3, 4, 5D
81, 2, 3, 4, 5<

3. Table
A function that creates lists is the Table command, taking two arguments, an expression possibly
involving some indexing variable and a specification for the range of that variable. Thus, for example,
In[303]:=
Out[303]=

Table@i, 8i, 1, 10<D

81, 2, 3, 4, 5, 6, 7, 8, 9, 10<

gives a list with generic entry given by i for values of i from 1 to 10 (by default in steps of 1). The
second argument is a list giving a variable, a start value and an end value, which is standard for many
functions in Mathematica. Here optionally you can also add an increment size as a fourth component of
the range specification.

4. MatrixForm
Table can also form two dimensional lists, that is a list of lists, by using two index variables and taking a
third argument specifying a range for the second index variable. A matrix in Mathematica is represented as a list of its rows. To display a matrix as a matrix you can use MatrixForm, one of a number of
functions that dont evaluate to anything but control the output of the expression.
In[304]:=
Out[304]=

In[305]:=

Table@i * j, 8i, 1, 10<, 8j, 1, 5<D

881, 2, 3, 4, 5<, 82, 4, 6, 8, 10<, 83, 6, 9, 12, 15<, 84, 8, 12, 16, 20<,
85, 10, 15, 20, 25<, 86, 12, 18, 24, 30<, 87, 14, 21, 28, 35<,
88, 16, 24, 32, 40<, 89, 18, 27, 36, 45<, 810, 20, 30, 40, 50<<
MatrixForm@Table@i * j, 8i, 1, 10<, 8j, 1, 5<DD

Out[305]//MatrixForm=

1
2
3
4
5
6
7
8
9
10

2
4
6
8
10
12
14
16
18
20

3
6
9
12
15
18
21
24
27
30

4
8
12
16
20
24
28
32
36
40

5
10
15
20
25
30
35
40
45
50

5. TableForm
Sometimes you want to display a table of results. Many functions take optional additional arguments in
the form of rules, in this case rules specifying the formatting of the table with column headers.

02.1-Commands.nb

In[306]:=

Out[306]=

In[307]:=

Table@8x, Sin@xD<, 8x, 0, Pi 2, Pi 12<D


:80, 0<, :

-1 +

12

>, : , >, : ,
6 2
4

>, : ,
3
2

3
2

TableForm@Table@8x, Sin@xD<, 8x, 0, Pi 2, Pi 12<D,


TableHeadings 88<, 8"x", "sinHxL"<<D

>, :

1+
,

12

>, : , 1>>
2
2
3

Out[307]//TableForm=

x
0

sinHxL
0

12

-1+

1
2

3
2

1
2
3

5
12

1+

6. FullForm
If you ever wonder what Mathematica really has as an expression, the FullForm command prints out
results using the names of commands rather than special notations. You wont need this often, but it
may occasionally help clarify puzzling results.
In[308]:=

Sin@Pi 12D
-1 +

Out[308]=

2
In[309]:=

FullForm@Sin@Pi 12DD

Out[309]//FullForm=

Times@Rational@1, 2D, Power@2, Rational@- 1, 2DD, Plus@- 1, Power@3, Rational@1, 2DDDD

7. Length
The Length function gives the length of a list, or in fact the number of arguments in any expression.
In[310]:=
Out[310]=

In[311]:=
Out[311]=

Table@x, 8x, 0.1, 0.2, 0.01<D

80.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2<
Length@%D
11

02.1-Commands.nb

In[312]:=
Out[312]=

In[313]:=
Out[313]=

In[314]:=

x^2 + x + 1
1 + x + x2
Length@%D
3
FullForm@%%D

Out[314]//FullForm=

Plus@1, x, Power@x, 2DD

8. Dimensions
A matrix is a list of rows, each row with the same number of elements. To determine how many rows
and columns a matrix has you can use the Dimensions function. Of course this may not be so interesting if you have created the matrix and already know the dimensions. But you can also form an operate
on three dimensional lists, say a list of matrices all having the same number of rows and columns, and
keeping track of indexing in such structures can sometimes be confusing. The Dimensions function
gives a list of the dimensions of such multi-dimensional lists down to the level where all component lists
have the same length. Thus in a list of lists not all of the same length, Dimensions will return just the
length of the top level list, since variable length rows do not make a rectangular matrix.
In[315]:=
Out[315]=

In[316]:=
Out[316]=

In[317]:=
Out[317]=

Table@i * x + j * y + k * z, 8i, 1, 2<, 8j, 3, 4<, 8k, 5, 7<D

888x + 3 y + 5 z, x + 3 y + 6 z, x + 3 y + 7 z<, 8x + 4 y + 5 z, x + 4 y + 6 z, x + 4 y + 7 z<<,


882 x + 3 y + 5 z, 2 x + 3 y + 6 z, 2 x + 3 y + 7 z<, 82 x + 4 y + 5 z, 2 x + 4 y + 6 z, 2 x + 4 y + 7 z<<<
Dimensions@%D
82, 2, 3<

Dimensions@881<, 82, 3<<D


82<

9. Part
The Part function extracts the n-th element from a list, or really from any expression which is a function
applied to a number of arguments. The double square bracket notation x[[n]] is usually used for the
Part function.
In[318]:=
Out[318]=

In[319]:=
Out[319]=

Table@i ^ 2, 8i, 1, 10<D

81, 4, 9, 16, 25, 36, 49, 64, 81, 100<


%@@6DD
36

Negative arguments index backward from the right end of the list
In[320]:=
Out[320]=

%%@@- 1DD
100

The notation x[[i,j]] accesses the i,j-th entry of a two dimensional list. Note that x[[i]] gives the whole i-th
row in a matrix x.

02.1-Commands.nb

The notation x[[i,j]] accesses the i,j-th entry of a two dimensional list. Note that x[[i]] gives the whole i-th
row in a matrix x.
In[321]:=
Out[321]=

In[322]:=
Out[322]=

In[323]:=
Out[323]=

Table@i * j, 8i, 1, 10<, 8j, 1, 5<D

881, 2, 3, 4, 5<, 82, 4, 6, 8, 10<, 83, 6, 9, 12, 15<, 84, 8, 12, 16, 20<,
85, 10, 15, 20, 25<, 86, 12, 18, 24, 30<, 87, 14, 21, 28, 35<,
88, 16, 24, 32, 40<, 89, 18, 27, 36, 45<, 810, 20, 30, 40, 50<<
%@@5, 3DD
15
%%@@5DD

85, 10, 15, 20, 25<

Part applies just as well to non-rectangular matrices, and generalizes to arbitrary multi-dimensional
lists. But it also applies to arbitrary expressions.
In[324]:=
Out[324]=

In[325]:=
Out[325]=

In[326]:=

x^2 + x + 1
1 + x + x2
%@@3DD
x2
FullForm@%%D

Out[326]//FullForm=

Plus@1, x, Power@x, 2DD

Finally, there are a few special argument forms used for Part. The argument All takes all possible
values of the index in that position. A range of indices is denoted by i;;j.
In[327]:=
Out[327]=

Table@i * j, 8i, 1, 10<, 8j, 1, 5<D

881, 2, 3, 4, 5<, 82, 4, 6, 8, 10<, 83, 6, 9, 12, 15<, 84, 8, 12, 16, 20<,
85, 10, 15, 20, 25<, 86, 12, 18, 24, 30<, 87, 14, 21, 28, 35<,
88, 16, 24, 32, 40<, 89, 18, 27, 36, 45<, 810, 20, 30, 40, 50<<

The fifth column of this is


In[328]:=
Out[328]=

%@@All, 5DD

85, 10, 15, 20, 25, 30, 35, 40, 45, 50<

The first two entries in the first three rows is given by


In[329]:=
Out[329]=

%%@@1 ;; 3, 1 ;; 2DD

881, 2<, 82, 4<, 83, 6<<

10. N
The N function converts exact numerical quantities to approximate decimal numbers. Numbers written
with a decimal point are automatically decimal numbers with machine precision. Without a decimal
point a number is interpreted as an integer and computations with integers are done exactly, with as
many digits as necessary. The optional second argument specifies the number of significant figures to
generate and display.

The N function converts exact numerical quantities to approximate decimal numbers. Numbers written
with a decimal point are automatically decimal numbers with machine precision. Without a decimal
point a number is interpreted as an integer and computations with integers are done exactly, with as
many digits as necessary. The optional second argument specifies the number of significant figures to
generate and display.

02.1-Commands.nb

In[330]:=
Out[330]=

In[331]:=
Out[331]=

N@22 7D

3.14286

N@Pi, 100D
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089
98628034825342117068

11. NumberForm
The NumberForm command is another wrapper function that doesnt change the value but controls the
formatting of output, in this case controlling the formatting of numbers. The simplest form controls the
number of significant digits displayed.
In[332]:=
Out[332]=

In[333]:=

N@PiD
3.14159
NumberForm@%, 10D

Out[333]//NumberForm=

3.141592654

Note that the first command computes the machine precision form of , approximately 16 decimal
digits. The NumberForm command doesnt calculate more digits of precision than is already available
in a number, it only shows the specified number of digits.of precision. A second version of this command sets the maximum number of digits and the number of digits to the right of the decimal.
In[334]:=

NumberForm@1000. 29, 85, 2<D

Out[334]//NumberForm=

34.48

12. Round
The Round function rounds an approximate number to the nearest integer, or with an optional second
argument rounds to the nearest multiple of some increment.
In[335]:=
Out[335]=

In[336]:=
Out[336]=

Round@1.2345D
1
Round@1.2345, 0.01D
1.23

13. Chop
Occasionally in a long computation, round-off errors accumulate so that a value which should be zero
ends up to be slightly off, usually on the order of 10-15. The Chop function sets to 0 values that are
sufficiently close to zero, usually within 10-10 but with an optional second argument allowing the tolerance to be specified. This can be espcially useful to get rid of imaginary parts of expressions that
should be real.

Occasionally in a long computation, round-off errors accumulate so that a value which should be zero
ends up to be slightly off, usually on the order of 10-15. The Chop function sets to 0 values that are
sufficiently close to zero, usually within 10-10 but with an optional second argument 02.1-Commands.nb
allowing the tolerance to be specified. This can be espcially useful to get rid of imaginary parts of expressions that
should be real.
In[337]:=
Out[337]=

In[338]:=
Out[338]=

In[339]:=
Out[339]=

1. 3 + 1. 9 + 1. 27 + 1. 81 + 1 243
0.497942

243 * % - 81 - 27 - 9 - 3 - 1
- 1.42109 10-14
Chop@%D
0

14 - 15. Plus, Minus


Of course, Mathematica does arithmetic. Addition is Plus and is denoted by +. Subtraction is Subtract,
is denoted by - and translates to addition of a negative multiple. Mathematica adds all of the numerical
arguments and combines and sorts other terms in algebraic expressions.
In[340]:=
Out[340]=

1 + x + x^2 + x^3 + x^2 - 2 x - 3


- 2 - x + 2 x2 + x3

16 - 17. Times, Divide


Multiplication is Times and is denoted by * or by juxtaposition, but you need to leave a space between
letters else a single symbol will be interpreted. (Are you surprised by the following result? Use a * when
in doubt.) Division is Divide and is denoted by /.
In[341]:=
Out[341]=

In[342]:=

2 * z3 * y 4 * x y
8 x y2 z3
xyzxy
1

Out[342]=

y2

18 - 19. Power, Sqrt


Exponentiation is Power and is denoted by ^ and displayed using superscripts. You can enter superscripts for powers but it is usually simpler to just type your expression.
In[343]:=
Out[343]=

In[344]:=
Out[344]=

In[345]:=
Out[345]=

2^3^4
2 417 851 639 229 258 349 412 352
2 ^ H3 ^ 4L

2 417 851 639 229 258 349 412 352


H2 ^ 3L ^ 4
4096

02.1-Commands.nb

In[346]:=
Out[346]=

2 ^ H3 * 4L
4096

The square root function is entered as Sqrt and displays as a radical. This is one of the few Mathematica functions that is an abbreviation but not standard mathematical usage. It translates as raising to the
1/2 power.
In[347]:=

Sqrt@2D

Out[347]=

In[348]:=

N@%D

Out[348]=

In[349]:=

1.41421
Sqrt@2.D

Out[349]=

1.41421

In[350]:=

Sqrt@xD
x

Out[350]=

In[351]:=

FullForm@%D

Out[351]//FullForm=

Power@x, Rational@1, 2DD

20 - 22. I, E, Pi
Mathematica works also with complex numbers, exact and approximate. The square root of -1, i in
standard mathematical notation is denoted by a capital I in keeping with Mathematicas convention of
capitalizing built-in functions, but displays as a stylized letter to distinguish it from the variable i.
In[352]:=
Out[352]=

In[353]:=
Out[353]=

Sqrt@- 1D

H1 + 2 * IL * H2 + 3 * IL
-4 + 7

The base of the natural log is entered as E and displays as a stylized e to distinguish it from a variable.
In[354]:=

Out[354]=

In[355]:=
Out[355]=

N@%D
2.71828

Pi is .
In[356]:=
Out[356]=

Pi

02.1-Commands.nb

In[357]:=
Out[357]=

N@%D
3.14159

23 - 42. Sin, Cos, Tan, Cot, Sec, Csc, ArcSin, ArcCos, ArcTan, ArcCot, ArcSec,
ArcCsc, Exp, Log, Log10, Abs, Sign, Min, Max, Floor
Sin is sin, Cos is cos, Tan is tan, Cot is cot, Sec is sec, Csc is csc, ArcSin is arcsin, ArcCos is arccos,
ArcTan is arctan, ArcCot is arccot, ArcSec is arcsec, ArcCsc is ArcCsc, Exp is exp is the exponential
function ex , Log is ln (or log) the log to base e, Log10 is log10 the log to the base 10, Abs[x] is |x|, Sign
is sgn, Min is min, Max is max, and Floor is the greatest integer function.
In[358]:=

Sin@xD + Cos@xD + Tan@xD + Cot@xD + Sec@xD + Csc@xD

Out[358]=

Cos@xD + Cot@xD + Csc@xD + Sec@xD + Sin@xD + Tan@xD

In[359]:=

ArcSin@xD + ArcCos@xD + ArcTan@xD + ArcCot@xD + ArcSec@xD + ArcCsc@xD

Out[359]=

ArcCos@xD + ArcCot@xD + ArcCsc@xD + ArcSec@xD + ArcSin@xD + ArcTan@xD

In[360]:=

Out[360]=

Exp@xD + Log@xD + Log10@xD


x + Log@xD +

Log@xD
Log@10D

In[361]:=

Abs@xD + Sign@xD + Min@x, yD + Max@x, yD + Floor@xD

Out[361]=

Abs@xD + Floor@xD + Max@x, yD + Min@x, yD + Sign@xD

43 - 44. Simplify, FullSimplify


Mathematica does some rearrangement of algebraic expressions, for example, writing polynomials in
increasing degree order allowing it to combine like degree terms. Other simplifications arent by default
applied. Mathematica will apply basic simplification rules when you use the Simplify command. The
FullSimplify command is occasionally necessary and tries more simplifications.
In[362]:=

Simplify@Hx ^ 3 - 1L Hx ^ 2 - 1LD
1 + x + x2

Out[362]=

1+x
In[363]:=
Out[363]=

In[364]:=

Simplify@Sin@2 xD Cos@xDD
2 Sin@xD

Simplify@Sin@ArcTan@xDDD
x

Out[364]=

1 + x2

45 - 50. Expand, ExpandAll, Factor, PowerExpand, Together, Apart


The Expand command expands products of sums, e.g., multiplying polynomials to get a polynomial in
the form of a sum of products of powers of variables and coefficients. ExpandAll applies Expand in all
parts of an expression. Factor tries to factor integer polynomials.

10

02.1-Commands.nb

The Expand command expands products of sums, e.g., multiplying polynomials to get a polynomial in
the form of a sum of products of powers of variables and coefficients. ExpandAll applies Expand in all
parts of an expression. Factor tries to factor integer polynomials.
In[365]:=
Out[365]=

In[366]:=
Out[366]=

In[367]:=
Out[367]=

Expand@Hx + 1L Hx + 2L Hx + 3LD
6 + 11 x + 6 x2 + x3
Factor@%D

H1 + xL H2 + xL H3 + xL

ExpandAll@Hx + 1L Sin@Hx + 2L * Hx + 3LDD


SinA6 + 5 x + x2 E + x SinA6 + 5 x + x2 E

Occasionally you will have a square root of an even power of a variable. Mathematica doesnt simplify
x2 could be x or -x. PowerExpand expands such expressions assuming a positive x

this since
In[368]:=

Sqrt@x ^ 2D
x2

Out[368]=

In[369]:=
Out[369]=

PowerExpand@%D
x

Together combines sum of fractions, Apart breaks up a rational function as a sum of fractions.
In[370]:=

Together@1 Hx + 1L + 1 Hx + 2L + 1 Hx + 3LD
11 + 12 x + 3 x2

Out[370]=

In[371]:=

H1 + xL H2 + xL H3 + xL

Apart@%D
1

1
+

Out[371]=

1+x

1
+

2+x

3+x

51. Set
You can tell Mathematica to remember the result of a computation by assigning the result to a variable
using the Set command. An equals sign = is used for Set command. Thus
In[372]:=
Out[372]=

In[373]:=
Out[373]=

In[374]:=
Out[374]=

interestrate = 2.5
2.5
principal = 25 000.
25 000.
interest = principal * interestrate 100
625.

52. SetDelayed
The Set (=) command evaluates the right-hand side of the assignment before assignment. The SetDelayed command is denoted by := and makes a definition to a variable or function of an expression to be
evaluated only when the variable or function is used.

02.1-Commands.nb

11

The Set (=) command evaluates the right-hand side of the assignment before assignment. The SetDelayed command is denoted by := and makes a definition to a variable or function of an expression to be
evaluated only when the variable or function is used.
In[375]:=

linfcn := slope * x + intercept

In[376]:=

linfcn

Out[376]=

In[377]:=
Out[377]=

In[378]:=
Out[378]=

In[379]:=
Out[379]=

In[380]:=
Out[380]=

intercept + 3 x
slope = 2
2
linfcn
intercept + 2 x
slope = 3
3
linfcn
intercept + 3 x

53. Blank
You can define functions using Set, but the left-hand side must use a pattern with Blank, denoted by an
underscore character after a variable, to denote a dummy variable that can get any argument.
In[381]:=
Out[381]=

In[382]:=
Out[382]=

parabola@x_D = x ^ 2 + x + 1
1 + x + x2
parabola@2D
7

Often however you should use SetDelayed instead of Set for function definitions. You need to use
SetDelayed for definitions of functions that you cant evaluate until you have the value of an argument.
In[383]:=

In[384]:=
Out[384]=

tableofsquares@n_D := Table@i ^ 2, 8i, 1, n<D


tableofsquares@5D
81, 4, 9, 16, 25<

More complex patterns, definitions by cases, and recursive definitions are allowed in defining functions,
but you need to be careful not to get have infinite recursive definitions.
In[385]:=

sayifinteger@x_IntegerD := "is integer"

This only applies if x is an integer.


In[386]:=

sayifinteger@x_D := "is not integer"

This definition is used if the more specific definition doesnt apply.

12

02.1-Commands.nb

In[387]:=
Out[387]=

In[388]:=
Out[388]=

sayifinteger@2D
is integer
sayifinteger@2.1D
is not integer

54. Information
The Information command asks the Mathematica kernel what definitions have been made for a symbol.
Typing ?symbol gets information on symbol.
In[389]:=

testfcn@x_D := x ^ 2

In[390]:=

Information@testfcnD
Global`testfcn
testfcn@x_D := x2

In[391]:=

? testfcn
Global`testfcn
testfcn@x_D := x2

55. Clear
Sometimes you have assigned to a variable which you now want treated as a variable without a value.
I avoid this by using longer names for symbols I define and leaving single letter names for variables.
The Clear command removes definitions of variables and functions. If you make an assignment of a
variable that already has a definition that definition is usually replaced. The exception is if you make
definitions a function with different argument patterns. To be sure you dont have conflicting definitions
you may want to first Clear any existing definitions.
In[392]:=
Out[392]=

In[393]:=
Out[393]=

x=4
4
x^2 + x + 1
21

In[394]:=

Clear@xD

In[395]:=

x^2 + x + 1

Out[395]=

1 + x + x2

56 - 57. Rule, ReplaceAll


A rule specifies a value corresponding to a variable (or other expression possibly with patterns) without
making a global assignment. The notation typed as -> converts to an arrow. Rules are used for specifying options to various functions (see TableForm above) and used to express solutions sets (see Solve
below). You substitute in an expression according to a rule or list of rules using the function ReplaceAll
usually expressed using the notation /. between expression and rules.

02.1-Commands.nb

13

A rule specifies a value corresponding to a variable (or other expression possibly with patterns) without
making a global assignment. The notation typed as -> converts to an arrow. Rules are used for specifying options to various functions (see TableForm above) and used to express solutions sets (see Solve
below). You substitute in an expression according to a rule or list of rules using the function ReplaceAll
usually expressed using the notation /. between expression and rules.
In[396]:=
Out[396]=

x + y . 8x 2, y 3<
5

58. Equal
The single equals sign = is used for assignment. An equation is represented in Mathematica with
Equal, denoted by a double equals sign == which translates to a condensed symbol . The Equal
function evaluates to True if its arguments are identically equal and False if they are evidently not
equal, but otherwise, as in the case where there are variables to be determined, remains in the form of
an equation.
In[397]:=
Out[397]=

In[398]:=
Out[398]=

7x+5 2x-3
5 + 7 x -3 + 2 x
Simplify@%D
8+5x 0

59 - 60. Solve, Reduce


The Solve command takes an equation or list of equations and a variable or list of variables and solves
the equations for the values of variables. It gives a list of solutions, each solution a list of rules for
values of the variables. Solve makes some assumptions about parameters and finds only generic
solutions. The Reduce command reduces a system of equations giving an equivalent system solving
for the named variables.
In[399]:=
Out[399]=

In[400]:=

Out[400]=

In[401]:=

Out[401]=

In[402]:=

Solve@8x + y 3, x - y 1<, 8x, y<D


88x 2, y 1<<

Solve@8Sqrt@x + yD 5, x * y 1<, 8x, y<D


::x

::x

-b -

I25 + 3

69 M, y

I25 - 3

Solve@a * x ^ 2 + b * x + c 0, xD
b2 - 4 a c
2a

>, :x

-b +

69 M>, :x

b2 - 4 a c
2a

Reduce@a * x ^ 2 + b * x + c 0, xD
-b -

Out[402]=

b2 - 4 a c

a 0 && x
2a
Ka 0 && b 0 && x -

c
b

-b +

2
, y 25 -

25 + 3

69

>>

b2 - 4 a c
2a

O Hc 0 && b 0 && a 0L

25 + 3

69

>>

14

02.1-Commands.nb

61 - 62. NSolve, FindRoot


The Solve command works for polynomial and a variety of other types of equations that have solutions
expressable by exact formulas. Often, the equations we solve wont have formulas for their solutions,
and even if they do we may only care about a numerical solution. Equations involving symbolic parameters need to be solved using Solve, but a different method can be used to solve equations for approximate numerical solutions. The command NSolve returns a list of numerical results corresponding to
what Solve produces when possible. Instead, and more generally, the FindRoot command solves
equations or systems of equations approximately. Starting from an initial starting approximation it uses
Newtons method (or a variant). If the functions involved dont have symbolic derivatives and two
starting values are specified it uses (a variant of) the secant method. In either case, it returns a single
approximate solution as a list of rules for variables.
In[403]:=
Out[403]=

In[404]:=
Out[404]=

In[405]:=
Out[405]=

NSolve@x ^ 2 2, xD

88x - 1.41421<, 8x 1.41421<<


FindRoot@x ^ 2 2, 8x, 2<D
8x 1.41421<

FindRoot@Sin@xD + Exp@xD - Abs@x - 1D 3, 8x, 0, 2<D


8x 0.864726<

63 - 64. D, Derivative
The partial derivative of a function f with respect to a variable x is computed by D[f,x]. If f is given by an
expression, D evaluates the derivative of this expression. If f is a symbol the notation f ' is the derivative function, denoted by Derivative[1][f], which is evaluated if f is defined. The Derivative function
applies to a function not an expression returning another function, and is not usually what you want
except in the case you are taking f ' for a symbol f . Higher order and mixed partial derivatives are
expressed adding more arguments to D for additional variables.
In[406]:=
Out[406]=

D@a * x ^ 2 + b * x + c, xD
b+2ax

In[407]:=

testfunc@x_D := Sin@x ^ 4D

In[408]:=

testfunc '@xD

Out[408]=

In[409]:=
Out[409]=

In[410]:=
Out[410]=

In[411]:=
Out[411]=

4 x3 Cos@x4 D

D@testfunc@xD, xD
4 x3 Cos@x4 D

Derivative@1D@testfuncD@xD
4 x3 Cos@x4 D

Derivative@1D@SinD
Cos@1D &

02.1-Commands.nb

In[412]:=
Out[412]=

In[413]:=
Out[413]=

15

D@Sin@xD, x, xD
- Sin@xD
D@x ^ 3 * y ^ 5, x, yD
15 x2 y4

65 - 66. Integrate, NIntegrate


The Integrate command computes definite and indefinite integrals as exact formulas when possible.
Integrals not given by closed form formulas are left as Integrate expressions displayed using an intergal
sign. The NIntegrate command evaluates a numerical integral as an approximate numerical value
using numerical integration techniques. Multiple integrals are represented by additional range
specifications.
In[414]:=

Integrate@x ^ 5, xD
x6

Out[414]=

6
In[415]:=

Integrate@x ^ 5, 8x, 0, 2<D


32

Out[415]=

3
In[416]:=

Integrate@a * x ^ 2 + b * x + c, 8x, bottom, top<D


b bottom2

Out[416]=

2
In[417]:=

Out[417]=

In[418]:=

a bottom3

b top2

- bottom c + c top +

a top3
+
3

Integrate@Exp@x ^ 5D * Sin@xD * Sqrt@xD, xD

x5

x Sin@xD x

Integrate@x * y, 8x, 0, 1<, 8y, 0, x<D


1

Out[418]=

8
In[419]:=
Out[419]=

In[420]:=
Out[420]=

NIntegrate@x ^ 5, 8x, 0, 2<D

10.6667

NIntegrate@x * y, 8x, 0, 1<, 8y, 0, x<D

0.125

67 - 68. Series, Limit


The Taylor series of a function is computed by Series. Limits are computed by Limit.

16

02.1-Commands.nb

In[421]:=

Series@Sin@xD, 8x, 0, 5<D


x3

Out[421]=

x-

6
In[422]:=
Out[422]=

x5

+ O@xD6

120

Limit@Sin@xD x, x 0D
1

69. DSolve
Differential equations can be solved using DSolve.
In[423]:=

Out[423]=

DSolve@y ''@xD + y '@xD + x ^ 2 0, y@xD, xD


::y@xD - 2 x + x2 -

x3

- -x C@1D + C@2D>>

70 - 71. Sum, Total


The Sum function calculates the sum of an expression over a range of values for an index of summa-

tion, i.e., it calculates the summation notation bi=a f HiL. The Total function adds up the elements of a list.
Thus Sum is the Total of a corresponding Table, except that Sum can also compute some symbolic
sums.
In[424]:=
Out[424]=

In[425]:=

Sum@i, 8i, 1, 10<D


55

Sum@i, 8i, 1, n<D


1

Out[425]=

2
In[426]:=
Out[426]=

In[427]:=
Out[427]=

n H1 + nL

Table@i, 8i, 1, 10<D

81, 2, 3, 4, 5, 6, 7, 8, 9, 10<
Total@%D
55

72 - 74. Plot, Plot3D, ListPlot


It helps understanding to display information graphically. A graph of a function of numerical function of
a single variable is produced by the Plot command. Multiple functions can be displayed on the same
graph by making the first argument to Plot a list. Numerous options apply to graphs.

02.1-Commands.nb

In[428]:=

Plot@x ^ 2, 8x, - 1, 1<D

17

1.0

0.8

0.6
Out[428]=

0.4

0.2

-1.0
In[429]:=

-0.5

0.5

1.0

Plot@8Sin@xD, Cos@xD<, 8x, 0, 2 Pi<, PlotLegends 8"sinHxL", "cosHxL"<D


1.0

0.5

sinHxL
Out[429]=

cosHxL

-0.5

-1.0

Funtions of two variables can be display using Plot3D, giving a surface of variable height above the x-y
plane. The picture can be rotated and tilted to view the surface from different viewpoints. Two ranges
of coordinates need to specified.

18

02.1-Commands.nb

In[430]:=

Plot3D@x ^ 2 - y ^ 2, 8x, - 1, 1<, 8y, - 1, 1<D

1.0
0.5
Out[430]=

1.0

0.0
0.5

-0.5
-1.0
-1.0

0.0
-0.5
-0.5

0.0
0.5
1.0

-1.0

Data in the form of a list of ordered pairs can be plotted using ListPlot. If the data in sorted in order of
increasing x value, then the option Joined->True will join the points rather than just draw points.
In[431]:=
Out[431]=

In[432]:=

data = 881, 2<, 82, 3<, 83, 3<, 84, 1<, 85, 2<<
881, 2<, 82, 3<, 83, 3<, 84, 1<, 85, 2<<

ListPlot@data, PlotStyle 8PointSize@0.02D<D


3.0

2.5

Out[432]= 2.0

1.5

02.1-Commands.nb

In[433]:=

19

ListPlot@data, Joined TrueD


3.0

2.5

Out[433]= 2.0

1.5

75 - 85. Mean, Variance, StandardDeviation, PDF, CDF, NormalDistribution,


UniformDistribution, ExponentialDistribution, GumbelDistribution,
BinomialDistribution, PoissonDistribution
Mathematica has numerous statistical functions. Mean, Variance, and StandardDeviation compute
these statistical measures for lists of numbers but also apply to named stistical distributions. The PDF
and CDF functions compute the probability density function and cummulative distribution function for
named distributions. Names are defined for a wide variety of parametrically defined distributions. The
normal distribution is the standard bell curve with a specified mean and standard deviation.
In[434]:=
Out[434]=

In[435]:=
Out[435]=

In[436]:=
Out[436]=

In[437]:=
Out[437]=

In[438]:=

dist1 = NormalDistribution@mu, sigmaD


NormalDistribution@mu, sigmaD
Mean@dist1D
mu
Variance@dist1D
sigma2
StandardDeviation@dist1D
sigma
PDF@NormalDistribution@10, 2D, xD
- 8 H-10+xL
1

Out[438]=

In[439]:=

CDF@NormalDistribution@10, 2D, xD
10 - x

1
ErfcB

Out[439]=

20

02.1-Commands.nb

In[440]:=

Plot@PDF@NormalDistribution@10, 2D, xD, 8x, 0, 20<D


0.20

0.15

Out[440]= 0.10

0.05

5
In[441]:=

10

15

20

Plot@CDF@NormalDistribution@10, 2D, xD, 8x, 0, 20<D


1.0

0.8

0.6
Out[441]=

0.4

0.2

10

15

20

Other continuous distributions are UniformDistribution, ExponentialDistribution, and GumbelDistribution


(a distribution youve probably never heard of) among many others.
In[442]:=

Plot@PDF@UniformDistribution@83, 7<D, xD, 8x, 0, 10<D


0.25

0.20

0.15
Out[442]=

0.10

0.05

10

02.1-Commands.nb

In[443]:=

Plot@PDF@ExponentialDistribution@0.5D, xD, 8x, 0, 10<D


0.5

0.4

0.3
Out[443]=

0.2

0.1

2
In[444]:=

10

Plot@PDF@GumbelDistribution@6, 1D, xD, 8x, 0, 10<D


0.35
0.30
0.25
0.20

Out[444]=

0.15
0.10
0.05

10

Discrete distributions include BinomialDistribution and PoissonDistribution.


In[445]:=

ListPlot@Table@8x, PDF@BinomialDistribution@10, 0.3D, xD<, 8x, 0, 10<D,


PlotStyle 8PointSize@0.02D<D
0.25

0.20

0.15
Out[445]=

0.10

0.05

10

21

22

02.1-Commands.nb

In[446]:=

ListPlot@Table@8x, PDF@PoissonDistribution@4D, xD<, 8x, 0, 10<D,


PlotStyle 8PointSize@0.02D<D
0.15

Out[446]=

0.10

0.05

10

86 - 87. Function, Slot


You can also define functions without making assignments. The expression Function[x,f] is the function
of a variable x whose value is computed by the formula f in terms of this variable. The variable x is
local to this expression. This expression represents a function which can be then be applied to any
argument.
In[447]:=
Out[447]=

In[448]:=
Out[448]=

Function@x, x ^ 2 + x + 1D
FunctionAx, x2 + x + 1E
%@2D
7

This would ordinarily not be any simpler than writing the formula f and substituting with a rule for the
variable x, but it does protect the variable x when x has a value, where the substitution method would
fail.
In[449]:=
Out[449]=

In[450]:=
Out[450]=

In[451]:=
Out[451]=

In[452]:=

x=2
2
Function@x, x ^ 2 + x + 1D
FunctionAx, x2 + x + 1E
%@3D
13
Clear@xD

There is a particular useful shorthand notation for this form of function specification. The symbol #,
shorthand for the Slot function, is used for a generic argument and an ampersand & after an expression
in # makes this a function of the #. Thus an anonymous function is defined by

02.1-Commands.nb

In[453]:=

^2 + + 1 &

Out[453]=

12 + 1 + 1 &

In[454]:=

FullForm@%D

23

Out[454]//FullForm=

Function@Plus@Power@Slot@1D, 2D, Slot@1D, 1DD

In application, we have
In[455]:=
Out[455]=

^ 2 + + 1 &@3D
13

Anonymous functions of more than one variable are represented with generic arguments #1, #2,...
In[456]:=
Out[456]=

1 ^ 2 + 2 ^ 2 &@3, 4D
25

88 - 90. Map, MapThread, Thread


What makes anonymous functions so useful is their use in Map. The Map function takes a function as
first argument and a list as second argument and applies the function to each element of the list return
the list of all results. For the first argument, it is often convenient to use an anonymous function.
In[457]:=
Out[457]=

In[458]:=
Out[458]=

data1 = Table@i, 8i, 1, 10<D

81, 2, 3, 4, 5, 6, 7, 8, 9, 10<
Map@ ^ 2 &, data1D

81, 4, 9, 16, 25, 36, 49, 64, 81, 100<

The MapThread function takes a function of several variables and a list of lists, each of the same
length, and applies the function to first elements from the lists, then to the second elements, etc.,
returning a list of all of the results, essentially from applying the function to arguments taken from each
column of the matrix of values.
In[459]:=
Out[459]=

MapThread@1 ^ 2 + 2 ^ 2 &, 883, 6, 9<, 84, 8, 12<<D

825, 100, 225<

The Thread function does something similar to Map and MapThread. If (the evaluated form of) an
expression is a function applied to one or several lists, then Thread applied to this expression gives the
list of applying the function instead to the elements of the list arguments. The trick is that this only
works when the function applied to lists wouldnt already evaluate anyway. Thus because f is not
defined we can thread.
In[460]:=
Out[460]=

In[461]:=
Out[461]=

f@data1D
f@81, 2, 3, 4, 5, 6, 7, 8, 9, 10<D
Thread@f@data1DD

8f@1D, f@2D, f@3D, f@4D, f@5D, f@6D, f@7D, f@8D, f@9D, f@10D<

24

02.1-Commands.nb

In[462]:=
Out[462]=

In[463]:=
Out[463]=

f@83, 6, 9<, 84, 8, 12<D


f@83, 6, 9<, 84, 8, 12<D

Thread@f@83, 6, 9<, 84, 8, 12<DD


8f@3, 4D, f@6, 8D, f@9, 12D<

An example where this is useful is when you have a list of variables and a list of values and you want
the list of rules assigning successive variables to successive values.
In[464]:=
Out[464]=

Thread@8x, y< 83, 4<D


8x 3, y 4<

The real surprise is that many functions are designed to automatically thread over lists. So we have for
instance
In[465]:=
Out[465]=

In[466]:=
Out[466]=

81, 2, 3< + 82, 4, 6<


83, 6, 9<

10 * 81, 2, 3<
810, 20, 30<

giving vector addition and scalar multiplication as instances of the threading mechanism. We also have
the less intuitive
In[467]:=
Out[467]=

In[468]:=
Out[468]=

81, 2, 3< * 82, 4, 6<


82, 8, 18<

10 + 81, 2, 3<
811, 12, 13<

91 - 94. Module, If, While, For


If you are going to write programs of any complexity you will want to encapsulate your computations
and protect your local variables using Module. The Module command takes two arguments, a list of
local variables, and an expression to evaluate treating these variables as local to the expression. A
compound expression is a sequence of expression separated by semicolons (;) which is evaluated by
evaluating the expressions in sequence and having value the value of the last expression, so the
second argument of Module can do any computation.
In[469]:=

testit@x_D := Module@8y, z<, y = x ^ 2; z = x ^ 3; y + zD

In[470]:=

testit@2D

Out[470]=

12

The If function takes two or three (or even four arguments), evaluating the first argument, and if the
value is True, evaluating and returning the second (then) argument, while if the result from the first
argument is False, evaluating and returning the third (else) argument, (and if neither True nor False
evaluating and returning a fourth argument if present).
In[471]:=

testit2@x_D := If@x > 1, "Yes", "No"D

02.1-Commands.nb

In[472]:=
Out[472]=

In[473]:=
Out[473]=

In[474]:=
Out[474]=

25

testit2@10D
Yes
testit2@0D
No
testit2@yD
If@y > 1, Yes, NoD

The While command gives a structured loop, first argument a test whether to continue and the second
argument repeatedly evaluated as long as the test is true. The For implements a loop with some
initialization (usually of an index variable), some test applied to determine whether to stop, an increment
expression to evaluate at the end of each evaluation of a fourth expression.
In[475]:=
Out[475]=

In[476]:=
Out[476]=

Module@8i, total<, i = 1; total = 0; While@i 10, total = total + i; i = i + 1D; totalD


55
Module@8i, total<, total = 0; For@i = 0, i 10, i = i + 1, total = total + iD; totalD
55

There are a number of other procedural programming functions available. You should probably stick to
interactively evaluating expressions, defining intermediate results and simple functions, since it is much
easier to experiment, change, and understand. You should not write elaborate programs that will be
difficult to debug and understand.

95 - 98. Dot, Det, Inverse, Transpose


A matrix are represented by a list of its rows. A vector is simply a list, and row and column vectors are
not distinguished. The dot product of vectors, and the product of a matrix with a vector or a matrix, is
given by the Dot function which has short-hand notation simple a period (as long as it isnt next to a
number).
In[477]:=
Out[477]=

In[478]:=
Out[478]=

In[479]:=

82, 5<.81, 3<


17

mat1 = 881, 2<, 83, 4<<


881, 2<, 83, 4<<

MatrixForm@mat1D

Out[479]//MatrixForm=

In[480]:=
Out[480]=

In[481]:=
Out[481]=

1 2
O
3 4

mat1.81, 1<
83, 7<

mat1.mat1

887, 10<, 815, 22<<

The determinant of a square matrix is computed by Det. The inverse of an invertible square matrix is
given by Inverse. The transpose of a matrix is given by Transpose.

26

02.1-Commands.nb

The determinant of a square matrix is computed by Det. The inverse of an invertible square matrix is
given by Inverse. The transpose of a matrix is given by Transpose.
In[482]:=
Out[482]=

In[483]:=

Det@mat1D
-2
MatrixForm@Inverse@mat1DD

Out[483]//MatrixForm=

In[484]:=

-2

3
2

-2

MatrixForm@Transpose@mat1DD

Out[484]//MatrixForm=

1 3
O
2 4

99 - 100. Sort, Select


The Sort function sorts the elements of a list in a canonical order for Mathematica, for numerical values
in increasing order. The Select function takes a list and a function, applies the function to each element
of the list, and creates a list of the elements for which the function evaluates to True.
In[485]:=
Out[485]=

In[486]:=
Out[486]=

Sort@Table@N@Sin@xDD, 8x, 0, 10<DD

8- 0.958924, - 0.756802, - 0.544021, - 0.279415, 0.,


0.14112, 0.412118, 0.656987, 0.841471, 0.909297, 0.989358<
Select@%, > 0 &D

80.14112, 0.412118, 0.656987, 0.841471, 0.909297, 0.989358<

101. FinancialData
Mathematica has a number of functions that link into external databases. For our purposes the most
interesting of these is the FinancialData function. It can download current or historical data on stock
prices and indices, exchange rates, etc.
In[487]:=

entities = FinancialData@D

A very large output was generated. Here is a sample of it:

Out[487]=

8^A1BSC, ^A1CYC, ^A1DOW, ^A1ENE, ^A1FIN, ^A1HCR, ^A1IDU, ^A1NCY, ^A1SGI, ^A1SGITR,
^A1TEC, ^A1TLS, ^A1UTI, 145 477, Z:XBNCG, Z:XBNCH, Z:XBNCI, Z:XBPHF,
Z:XBPHG, Z:XBPHH, Z:XBPHI, Z:XBREF, Z:XBREG, Z:XBREH, Z:XBREI, Z:ZZ6P, Z:ZZ6Q<

Show Less Show More Show Full Output Set Size Limit...

In[488]:=
Out[488]=

Length@entitiesD
145 503

02.1-Commands.nb

In[489]:=
Out[489]=

In[490]:=
Out[490]=

In[491]:=
Out[491]=

In[492]:=
Out[492]=

FinancialData@"^SPX"D
1831.37
FinancialData@"^SPX", "StandardName"D
SAndP500
FinancialData@"AAPL", "StandardName"D
AppleInc
apple2012 = FinancialData@"AAPL", "Price", 882012, 1, 1<, 82012, 12, 31<<D

8882012, 1, 3<, 397.62<, 882012, 1, 4<, 399.76<,


882012, 1, 5<, 404.2<, 882012, 1, 6<, 408.42<, 882012, 1, 9<, 407.77<,
882012, 1, 10<, 409.23<, 882012, 1, 11<, 408.57<,
882012, 1, 12<, 407.45<, 882012, 1, 13<, 405.92<, 882012, 1, 17<, 410.65<,
882012, 1, 18<, 414.91<, 882012, 1, 19<, 413.59<, 882012, 1, 20<, 406.39<,
882012, 1, 23<, 413.27<, 882012, 1, 24<, 406.5<, 882012, 1, 25<, 431.88<,
882012, 1, 26<, 429.92<, 882012, 1, 27<, 432.48<, 882012, 1, 30<, 438.02<,
882012, 1, 31<, 441.37<, 882012, 2, 1<, 441.09<, 882012, 2, 2<, 440.06<,
882012, 2, 3<, 444.47<, 882012, 2, 6<, 448.62<, 882012, 2, 7<, 453.32<,
882012, 2, 8<, 460.91<, 882012, 2, 9<, 476.85<, 882012, 2, 10<, 477.09<,
882012, 2, 13<, 485.97<, 882012, 2, 14<, 492.6<, 882012, 2, 15<, 481.2<,
882012, 2, 16<, 485.59<, 882012, 2, 17<, 485.5<, 882012, 2, 21<, 497.81<,
882012, 2, 22<, 496.06<, 882012, 2, 23<, 499.3<, 882012, 2, 24<, 505.12<,
882012, 2, 27<, 508.36<, 882012, 2, 28<, 517.69<, 882012, 2, 29<, 524.49<,
882012, 3, 1<, 526.45<, 882012, 3, 2<, 527.14<, 882012, 3, 5<, 515.52<,
882012, 3, 6<, 512.71<, 882012, 3, 7<, 513.13<, 882012, 3, 8<, 524.05<,
882012, 3, 9<, 527.13<, 882012, 3, 12<, 533.73<, 882012, 3, 13<, 549.3<,
882012, 3, 14<, 570.07<, 882012, 3, 15<, 566.18<, 882012, 3, 16<, 566.19<,
882012, 3, 19<, 581.21<, 882012, 3, 20<, 585.91<, 882012, 3, 21<, 582.56<,
882012, 3, 22<, 579.51<, 882012, 3, 23<, 576.33<, 882012, 3, 26<, 586.89<,
882012, 3, 27<, 594.15<, 882012, 3, 28<, 597.18<, 882012, 3, 29<, 589.68<,
882012, 3, 30<, 579.71<, 882012, 4, 2<, 598.16<, 882012, 4, 3<, 608.49<,
882012, 4, 4<, 603.65<, 882012, 4, 5<, 612.71<, 882012, 4, 9<, 615.18<,
882012, 4, 10<, 607.64<, 882012, 4, 11<, 605.48<, 882012, 4, 12<, 602.16<,
882012, 4, 13<, 585.2<, 882012, 4, 16<, 560.93<, 882012, 4, 17<, 589.52<,
882012, 4, 18<, 588.21<, 882012, 4, 19<, 568.<, 882012, 4, 20<, 554.02<,
882012, 4, 23<, 552.78<, 882012, 4, 24<, 541.74<, 882012, 4, 25<, 589.81<,
882012, 4, 26<, 587.59<, 882012, 4, 27<, 583.05<, 882012, 4, 30<, 564.65<,
882012, 5, 1<, 562.87<, 882012, 5, 2<, 566.59<, 882012, 5, 3<, 562.57<,
882012, 5, 4<, 546.54<, 882012, 5, 7<, 550.63<, 882012, 5, 8<, 549.38<,
882012, 5, 9<, 550.34<, 882012, 5, 10<, 551.64<, 882012, 5, 11<, 547.96<,
882012, 5, 14<, 539.75<, 882012, 5, 15<, 534.86<, 882012, 5, 16<, 528.01<,
882012, 5, 17<, 512.58<, 882012, 5, 18<, 512.83<, 882012, 5, 21<, 542.71<,
882012, 5, 22<, 538.54<, 882012, 5, 23<, 551.68<, 882012, 5, 24<, 546.61<,
882012, 5, 25<, 543.68<, 882012, 5, 29<, 553.33<, 882012, 5, 30<, 560.<,
882012, 5, 31<, 558.61<, 882012, 6, 1<, 542.43<, 882012, 6, 4<, 545.62<,
882012, 6, 5<, 544.2<, 882012, 6, 6<, 552.55<, 882012, 6, 7<, 552.8<,
882012, 6, 8<, 561.12<, 882012, 6, 11<, 552.27<, 882012, 6, 12<, 557.09<,
882012, 6, 13<, 553.23<, 882012, 6, 14<, 552.62<, 882012, 6, 15<, 555.13<,
882012, 6, 18<, 566.4<, 882012, 6, 19<, 567.97<, 882012, 6, 20<, 566.36<,
,
,
,

27

28

02.1-Commands.nb

In[493]:=
Out[493]=

882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,
882012,

6, 21<, 558.55<, 882012, 6, 22<, 562.84<, 882012, 6, 25<, 551.88<,


6, 26<, 553.1<, 882012, 6, 27<, 555.49<, 882012, 6, 28<, 550.22<,
6, 29<, 564.67<, 882012, 7, 2<, 572.91<, 882012, 7, 3<, 579.57<,
7, 5<, 589.76<, 882012, 7, 6<, 585.83<, 882012, 7, 9<, 593.58<,
7, 10<, 588.08<, 882012, 7, 11<, 584.43<, 882012, 7, 12<, 579.08<,
7, 13<, 584.95<, 882012, 7, 16<, 586.83<, 882012, 7, 17<, 586.86<,
7, 18<, 586.2<, 882012, 7, 19<, 593.99<, 882012, 7, 20<, 584.3<,
7, 23<, 583.85<, 882012, 7, 24<, 581.03<, 882012, 7, 25<, 555.94<,
7, 26<, 555.86<, 882012, 7, 27<, 565.8<, 882012, 7, 30<, 575.34<,
7, 31<, 590.55<, 882012, 8, 1<, 586.73<, 882012, 8, 2<, 587.68<,
8, 3<, 595.33<, 882012, 8, 6<, 601.95<, 882012, 8, 7<, 600.36<,
8, 8<, 599.35<, 882012, 8, 9<, 602.77<, 882012, 8, 10<, 603.71<,
8, 13<, 611.77<, 882012, 8, 14<, 613.41<, 882012, 8, 15<, 612.57<,
8, 16<, 617.92<, 882012, 8, 17<, 629.35<, 882012, 8, 20<, 645.9<,
8, 21<, 637.07<, 882012, 8, 22<, 649.51<, 882012, 8, 23<, 643.45<,
8, 24<, 644.03<, 882012, 8, 27<, 656.13<, 882012, 8, 28<, 655.27<,
8, 29<, 653.98<, 882012, 8, 30<, 644.66<, 882012, 8, 31<, 645.99<,
9, 4<, 655.44<, 882012, 9, 5<, 650.83<, 882012, 9, 6<, 656.7<,
9, 7<, 660.75<, 882012, 9, 10<, 643.56<, 882012, 9, 11<, 641.47<,
9, 12<, 650.41<, 882012, 9, 13<, 663.21<, 882012, 9, 14<, 671.27<,
9, 17<, 679.53<, 882012, 9, 18<, 681.6<, 882012, 9, 19<, 681.78<,
9, 20<, 678.48<, 882012, 9, 21<, 679.83<, 882012, 9, 24<, 670.8<,
9, 25<, 654.05<, 882012, 9, 26<, 645.93<, 882012, 9, 27<, 661.6<,
9, 28<, 647.79<, 882012, 10, 1<, 640.31<, 882012, 10, 2<, 642.17<,
10, 3<, 652.02<, 882012, 10, 4<, 647.5<, 882012, 10, 5<, 633.7<,
10, 8<, 619.7<, 882012, 10, 9<, 617.45<, 882012, 10, 10<, 622.36<,
10, 11<, 609.92<, 882012, 10, 12<, 611.49<, 882012, 10, 15<, 616.39<,
10, 16<, 630.98<, 882012, 10, 17<, 625.95<, 882012, 10, 18<, 614.33<,
10, 19<, 592.19<, 882012, 10, 22<, 615.68<, 882012, 10, 23<, 595.61<,
10, 24<, 598.98<, 882012, 10, 25<, 591.9<, 882012, 10, 26<, 586.52<,
10, 31<, 578.09<, 882012, 11, 1<, 579.28<, 882012, 11, 2<, 560.11<,
11, 5<, 567.7<, 882012, 11, 6<, 565.98<, 882012, 11, 7<, 544.33<,
11, 8<, 524.57<, 882012, 11, 9<, 533.65<, 882012, 11, 12<, 529.53<,
11, 13<, 529.6<, 882012, 11, 14<, 523.72<, 882012, 11, 15<, 512.74<,
11, 16<, 514.75<, 882012, 11, 19<, 551.87<, 882012, 11, 20<, 547.16<,
11, 21<, 547.94<, 882012, 11, 23<, 557.5<, 882012, 11, 26<, 575.08<,
11, 27<, 570.45<, 882012, 11, 28<, 568.65<, 882012, 11, 29<, 574.92<,
11, 30<, 570.94<, 882012, 12, 3<, 571.83<, 882012, 12, 4<, 561.74<,
12, 5<, 525.59<, 882012, 12, 6<, 533.83<, 882012, 12, 7<, 520.18<,
12, 10<, 516.84<, 882012, 12, 11<, 528.12<, 882012, 12, 12<, 525.79<,
12, 13<, 516.71<, 882012, 12, 14<, 497.3<, 882012, 12, 17<, 506.12<,
12, 18<, 520.82<, 882012, 12, 19<, 513.41<, 882012, 12, 20<, 508.94<,
12, 21<, 506.6<, 882012, 12, 24<, 507.42<, 882012, 12, 26<, 500.43<,
12, 27<, 502.44<, 882012, 12, 28<, 497.1<, 882012, 12, 31<, 519.13<<

apple2013 = FinancialData@"AAPL", "Price", 882013, 1, 1<, 82013, 12, 31<<D

8882013, 1, 2<, 535.58<, 882013, 1, 3<, 528.82<, 882013, 1, 4<, 514.09<,


882013, 1, 7<, 511.06<, 882013, 1, 8<, 512.44<, 882013, 1, 9<, 504.43<,
882013, 1, 10<, 510.68<, 882013, 1, 11<, 507.55<, 882013, 1, 14<, 489.45<,
882013, 1, 15<, 474.01<, 882013, 1, 16<, 493.69<, 882013, 1, 17<, 490.36<,
882013, 1, 18<, 487.75<, 882013, 1, 22<, 492.4<, 882013, 1, 23<, 501.41<,
,
,
,

Out[493]=

02.1-Commands.nb

882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,

1,
1,
2,
2,
2,
2,
2,
2,
2,
3,
3,
3,
3,
3,
3,
4,
4,
4,
4,
4,
4,
4,
4,
5,
5,
5,
5,
5,
5,
5,
6,
6,
6,
6,
6,
6,
6,
7,
7,
7,
7,
7,
7,
7,
8,
8,
8,
8,
8,
8,
8,
9,

24<, 439.46<, 882013, 1, 25<, 429.1<, 882013, 1, 28<, 438.81<,


29<, 447.04<, 882013, 1, 30<, 445.64<, 882013, 1, 31<, 444.33<,
1<, 442.5<, 882013, 2, 4<, 431.48<, 882013, 2, 5<, 446.62<,
6<, 446.14<, 882013, 2, 7<, 459.41<, 882013, 2, 8<, 466.04<,
11<, 470.9<, 882013, 2, 12<, 459.09<, 882013, 2, 13<, 458.22<,
14<, 457.81<, 882013, 2, 15<, 451.5<, 882013, 2, 19<, 451.33<,
20<, 440.4<, 882013, 2, 21<, 437.66<, 882013, 2, 22<, 442.33<,
25<, 434.47<, 882013, 2, 26<, 440.52<, 882013, 2, 27<, 436.2<,
28<, 433.09<, 882013, 3, 1<, 422.37<, 882013, 3, 4<, 412.14<,
5<, 423.03<, 882013, 3, 6<, 417.65<, 882013, 3, 7<, 422.48<,
8<, 423.59<, 882013, 3, 11<, 429.63<, 882013, 3, 12<, 420.37<,
13<, 420.29<, 882013, 3, 14<, 424.36<, 882013, 3, 15<, 435.31<,
18<, 447.14<, 882013, 3, 19<, 445.94<, 882013, 3, 20<, 443.57<,
21<, 444.21<, 882013, 3, 22<, 453.22<, 882013, 3, 25<, 454.86<,
26<, 452.46<, 882013, 3, 27<, 443.57<, 882013, 3, 28<, 434.33<,
1<, 420.84<, 882013, 4, 2<, 421.7<, 882013, 4, 3<, 423.86<,
4<, 419.67<, 882013, 4, 5<, 415.24<, 882013, 4, 8<, 418.19<,
9<, 418.94<, 882013, 4, 10<, 427.49<, 882013, 4, 11<, 426.16<,
12<, 421.71<, 882013, 4, 15<, 411.95<, 882013, 4, 16<, 418.22<,
17<, 395.22<, 882013, 4, 18<, 384.67<, 882013, 4, 19<, 383.18<,
22<, 391.17<, 882013, 4, 23<, 398.49<, 882013, 4, 24<, 397.83<,
25<, 400.69<, 882013, 4, 26<, 409.35<, 882013, 4, 29<, 422.02<,
30<, 434.45<, 882013, 5, 1<, 431.02<, 882013, 5, 2<, 437.14<,
3<, 441.51<, 882013, 5, 6<, 452.04<, 882013, 5, 7<, 450.03<,
8<, 455.11<, 882013, 5, 9<, 451.14<, 882013, 5, 10<, 447.39<,
13<, 449.13<, 882013, 5, 14<, 438.39<, 882013, 5, 15<, 423.56<,
16<, 429.22<, 882013, 5, 17<, 427.92<, 882013, 5, 20<, 437.47<,
21<, 434.24<, 882013, 5, 22<, 435.91<, 882013, 5, 23<, 436.69<,
24<, 439.66<, 882013, 5, 28<, 436.<, 882013, 5, 29<, 439.47<,
30<, 446.01<, 882013, 5, 31<, 444.19<, 882013, 6, 3<, 445.16<,
4<, 443.77<, 882013, 6, 5<, 439.62<, 882013, 6, 6<, 433.06<,
7<, 436.36<, 882013, 6, 10<, 433.48<, 882013, 6, 11<, 432.21<,
12<, 426.86<, 882013, 6, 13<, 430.59<, 882013, 6, 14<, 424.75<,
17<, 426.68<, 882013, 6, 18<, 426.45<, 882013, 6, 19<, 417.79<,
20<, 411.7<, 882013, 6, 21<, 408.4<, 882013, 6, 24<, 397.58<,
25<, 397.67<, 882013, 6, 26<, 393.16<, 882013, 6, 27<, 388.93<,
28<, 391.64<, 882013, 7, 1<, 404.18<, 882013, 7, 2<, 413.33<,
3<, 415.61<, 882013, 7, 5<, 412.27<, 882013, 7, 8<, 409.93<,
9<, 417.14<, 882013, 7, 10<, 415.54<, 882013, 7, 11<, 422.02<,
12<, 421.25<, 882013, 7, 15<, 422.17<, 882013, 7, 16<, 424.9<,
17<, 425.01<, 882013, 7, 18<, 426.44<, 882013, 7, 19<, 419.71<,
22<, 421.06<, 882013, 7, 23<, 413.83<, 882013, 7, 24<, 435.08<,
25<, 433.1<, 882013, 7, 26<, 435.55<, 882013, 7, 29<, 442.27<,
30<, 447.73<, 882013, 7, 31<, 446.95<, 882013, 8, 1<, 451.05<,
2<, 456.84<, 882013, 8, 5<, 463.66<, 882013, 8, 6<, 459.52<,
7<, 459.25<, 882013, 8, 8<, 458.33<, 882013, 8, 9<, 451.81<,
12<, 464.65<, 882013, 8, 13<, 486.73<, 882013, 8, 14<, 495.61<,
15<, 495.02<, 882013, 8, 16<, 499.41<, 882013, 8, 19<, 504.79<,
20<, 498.16<, 882013, 8, 21<, 499.44<, 882013, 8, 22<, 500.04<,
23<, 498.11<, 882013, 8, 26<, 500.05<, 882013, 8, 27<, 485.75<,
28<, 488.05<, 882013, 8, 29<, 488.85<, 882013, 8, 30<, 484.39<,
3<, 485.74<, 882013, 9, 4<, 495.8<, 882013, 9, 5<, 492.4<,
,
,
,

29

30

02.1-Commands.nb

In[494]:=

882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,
882013,

9, 6<, 495.33<, 882013, 9, 9<, 503.23<, 882013, 9, 10<, 491.77<,


9, 11<, 465.<, 882013, 9, 12<, 469.95<, 882013, 9, 13<, 462.2<,
9, 16<, 447.51<, 882013, 9, 17<, 452.68<, 882013, 9, 18<, 461.98<,
9, 19<, 469.56<, 882013, 9, 20<, 464.7<, 882013, 9, 23<, 487.79<,
9, 24<, 486.26<, 882013, 9, 25<, 478.73<, 882013, 9, 26<, 483.4<,
9, 27<, 479.95<, 882013, 9, 30<, 473.98<, 882013, 10, 1<, 485.13<,
10, 2<, 486.72<, 882013, 10, 3<, 480.6<, 882013, 10, 4<, 480.23<,
10, 7<, 484.92<, 882013, 10, 8<, 478.15<, 882013, 10, 9<, 483.77<,
10, 10<, 486.8<, 882013, 10, 11<, 489.95<, 882013, 10, 14<, 493.16<,
10, 15<, 495.79<, 882013, 10, 16<, 498.2<, 882013, 10, 17<, 501.57<,
10, 18<, 505.94<, 882013, 10, 21<, 518.33<, 882013, 10, 22<, 516.85<,
10, 23<, 521.91<, 882013, 10, 24<, 528.82<, 882013, 10, 25<, 522.91<,
10, 28<, 526.8<, 882013, 10, 29<, 513.68<, 882013, 10, 30<, 521.85<,
10, 31<, 519.67<, 882013, 11, 1<, 517.01<, 882013, 11, 4<, 523.69<,
11, 5<, 522.4<, 882013, 11, 6<, 520.92<, 882013, 11, 7<, 512.49<,
11, 8<, 520.56<, 882013, 11, 11<, 519.05<, 882013, 11, 12<, 520.01<,
11, 13<, 520.63<, 882013, 11, 14<, 528.16<, 882013, 11, 15<, 524.99<,
11, 18<, 518.63<, 882013, 11, 19<, 519.55<, 882013, 11, 20<, 515.<,
11, 21<, 521.14<, 882013, 11, 22<, 519.8<, 882013, 11, 25<, 523.74<,
11, 26<, 533.4<, 882013, 11, 27<, 545.96<, 882013, 11, 29<, 556.07<,
12, 2<, 551.23<, 882013, 12, 3<, 566.32<, 882013, 12, 4<, 565.<,
12, 5<, 567.9<, 882013, 12, 6<, 560.02<, 882013, 12, 9<, 566.43<,
12, 10<, 565.55<, 882013, 12, 11<, 561.36<, 882013, 12, 12<, 560.54<,
12, 13<, 554.43<, 882013, 12, 16<, 557.5<, 882013, 12, 17<, 554.99<,
12, 18<, 550.77<, 882013, 12, 19<, 544.46<, 882013, 12, 20<, 549.02<,
12, 23<, 570.09<, 882013, 12, 24<, 567.67<, 882013, 12, 26<, 563.9<,
12, 27<, 560.09<, 882013, 12, 30<, 554.52<, 882013, 12, 31<, 561.02<<

DateListPlot@apple2012D

650

600

Out[494]=

550

500

450

400
Jan

Apr

Jul

Oct

Jan

02.1-Commands.nb

In[495]:=

DateListPlot@apple2013D

550

500
Out[495]=

450

400

Jan

In[496]:=

Apr

Jul

Oct

Jan

DateListPlot@Join@apple2012, apple2013DD

650

600

550
Out[496]=

500

450

400
2012

2013

2014

31

Das könnte Ihnen auch gefallen