Description
MA202 Numerical Techniques
LAB#3 Approximations and error analysis
1. Taylor Polynomial Approximations It is desirable to know the size of error while making approximations in numerical computation. We would like to know the difference R(x) between the original function f(x) and our approximation fˆ(x).
Taylor-Maclaurin Series Suppose f(x) has a power series expansion at x = a with radius of convergence R > 0, then the series expansion of f(x) takes following form
(1)
, where f(n)(x) is the differentiation of f(x) at nth order. Here in equation (1), the coefficient in the expansion of f(x) centered at x = a and expansion is called Taylor series. If a = 0, then the expansion is called Maclaurin Series. Let us now consider one such classical Taylor series expansion.
For the following example we will assume that all of the functions involved can be expanded into power series. The function f(x) =ex satisfies f(n)(x) =ex for any integer n ≥ 1 and in particular f(n)(0) = 1 for all n and then the Maclaurin series of f(x) is
, (2)
Approximations and truncation errors:
Q. 1: (a) Write a MATLAB script that computes e0.1 and compare with actual value by
calculating error, i.e., absolute difference of true and approximated value
(b) Observe that the error reduces by retaining more number of terms. Plot the errorbetween your approximation and the exact value for different number of terms, i.e., n = 1 to n = 5. Make sure to include labels and have different colors for different values of n.
(c) Plot the error using log-log scale for each of the step sizes. choose step sizes as0.1,0.05,0.02,0.01.
(d) Explain the behaviour you see in both the graphs. Comment on error withnumber of terms as well as accuracy.
(e) What is the slope with respect to the accuracy?
Taylor’s series approximation for forward difference method to approximate the derivatives of a function
Numerical differentiation for f0(x) for the given function f(x) is defined as,
, (3)
where h is the step size.
Q. 2: (a) Write a MATLAB script to calculate numerical derivative of tan−1(x) (b) Use stepsizes ranging from 10−1 to 10−16. Plot the error using log-log scale for each of your step sizes.
(c) Comment on truncation error, machine precision, roundoff error with respect to h.
Home assignment:
Q. 3: Consider a linear system with
, (4)
(a) Find solution of equation (5).
(b) Now, consider the system with a slightly perturbed measurement vector ˆb such that
, (5)
Find solution of equation (6).
(c) Forward error analysis: Find relative error in observation and relative error in solution ; and use eq. (4) to comment on ill-posedness of the problem. Let x denote the solution vector of a linear system Ax = b. If we choose a slightly perturbed observation vector ˆb then we obtain a different solution vector ˆx satisfying Axˆ = ˆb. We would like to know how the relative error in observation influences the relative error in solution. Show that condition number of the matrix A is,
, (6)
where, / represents division operator. See that the value of κA determines (a) how much the relative error in observation can be amplified, i.e., affect the solution, and (b) how much A is close to a singular matrix.
Q. 4: In practice, referring to Q.3, x is not available (since need to be estimated!) and hence impossible to calculate kxˆ − xk as done in Q.4. In order to check the accuracy of computed (estimated) solution ˆx, we measure backward error in terms of difference kˆb − bk. This is possible by considering available (given) observation vector as the true (for reference) while a vector can be (re)constructed using the A and estimated x, i.e., Axˆ.
(a) To realize this, find the backward error kb −ˆbk for Q.4 and comment. (b) Show that, in general, ˆx is the solution to Ax = b exactly when the backward error kb −ˆbk is zero.
Page 2 of 2




Reviews
There are no reviews yet.