Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedCreate 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 equal

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

Microsoft Office 365 For Beginners 2022 8 In 1

Authors: James Holler

1st Edition

B0B2WRC1RX, 979-8833565759

More Books

Students also viewed these Databases questions

Question

dy dx Find the derivative of the function y=(4x+3)5(2x+1)2.

Answered: 1 week ago