Escolar Documentos
Profissional Documentos
Cultura Documentos
2
In[15]:= (+Example+)
(+Define the function f(x) =
2x
6
+ 5x
3
- x
2
+ 9 and find the (i) first derivative
(ii) third derivative (iii) seventh derivative.+)
f[x_] := 2+x^6 + 5+x^3 - x^2 + 9
f'[x] (+for 1st derivative+)
Out[16]= 2 x 15 x
2
12 x
5
In[17]:= f'''[x] (+for 3rd derivative+)
Out[17]= 30 240 x
3
In[18]:= D[f[x], {x, 7}] (+I could have used the f'[x] notation,
but it is easier to write it like
this when we need high order derivatives+)
Out[18]= 0
(+Example <- VERY IMPORTANT+)
(+Let f(x) = cos(x),
sketch the graph and its tangent line at a = /7.+)
In[23]:= f[x_] := Cos[x] (+Define the function+)
In[24]:= a := Pi/7 (+Define the constant a+)
In[25]:= t[x_] := f[a] + f'[a]+(x - a) (+Equation of the tangent,
see class notes for the detailed derivation+)
mathematica_lab_review.nb 9
In[26]:= Plot[{f[x], t[x]}, {x, -2+Pi, 2+Pi}]
(+Plot both in the same graph+)
Out[26]=
6 4 2 2 4 6
1
1
2
3
(+Maclaurin and Taylor series+)
(+Example+)
(+Find the Maclaurin Polynomial of degree 10
for the funtion j(x) = tan
-1
(x). Evaluate j(12.5)+)
j[x_] := ArcTan[x]
Series[j[x], {x, 0, 10}] // Normal
(+the //Normal command is used to remove the O
(n) term. You can't evaluate j(a) with this term.+)
Out[28]= x
x
3
3
x
5
5
x
7
7
x
9
9
In[30]:= j[12.5]
Out[30]= 1.49097
(+Example+)
(+Find the Taylor Polynomial of degree 5 for the funtion k(x) =
e
x
at x = 2. Evaluate k(53.54).+)
k[x_] := E^x
In[34]:= Series[k[x], {x, 2, 5}] // Normal
(+Notice how things are written here inside the curly brackets.+)
Out[34]=
2
2
(2 x)
1
2
2
(2 x)
2
1
6
2
(2 x)
3
1
24
2
(2 x)
4
1
120
2
(2 x)
5
In[35]:= k[53.54]
Out[35]= 1.7870110
23
10 mathematica_lab_review.nb
In[37]:=
(+Integral calculus+)
(+Example+)
(+Calculate
]
[b
2
+ x
2
|dx+)
Integrate[b^2 + x^2, x]
Out[37]= b
2
x
x
3
3
(+Example+)
(+Calculate
]
-5
5
[5x + x
2
|dx+)
In[39]:= Integrate[5+x + x^2, {x, -5, 5}]
Out[39]=
250
3
In[40]:=
(+Ordinary Differential Equation+)
(+Example+)
(+Solve the equation y' =
x + y with initial condition y(0) = 2.+)
DSolve[{y'[x] = x + y[x], y[0] = 2}, y[x], x]
Out[40]= {{y[x] 1 3
x
x]]
(+Example+)
(+Numerically solve the equation y' =
xy with initial condition y(1) =
2 and the graph the solution for -2 to 2.+)
In[41]:= eq1 = NDSolve[{y'[x] = x+ y[x], y[1] = 2}, y[x], {x, -2, 2}]
Out[41]= {{y[x] InterpolatingFunction[{{2., 2.]], ][x]]]
mathematica_lab_review.nb 11
In[42]:= Plot[y[x] /. eq1, {x, -2, 2}]
Out[42]=
2 1 1 2
4
6
8
(+I hope you will all get full scores in the test. All the best!+)
12 mathematica_lab_review.nb