Question: Program: MATLAB Taylor series can be rearranged to estimate the derivatives of a function. For example, (4.25) is easily obtained from (4.24) f(a + h)

Program: MATLAB

Program: MATLAB Taylor series can be rearranged to estimate the derivatives of

Taylor series can be rearranged to estimate the derivatives of a function. For example, (4.25) is easily obtained from (4.24) f(a + h) - f(a - h) 2h f(a) This equation is called the Centered (or Central) Difference approximation, in which h is the step size The term 0 (h2) means the accuracy is tc h2,c is an unknown constant. It is not a very accurate estimate of f'(a), if h is not small. The accuracy can be improved by reducing h, or by keeping more terms of the Taylor series. The algebra to obtain the approximation with more terms of the Taylor series can be cumbersome. Fortunately, this has been done by some diligent mathematician, and the resulting coefficients are posted on Wikipedia (cf. https://en.wikipedia.org/wiki/Finite difference coefficient). For example, the second line of the table on the Wiki page is f'(a) to the order of O (h4). It has the coefficients of 1/12 -213 0 2/3 -1/12 It means the derivative is 1 [f(a - 2h) 2f(a - h) 2f(a + h) f(a + 2h) 30 f(a)+ The table goes up to O(h8) Assignment: For this assignment, compare the accuracy of the derivative, f' (a) by using the four estimates of f'(a) for the centered (central) difference equation, and by using different values of h. Use the function f(x) - sin(x), a two tables; the first one containing the values of the derivatives with different values of h (11 different values of h), and the second one with the true error in percentage 1. -0.5, and h 1,0.1, 0.01, 0.001,... , 0.0000000001. Create (Exact value - approx value) Exact value errort - abs (a) +OCh2 (a) 0(h6 (a)O(h 0.01 Plot the exact error for each expression of f'(a), by using a log log plot (loglog (h,error)) You will have 4 curves. Explain how the error changes. Based on these results, can you explain which is a better way to improve the accuracy (reduce h or increase the order of approximation)? Is roundoff error a factor in the calculation? Please explain. 2. Taylor series can be rearranged to estimate the derivatives of a function. For example, (4.25) is easily obtained from (4.24) f(a + h) - f(a - h) 2h f(a) This equation is called the Centered (or Central) Difference approximation, in which h is the step size The term 0 (h2) means the accuracy is tc h2,c is an unknown constant. It is not a very accurate estimate of f'(a), if h is not small. The accuracy can be improved by reducing h, or by keeping more terms of the Taylor series. The algebra to obtain the approximation with more terms of the Taylor series can be cumbersome. Fortunately, this has been done by some diligent mathematician, and the resulting coefficients are posted on Wikipedia (cf. https://en.wikipedia.org/wiki/Finite difference coefficient). For example, the second line of the table on the Wiki page is f'(a) to the order of O (h4). It has the coefficients of 1/12 -213 0 2/3 -1/12 It means the derivative is 1 [f(a - 2h) 2f(a - h) 2f(a + h) f(a + 2h) 30 f(a)+ The table goes up to O(h8) Assignment: For this assignment, compare the accuracy of the derivative, f' (a) by using the four estimates of f'(a) for the centered (central) difference equation, and by using different values of h. Use the function f(x) - sin(x), a two tables; the first one containing the values of the derivatives with different values of h (11 different values of h), and the second one with the true error in percentage 1. -0.5, and h 1,0.1, 0.01, 0.001,... , 0.0000000001. Create (Exact value - approx value) Exact value errort - abs (a) +OCh2 (a) 0(h6 (a)O(h 0.01 Plot the exact error for each expression of f'(a), by using a log log plot (loglog (h,error)) You will have 4 curves. Explain how the error changes. Based on these results, can you explain which is a better way to improve the accuracy (reduce h or increase the order of approximation)? Is roundoff error a factor in the calculation? Please explain. 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!