Sie sind auf Seite 1von 6

1+2

Linear Algebra

M = 881, 2, 3<, 80, 2, - 1<, 82, 3, 4<<


881, 2, 3<, 80, 2, - 1<, 82, 3, 4<<

M •• MatrixForm
1 2 3
0 2 -1
2 3 4

Inverse@MD

::- >, : , , - >, : , - , - >>


11 1 8 2 2 1 4 1 2
,- ,
5 5 5 5 5 5 5 5 5

% •• MatrixForm
11 1 8
- 5
-5 5
2 2 1
5 5
-5
4 1 2
5
-5 -5

Det@MD
-5

Eigenvalues@MD •• N
83.68262 + 0.358259 ä, 3.68262 - 0.358259 ä, - 0.36523<

Eigenvectors@MD •• N
880.694116 - 0.0024487 ä, - 0.568539 + 0.121052 ä, 1.<,
80.694116 + 0.0024487 ä, - 0.568539 - 0.121052 ä, 1.<, 8- 2.8168, 0.422792, 1.<<

Solve@M.8x1, x2, x3< Š 8- 1, 2, 3<, 8x1, x2, x3<D

::x1 ® >>
33 1 12
, x2 ® - , x3 ® -
5 5 5

IdentityMatrix@3D
881, 0, 0<, 80, 1, 0<, 80, 0, 1<<

% •• MatrixForm
1 0 0
0 1 0
0 0 1
2 CHE 560 - 1.nb

M.M
887, 15, 13<, 8- 2, 1, - 6<, 810, 22, 19<<

M^2
881, 4, 9<, 80, 4, 1<, 84, 9, 16<<

Transpose@MD
881, 0, 2<, 82, 2, 3<, 83, - 1, 4<<

% •• MatrixForm
1 0 2
2 2 3
3 -1 4

Tr@MD
7

M+M
882, 4, 6<, 80, 4, - 2<, 84, 6, 8<<

2M
882, 4, 6<, 80, 4, - 2<, 84, 6, 8<<

2´3
6

Solving simple equations

FindRoot@Exp@- xD Š Cos@xD, 8x, 1.2<D


8x ® 1.2927<

Solve@x ^ 3 + x - 1 Š 0, xD

J 2 I9 + 93 MN
1•3 1 1•3

::x ® - >,
2
+
3 I9 + 93 M 32•3

I1 + ä 3 M J 2 I9 + 93 MN
1 1•3

:x ® - >,
1-ä 3
+
32•3 22•3 I3 I9 + 93 MM
2´ 1•3

I1 - ä 3 M J 2 I9 + 93 MN
1 1•3

:x ® - >>
1+ä 3
+
2 ´ 32•3 22•3 I3 I9 + 93 MM
1•3

% •• N
88x ® 0.682328<, 8x ® - 0.341164 - 1.16154 ä<, 8x ® - 0.341164 + 1.16154 ä<<
CHE 560 - 1.nb 3

Solve@a x ^ 2 + b x + c Š 0, xD

::x ® >, :x ® >>


-b - b2 - 4 a c -b + b2 - 4 a c
2a 2a

plotting 1-d and 2-d functions

Plot@Tanh@xD, 8x, 0, 5<, PlotRange ® 80, 1<, PlotStyle ® ThickD


1.0

0.8

0.6

0.4

0.2

0 1 2 3 4 5

Plot3D@Exp@- x yD, 8x, 0, 2<, 8y, 0, 2<D

1.0

2.0
0.5
1.5

0.0
0.0 1.0

0.5

1.0 0.5

1.5
0.0
2.0

Computing derivatives and defining functions

f@x_D := Sqrt@xD

f '@xD
1

2 x
4 CHE 560 - 1.nb

f ''@xD
1
-
4 x3•2

f@1D
1

evaluation of an integral

Integrate@f@xD, 8x, 0, 2<D

4 2
3

NIntegrate@1 • Sin@xD ^ 2, 8x, 1, 3<D


7.65735

Integrate@x ^ 2, xD
x3
3

solving differential equations and plotting the solution

sol = NDSolve@8x '@tD Š - 2 x@tD, x@0D Š 1<, 8x@tD<, 8t, 0, 10<D


88x@tD ® InterpolatingFunction@880., 10.<<, <>D@tD<<

Plot@x@tD •. sol, 8t, 0, 10<, PlotRange ® All, PlotStyle ® ThickD


1.0

0.8

0.6

0.4

0.2

2 4 6 8 10

x@tD •. sol •. t ® 1
80.135335<

First@%D
0.135335

Logic and boolean algebra


CHE 560 - 1.nb 5

Logic and boolean algebra

1Š 2
False

x = 1.3
1.3

If@x Š 2, 1, 3D
3

While and For doing loops

i = 0;

While@i < 10, 8Print@iD, i ++<D


0

For@i = 0, i < 10, 8Print@iD, i ++<D


0

9
6 CHE 560 - 1.nb

Sums and Tables

Sum@1 • i ^ 2, 8i, 1, Infinity<D


p2
6

tbl = Table@Random@D, 8i, 1, 10<D


80.40918, 0.227692, 0.982778, 0.0665394,
0.860748, 0.549407, 0.155527, 0.935134, 0.695273, 0.291656<

Apply a function to a list

f@x_D := x ^ 2

Map@f, tblD
80.167428, 0.0518438, 0.965852, 0.00442749,
0.740886, 0.301849, 0.0241886, 0.874476, 0.483405, 0.085063<

0.4091796759394064`^ 2
0.167428

lists and tables

x =.

Table@x@iD, 8i, 1, 5<D


8x@1D, x@2D, x@3D, x@4D, x@5D<

NestList@f, 2, 5D
82, 4, 16, 256, 65 536, 4 294 967 296<

tbl
80.40918, 0.227692, 0.982778, 0.0665394,
0.860748, 0.549407, 0.155527, 0.935134, 0.695273, 0.291656<

tbl@@1DD
0.40918

tbl@@2DD
0.227692

Das könnte Ihnen auch gefallen