Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please document the code and write this code in python, if I like your solution, i will give you a thumbs up Within the program

image text in transcribed

image text in transcribed

please document the code and write this code in python,

if I like your solution, i will give you a thumbs up

Within the program you MUST document the following: Loop invariants Highlight (via a comment) the decreasing measure in each iteration which guarantees termination Time complexity of the function. Use appropriate notation in your argu- ments/explanations. You will get 0 for not writing appropriate explanations. You will be asked to explain the same during the demo. Write all your code in a single Python file named assignment_3.py. Other specific instructions: Use the Python math library to get the value of it. Part 1 Question 1 In this assignment we will work with iteration (loops) and write their loop in- variants. We already learnt in class how to calculate the value of sin(x) using the Taylor series expansion. We will apply the same ideas to calculate some more useful functions. Implement the following functions using Taylor's Series expansions to find the value of the function for a given x. 1. et = 1 + x + + + + ... Write a function expn(x, n) where n is the number of terms up to which the series is to be expanded and x is the point at which the function is to be evaluated. Example: As e = 1 and let us suppose the number of terms is 2, the function should behave as >>> expn (0, 2) 1 2 2. cos(x) = 1 - x +*+... Example: As cos({ ) = 0 and let us suppose the number of terms is 3, but as the series converges on large values of n. You should obtain >>> cosine (pi/2, 3) 0.0199689 3. 1x = 1+ x + x2 + x3 +... for x) >> inverse (0.5, 3) 1.75 4. In(1 + x) = x - + Example: >>> natural_log(0.5, 2) 0.375 5. tan-'(x) = X- + - ... Example: >>> tan_inv(1, 3) 0.86666667 Instructions: 1. The functions are to be implemented iteratively (using loops). 2. Loop invariants are to be provided for each function using comments. 3. Provide the time complexity of your functions. 4. Your answer should be correct upto 6 decimal digits 3

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

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

1. How is the newspaper help to our daily life?

Answered: 1 week ago

Question

1. Prepare a short profile of Mikhail Zoshchenko ?

Answered: 1 week ago

Question

What is psychology disorder?

Answered: 1 week ago

Question

1. Identify outcomes (e.g., quality, accidents).

Answered: 1 week ago