Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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!

image text in transcribed

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! 28 + 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 o 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.54888973327, 19948.71168145393, 7183.459420932159, 2208.4459606630235, 586.7639743355436, 136.1351467847754, 27.828867582232448, 5.051616582274471, 0.8198984471017642, 0.11971099927778994, 0.015809593950030343, 0.0018978006354862798, 0.00020799417515915408, 2.0896565128381006e-05, 1.931633703433633e-06, 1.6483353626473018e-07, 1.3034159418445768e-08, 9.49149988833397e-10, 7.235828847382734e-11, 2.836175738707425e-12)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

Which months of this year 5 Mondays ?

Answered: 1 week ago

Question

Define Leap year?

Answered: 1 week ago

Question

Prepare a short profile of Lucy Clifford ?

Answered: 1 week ago

Question

Prepare a short profile of Rosa parks?

Answered: 1 week ago

Question

KEY QUESTION Refer to the table in question

Answered: 1 week ago