Question: HOW TO DO IN PYTHON? Colin Maclaurin (Image credit: Wikipedia) Transcendental functions, like sine, cosine, and the exponential function (and others), can be represented as
HOW TO DO IN PYTHON?
Colin Maclaurin (Image credit: Wikipedia) Transcendental functions, like sine, cosine, and the exponential function (and others), can be represented as infinite expansions known as "Maclaurin Series", after the Scottish mathematician Colin Maclaurin (1698--1746). Three well-known Maclaurin series are: 00 23 3! sin (2) (-1)" 7 + 7! + 22+1 5! (2n + 1)! n=0 26 22 24 cos(x) = 1 - 2! + 4! +... (-1)" (2n)! 6! n=0 1 25 2 exp(x) = 1 + x + + + ...= n! n=0 The program template provided below, my_maclaurin.py, defines the function do_series_expansion () that requires three arguments: N is the number of terms you should use in your series computation, x is the independent variable value where the mathematical function represented by the infinite Maclaurin series expansion is to be evaluated, and func is one of 'sin', 'cos', or 'exp'. Based on the value of the argument func, your do_series_expansion() must compute the approximate value of sin(x), cos(x), or exp(x) using a Maclaurin series expansion out to N terms. It should then obtain the "exact" answer from the appropriate function in the math module. The difference between these two quantities [(approximate)-(exact)) should be assigned to the variable error, which do_series_expansion () returns. If func is not a valid option, return a value of exactly -1.0e10 in error. The main block in the template is provided to allow you to test this program on your own computer before you submit. It does not matter what is in the _main__block of the my_maclaurin.py you submit; you are only graded on the performance of your do_series_expansion() implementation
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
