Description
C1. This is a “warm-up exercise”. You are given the Matlab function expseries.m and script
expserieserrorT.m, illustrating Example 1.8 on page 12 of your course text.
For x in the interval [20, 20] plot the estimated and actual number
of digits lost (somewhat nonintuitively, it’s fine for this to not be an
integer), as well as the number of terms used in the Taylor series
expression. Your output plot should look like the picture on the
right (without the watermark). The second plot shows the number
of terms used in the Taylor series approximation.
To get there you will have to change the following in
expserieserrorT.m:
• Interval boundaries
• Find and fix the error in the code
• Add the plotting command for the second subplot
• Add titles and labels to the graph
I am also sharing a Matlab script plotpubl.m which plots thicker lines to produce figures suitable for
“publication”. You can set the line width to 2 by typing plotpubl(2).
C2. Now that you’ve modified Matlab code and executed a script, you are ready to write a script from
scratch. Consider Example 1.9, page 13 of your text. This example provides four different ways to
compute the numbers
yn =
Z 1
0
xn
x + a
dx.
Take a = 10; because we are now working with 16 decimal digits of accuracy, we will compute the yn
for n = 0, 1,… 20. Hand in a table of your computed values similar to Table 1.1 on page 14. Briefly
comment on your results, and explain why your numbers differ from those in Table 1.1 (which were
computed on the same HP pocket calculator used for Example 1.7 in the text).
Note: Array indices in Matlab always start at 1, so the mathematical y0 would correspond to, say y(1)
in Matlab. To format your table, print out the results with the fprintf command. See the Matlab
documentation, or simply type help fprintf at the command prompt.
C3. Evaluate s = X1
n=1
1
n2 + 1
with an error less than 1013. Report your answer (14 digits), and
comment. How many terms of the series would you need if you used this series directly?
How much faster can you compute s by rewriting the series (compute 1
n2 + 1 1
n2 +
1
n4 ) and using the
values X1
n=1
1
n2 = ⇡2
6 , X1
n=1
1
n4 = ⇡4
90 .
MRT 1