MS-A0210 Mathematics 1, period II

MS-A0210 Mathematics 1, period II-2016
Computer exercises
Metsalo
Attack these problems to get familiar with Matematica
After having logged in into a computer, for example in room Y344, choose Start (the Windows-symbol
in the lower left corner) and then Wolfram Mathematica 11. Choose to create a New Document. Then
Mathematica opens a new window for commands. How to leave Mathematica is described in the end.
Commands and functions in Mathematica begin with a capital letter, e.g. Sin, Sqrt and Exp.
? gives access to the helpsystem (write for example ?Sin). Commands are entered by pressing Shift Enter.
Arguments for functions are given in brackets [ ] and lists are given in braces { }.
√
1. Calculate 3 · 7, 36 , 5, sin(π/3) and eπ using 3 ∗ 7, 3ˆ6, Sqrt[5] (and when we ask for a numerical
value, we are given 2.23607), Sin[Pi/3] and Exp[Pi] or EˆPi.
2. Mathematica can plot graphs of functions. The curve y = sin(1/x), −4 ≤ x ≤ 7 can be drawn by
Plot[Sin[1/x], {x, −4, 7}]. Draw the curve also for −0.4 ≤ x ≤ 0.7 (using arrows ↑, ↓, ← and →)
and for −0.04 ≤ x ≤ 0.07. Notice, that the function behaves so badly near the origin x = 0 that
Mathematica can not draw a correct picture.
3. Parametric curves (x, y) = (f (t), g(t)) can be drawn using ParametricPlot. Draw the asteroid
x2/3 + y 2/3 = 1, which can be given parametrically as (x, y) = (cos3 t, sin3 t) for 0 ≤ t ≤ 2π, by
ParametricPlot[{(Cos[t])ˆ3, (Sin[t])ˆ3}, {t, 0, 2∗Pi}]. Notice, that the asteroid has cusps, although
f (t) and g(t) are smooth functions.
4. Mathematica can calculate derivatives of functions. f 0 =Sin[xˆ3] + 17 is differentiated by the
command f 1 = D[f 0, x]. Mathematica can also integrate some functions. Integrate[f 1, x] will give
the integral of the derivative of f 0.
5. Mathematica can calculate some definite integrals.
Integrate[Sqrt[9 − xˆ2], {x, −3, 3}] gives the area of the region under a semicircle.
√
R
6. Some functions can however not be integrated using Mathematica. Try for example sin( 1 + x6 )dx.
Definite integrals can be approximated numerically, though. NIntegrate[Sin[Sqrt[1 + xˆ6]], {x, 0, 1}]
√
R1
gives an approximate value of 0 sin( 1 + x6 )dx.
7. Parametric curves (x, y, z) = (f (t), g(t), h(t)) in space can be drawn using ParametricPlot3D.
ParametricPlot3D[{(2+Cos[3∗t/2])∗Cos[t], (2+Cos[3∗t/2])∗Sin[t],Sin[3∗t/2]∗Sqrt[21]/5}, {t, 0, 4∗Pi}]
draws a trefoil knot. It can be rotated in space using the mouse.
8. In this course we work primarely with functions of several variables. Mathematica can plot graphs
2
2
of functions of two variables. The surface z = xy 2 · e−(x +2y ) for −2 ≤ x, y ≤ 2 is drawn by
Plot3D[x ∗ yˆ2∗ Exp[−(xˆ2 + 2 ∗ yˆ2)], {x, −2, 2}, {y, −2, 2}]. And again it can be rotated.
9. Parametric surfaces (x, y, z) = (f (u, v), g(u, v), h(u, v)) can also be drawn using ParametricPlot3D.
ParametricPlot3D[{(2+Cos[3 ∗ u/2]+Cos[v]/5)∗Cos[u], (2+Cos[3 ∗ u/2]+Cos[v]/5)∗Sin[u],
Sin[3 ∗ u/2]∗Sqrt[21]/5+Sin[v]/5}, {u, 0, 4∗Pi}, {v, 0, 2∗Pi}] draws a thickened version of the trefoil
knot in exercise 7 above.
10. Instead of studying the graph of a function f (x, y) of two variable (i.e. the surface z = f (x, y)), we
can also study its level curves.
ContourPlot[(xˆ2 − 1)ˆ2 − (yˆ2 − 1)ˆ2, {x, −1.5, 1.5}, {y, −1.5, 1.5}] draws level curves of the function
f (x, y) = (x2 − 1)2 − (y 2 − 1)2 in the square −1.5 ≤ x, y ≤ 1.5.
11. Mathematica can calculate partial derivatives of functions of several variables, which we study in
2
this course. Let T (x, t) = √1t · e−x /4ct by writing T=Exp[−xˆ2/(4 ∗ c ∗ t)]/Sqrt[t]. Then calculate
∂T /∂t by D[T,t] (partial derivative of T with respect to t, while treating x as a constant) and
∂ 2 T /∂x2 by D[T,{x, 2}] (second partial derivative of T with respect to x, while treating t as a
constant). Finally calculate ∂T /∂t − c · ∂ 2 T /∂x2 and simplify the answer.
12. Mathematica can also calculate multiple integrals of functions of several variables. These will be
studied in chapter 14 in Adams/Essex.
Leave Mathematica by choosing File in the upper left corner in the Mathematica window and then Quit
under File. Probably there is no need to save this work. Do not forget to log off (using again Start in
the lower left corner).
Use Mathematica as a tool for doing complicated calculations and for checking answers to homework
problems and hand ins.
Problems for exercise 3, week 45-46 are on the back.