Solutions

In[13]:=

(*1*)A = Table[{x, x Exp[-x]}, {x, 0, 5, 0.5}]

Out[13]=

{{0, 0}, {0.5, 0.303265}, {1., 0.367879}, {1.5, 0.334695}, {2., 0.270671}, {2.5, 0.205212}, {3., 0.149361}, {3.5, 0.105691}, {4., 0.0732626}, {4.5, 0.0499905}, {5., 0.0336897}}

In[14]:=

(*2*)TableForm[A]

Out[14]//TableForm=

0 0
0.5` 0.3032653298563167`
1.` 0.36787944117144233`
1.5` 0.33469524022264474`
2.` 0.2706705664732254`
2.5` 0.205212496559747`
3.` 0.14936120510359183`
3.5` 0.10569084197811475`
4.` 0.07326255555493671`
4.5` 0.04999048442209038`
5.` 0.03368973499542734`

In[15]:=

(*3*)poly = InterpolatingPolynomial[A, x] ; Expand[%]

Out[16]=

0.999911 x - 0.999469 x^2 + 0.49869 x^3 - 0.164872 x^4 + 0.0401274 x^5 - 0.00745596 x^6 + 0.00104543 x^7 - 0.000104388 x^8 + 6.56489*10^-6 x^9 - 1.93445*10^-7 x^10

In the next excercise we'll do some tricks. The function Select takes as arguments a table and a criterion which it will apply to the table. In this case the criterion, #[[1]]==0.0& is in the form of a pure function, the argument of which, denoted by #, is a list. We test whether the first element of this list (which in this case is an element of A, equals to zero (or 1 or 2,5). The command & at the end just signifies that this really is a pure function. Select returns a list of elements of A which satisfy the criterion. We assume that there is only one element in A which satisfies our criterion and take the second element of the first element of the resulting list. This excercise can be done in a more simple way by just extracting A[[1,2]], A[[3,2]] and A[[6,2]].

In[17]:=

(*4*)Part[Select[A, #[[1]] 0.&], 1, 2] - poly/.x0.Part[S ... ] - poly/.x1.Part[Select[A, #[[1]] 2.5&], 1, 2] - poly/.x2.5

Out[17]=

0.

Out[18]=

0.

Out[19]=

-1.11022*10^-16

In[20]:=

(*5*)ListPlot[A, PlotStyle {PointSize[0.01], Hue[0.]}, DisplayFunctionᢃ ...  DisplayFunctionIdentity] ; Show[%, %%, DisplayFunction$DisplayFunction]

[Graphics:../HTMLFiles/ex03_solutions_44.gif]

Out[22]=

⁃Graphics⁃

In[23]:=

(*6*)Plot[poly - x Exp[-x], {x, 0, 5}, PlotRange {-6 * 10^(-6), 6 * 10^(-6)}]

[Graphics:../HTMLFiles/ex03_solutions_47.gif]

Out[23]=

⁃Graphics⁃


Created by Mathematica  (April 10, 2007) Valid XHTML 1.1!