Computational Techniques
NPTEL Video Course
Problem Sheet 02
Problem 1: Round-off Errors
The roots of the equation ax 2 bx c 0 can be computed in the following two ways:
b b 2 4ac 2c
x1 , x2 or x1 , x2 .
2a b b 2 4ac
Use five-digit arithmetic with chopping (i.e., the sixth digit is discarded) to compute the roots of
the equation x 2 5000.002 x 10 0 from the two formulae given above.
Problem 2: Taylor’s Series for Finite and Infinite Series
Consider the following functions. It is known that f(1) = 0 for both these cases. Use zero to
fourth order Taylor’s series expansion to obtain f(3). The two functions are:
f x 18 x 4 25 x3 6 x 2 7 x 44 and f x ln x .
Comment on the relative error of the two cases, as more terms are included from the Taylor’s
series expansion.
Problem 3: Taylor’s Series and Effect of Step Size
Using the Taylor’s series expansion:
h2 hn n
f a h f a hf a f a f a
2! 2!
Obtain the infinite series expansion of ex and cos(x). [Assume f(0) is known and h = x]
For each of these functions, calculate the function values at x = /4, each time increasing
the number of terms used by 1 until the relative error reduces to 10-5 (i.e., report the relative
error when 1, 2, 3, … terms are included from the infinite series). Compute the true relative
error at each stage. Observe that the truncation error reduces as the number of terms
increase. How many terms are required to reduce the relative error to 10-5?
Alternatively, we can truncate the infinite series at the first order term hf x . Compute the
value of cos(/4) using this first-order approximation, using h = /4, /8, /16, …, /64.
Plot error vs. step size (h) on a log-log plot and comment about its slope.
Computational Techniques