Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Write a Python program that calculates cosine function. The value for the cosine function can be approximated by the following Taylor series cosx)2(2n)! where n! is the factorial function (n2 0 is an...

1 answer below »
Write a Python program that calculates cosine function. The value for the cosine function can be approximated by the following Taylor series cosx)2(2n)! where n! is the factorial function (n2 0 is an integer) given by For example, 5!-1x2x3x4x5 1) Write a function called "myFact" that calculates factorial function. Use a "for" loop to calculate the factorial. 2) Write a function called "myCosine" that approximates the cosine function. Your function should use enough terms in the Taylor series such that the last term added before returning a result should be smaller than 10 the Taylor series using a "while" loop that uses the size of the term being added to the series is the stopping criteria. You can check your function's results with the built-in Python function math.cosx). Note that x is given in radian In other words, your code should compute Extra credit challenge question +10) After getting your function to work initially, modify your code such that your function will stop running if more than 10 terms are needed in the Taylor series. Your python program can have the following form: def myFact (n) def myCosine (x) xVal-math.pi/20 # call function myCosine() to calculate the cos(x) # ...-compare vour result with math.cos(x)
Answered 137 days After Nov 26, 2021

Solution

Sathishkumar answered on Apr 13 2022
95 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here