Question: python Q1: Functions - 20 points The file associated with this question is Q1Functions.py. Part A (8 points). Consider the Taylor Series expansion of cos(x):

python Q1: Functions - 20 points The file associated with this questionpython

Q1: Functions - 20 points The file associated with this question is Q1Functions.py. Part A (8 points). Consider the Taylor Series expansion of cos(x): .22 cos2 = 1 + + 2! 4! 6! 8! 26 Write a function called taylor_cos(x, terms) that computes the value of cos(x) according to this Taylor series expansion. Your function has two inputs: x: this denotes the value for which we want to compute cos(x) terms: this denotes how many terms should be considered in the Taylor series expansion. In the above example, terms=5. There may be fewer or more terms. taylor_cos() should return the computed result Part B (4 points). The value of cos(x) can also be computed using numpy: np.cos(x). We define the error in using the Taylor series expansion as: the absolute value difference between np.cos(x) and the result of taylor_cos(x, terms). The error changes according to how many terms are used in the Taylor series expansion. Write a function called calc_err_cos(x, start_term, end_term) such that: x is the value for which we compute cos(x) For terms between start_term and end_term (both inclusive): o calc_err_cos calculates the error with that number of terms The errors are stored in a list The return value of calc_err_cos is the list of errors For example, calc_err_cos(15, 10, 30) returns the following list. The first element is the error with terms=10, second element is the error with terms=11, third element is the error with terms=12, ..., the last element is the error with terms=30. [90963.06530710444, 46615.54808973327, 19948.71168145393, 7183.459420932159, 2208.4459606630235, 586.7639743355436, 136. 1351467847754, 27.828867582232448, 5.051616582274471, 0.8198984471017642, 0.11971099927778994, 0.015899593950030343, @.2018978006354862798, 0.00020799417515915408, 2.0896565128381006e-05, 1.931633703433633e-06, 1.6483353626473018e-e7, 1.3034159418445768e-08, 9.49149980833397e-10, 7.235800847382734e-11, 2.836175738707425e-12]

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!