Problem set: Truncation errors and the Taylor series
In this activity, methods of approximating the first derivative were demonstrated. Do some more reading to find at least two methods to approximate second derivatives. Discuss the formulation of these methods and then write functions that implement them.
Using the functions you have written (and some example functions), analyze how truncation error can be approximated in the methods that you have chosen and compare.
The Maclaurin series expansion for cos(x) is:
cos(x) = 1 - (x^2)/2! + (x^4)/4! - (x^6)/6! + ...
While for sin(x), it is:
sin(x) = x - (x^3)/3! + (x^5)/5! - (x^7)/7! + ...
The Maclaurin series is a special case of the Taylor series in which x_i = 0.
Write a script that approximates cos(x) and sin(x) and analyze the truncation error in each series as the number of terms used to approximate the function value is varied.
Use this script to...