Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create this using the Python Programming language. (a) Write a function that calculates the Taylor expansion 23 sin(x) = x - 2 25 + 27
Create this using the Python Programming language.
(a) Write a function that calculates the Taylor expansion 23 sin(x) = x - 2 25 + 27 7 + ... with a nested function that evaluates the factorial part. The function should take the number of terms in the expansion as a keyword argument (i.e. with a default value). Hint: iterate with a loop, using (-1) **i to determine the plus/minus sign, and make the odd numbers from i. Document what your code is doing so that both we and future-you would understand how you wrote the function. (b) Using x = 7/2, compare your function with numpy.sin(). Use %timeit to see which function is faster. Print the results alongside the --name-- of the function used, using the f-string to show the numbers with at least 5 decimal places. Use a Boolean to say whether they are equalStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started