Assignment-2 Natural Log
Assignment-2 Natural Log
NATURAL LOG
DEEPANSHU GOYAL
100407185
(a) By hand compute this series for the first 10 terms. What is your
answer? How much does it differ from ln(2)?
(b) By hand compute it again for the first 15 terms. Now how much
does it differ? Is it more “accurate”?
Computing the value of first 10 terms, I get 0.72 as the result.
Difference between ln(2) and 0.72 is 0.03
(c) Try computing the first 10 and 15 terms of this series again but this
time using 3-digit arithmetic throughout. Is it more “accurate”?
Yes, its more accurate.
(d) Now try it backwards using 2-digit arithmetic throughout. Sum up
the first 10 terms of the series, but starting with -1/10, and then 1/9,
etc. Do you get a more accurate answer? Or does the direction make
any difference?
The direction does make a difference, as the value is different from
the forward calculation. (0.64)
(e) So think about how you would get the best approximation of ln(2).
Should you use:-
a. an even number of terms or an odd number?
Using an even number of terms can result in cancellation of errors or
like-terms, especially when the terms have alternating signs. This can
lead to a more accurate approximation.
Trade-Off -> We cannot use odd number of terms if we want to get best
approximation of ln(2).
sumSeriesForwardsDouble : 0.0000000004992983
sumSeriesBackwardsDouble : 0.0000000005000003
sumSeriesForwardsTwoHalves : 0.0000000004970813
sumSeriesBackwardsTwoHalves : 0.0000000005004053
sumSeriesForwardsFloat : 0.0000096540477993
sumSeriesBackwardsFloat : 0.0000000019046547
The results vary due to following reasons:-
• sumSeriesForwardsDouble and sumSeriesBackwardsDouble use
the double data type, which has higher precision than float. They
provide results that are very close, but not necessarily identical,
due to the way floating-point arithmetic works.
• sumSeriesForwardsTwoHalves and
sumSeriesBackwardsTwoHalves sum positive and negative terms
separately before combining them. This can introduce additional
rounding errors compared to summing all terms together.
• sumSeriesForwardsFloat and sumSeriesBackwardsFloat use the
float data type, which has lower precision than double. As a
result, they provide results that are further from the true value of
the series.