1. Engineering
  2. Computer Science
  3. how do you code for the taylor series in python...

Question: how do you code for the taylor series in python...

Question details

this part, you will use a six-element Taylor series to approximate a cosine function of an angle x (measured in radians). Write a function mycos (x) that approximates the cosine function by returning the sum of the first six elements of its Taylor series as follows:- 8 10 2!4!!8!10! For this part, you may use the math.factorial ) function to calculate the factorial values in the denominator of each term. Write your function in the Part 1 section of your template file, being sure to import the necessary modules, and be sure to return the result from your function. When you have completed your function, run it by first invoking the Run > Run Module command of your IDLE edit window. Then in the Python shell window, call the function with some test values.2 or reference, here are some values of myCos (x):- >>> myCos (3.1416) -1.001829154863163 >>> myCos (0) >>> myCos (6.2832) -5.438422238161426 Experiment with some other values of the argument to mycos ).Report your test values and results in comment lines in your template file under Part 1. As you will see, myCos ) is a reasonable approximation to the actual cosine function for argument values (i.e., angles) in the range (-π t) radians, but it starts to diverge significantly as values move farther outside this range

How do you code for the taylor series in python, my professor said that I can just def myCos(x): and just type in the function but I can't use ! so while the syntax is correct, the answers aren't correct when I test out solutions.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution