Professional Documents
Culture Documents
1 Infinite Series (30 Points) : HW1 p1.m
1 Infinite Series (30 Points) : HW1 p1.m
1 Infinite Series (30 Points) : HW1 p1.m
For N up to 108 , the test script HW1 p1 test.m produces the following figure.
1) The backward sum is more accurate. This is because for forward sum, the starting summations are
between two numbers that have large difference in magnitude. For example, the first term is 1 and the
2nd term is 1/22 . This causes loss of significant figures. For backward sum, two numbers 1/N 2 and
1/(N − 1)2 have comparable magnitude when N is large. Therefore the loss of significant figures is
insignificant. As a result the backward sum is much accurate than the forward sum.
1
EP501 Numerical Methods Homework 1 Solution Due Sep 13, 2013 11:59 pm
2) Explain the results in the plot. Why the three errors vary differently with increasing N ?
The backward sum error decreases exponentially. This is because as more terms included, the error due
to truncation (ignored higher n terms) becomes smaller and the sum is closer to the true value.
The forward sum also decreases exponentially until about N = 104 , for the same reason as above. Beyond
N = 104 , the error due to loss of significant figures become large and it limits the further decrease in
error.
The approximate error is very small initially, because the forward sum and backward sums don’t differ
much when both errors are dominated by the same truncation error. Starting at N = 104 , the truncation
error becomes less significant and the error is dominated by loss of significant figures in the forward sum,
so the approximate error becomes the same as the true error of the forward sum.
3) MATLAB gives eps(’single’)=1.192e-07. The backward sum error can reach below 10−6 , close to this
value. It means that the backward sum is very accurate, there is no additional round off errors from the
numerical method. The forward sum error stopped decreasing at N = 104 , when the smallest term is
about 1/n2 = 10−8 , about the same as eps. This is consistent with the description above.
2
EP501 Numerical Methods Homework 1 Solution Due Sep 13, 2013 11:59 pm
Larger E gives a larger range of the normal number. Larger M gives more numbers for each value of e,
therefore more precision.
The number distribution is generally exponential (as shown by a straight-line) in the logarithmic plot. This
is because the numbers increase due mostly to the change in the exponent. The denormal numbers increase
linearly, because its exponent is a constant and the increase is only due to the fractional part f .
a.
1 1
p1 = 4 arctan + arctan = 3.1415926535897932
2 3
" 3 5 3 5 #
1 1 1 1 1 1 1 1 1 1
p01 = 4 − + + − + = 3.1455761316872428
2 3 2 5 2 3 3 3 5 3
|p01 − p1 | = 0.0039834780974495
p01 − p1
= 0.1268%
p1
b.
1 1
p2 = 16 arctan − 4 arctan = 3.1415926535897932
5 239
" 3 5 # " 3 5 #
0 1 1 1 1 1 1 1 1 1 1
p2 = 16 − + −4 − + = 3.1416210293250346
5 3 5 5 5 239 3 239 5 239
|p02 − p2 | = 0.0000283757352410
p02 − p2
= 0.0009032%
p2
The arctan approximations to π are both very accurate, indistinguishable within machine precision. The
Maclaurin series approximation has an error of about 0.13% for the first expression and 0.00090% for the
second.
3
EP501 Numerical Methods Homework 1 Solution Due Sep 13, 2013 11:59 pm
30.75 − 30.75
x2 = = 0.000 (6)
2(0.3333)
|x02 − x2 | = 0.005420, |x02 − x2 |/|x2 | = 100% (7)
Alternatively,
−2c −2(0.1667)
x001 = √ = =∞ (8)
2
b + b − 4ac −30.75 + 30.75
|x001 − x1 | = ∞, |x001 − x1 |/|x1 | = ∞% (9)
−2c −2(0.1667)
x002 = √ = = 0.005421 (10)
b− b2 − 4ac −30.75 − 30.75
|x002 − x2 | = 6.3 × 10−7 , |x002 − x2 |/|x2 | = 0.0116% (11)
4
EP501 Numerical Methods Homework 1 Solution Due Sep 13, 2013 11:59 pm
−11.01 − 11.00
x02 = = −10.98 (17)
2(1.002)
|x02 − x2 | = 0.00687, |x02 − x2 |/|x2 | = 0.0626% (18)
Alternatively,
−2c −2(0.01265)
x001 = √ = = −0.001149 (19)
b+ b2 − 4ac 11.01 + 11.00
|x001 − x1 | = 7.6 × 10−8 , |x001 − x1 |/|x1 | = 0.00661% (20)
−2c −2(0.01265)
x002 = √ = = −2.530 (21)
2
b − b − 4ac 11.01 − 11.00
|x002 − x2 | = 8.46, |x002 − x2 |/|x2 | = 77.0% (22)