Write a Python program that implements the Taylor series expansion of the function In(1+x) for any...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
• Write a Python program that implements the Taylor series expansion of the function In(1+x) for any x in the interval (-1,1], as given by: In(1 + x) = x -+-+-.... • The program should prompt the user to enter the number of terms n. If n > 0, the program prompts the user to enter the value of x. If the value of x is in the interval (-1, 1], the program calculates the approximation to ln(1 + x) using the first n terms of the above series. • The program displays the approximate value as well as the actual value calculated using the standard log function. • Note that the program should validate the user input for different values. If an invalid value is entered, the program should outputs an appropriate error messages and loops as long as the input is not valid. Sample program run: Enter number of terms: 0 Error: Zero or negative number of terms not accepted Enter the number of terms: 9000 Enter the value of x in the interval (-1, 1]: -2 Error: Invalid value for x Enter the value of x in the interval (-1, 1]: 0.5 The approximate value of In(1+0.5000) up to 9000 terms is 0.4054651081 and the value using the standard log function is 0.4054651081 • Note that your program should be general and work if we change the values of the input. Activate Wi • Write a Python program that implements the Taylor series expansion of the function In(1+x) for any x in the interval (-1,1], as given by: In(1 + x) = x -+-+-.... • The program should prompt the user to enter the number of terms n. If n > 0, the program prompts the user to enter the value of x. If the value of x is in the interval (-1, 1], the program calculates the approximation to ln(1 + x) using the first n terms of the above series. • The program displays the approximate value as well as the actual value calculated using the standard log function. • Note that the program should validate the user input for different values. If an invalid value is entered, the program should outputs an appropriate error messages and loops as long as the input is not valid. Sample program run: Enter number of terms: 0 Error: Zero or negative number of terms not accepted Enter the number of terms: 9000 Enter the value of x in the interval (-1, 1]: -2 Error: Invalid value for x Enter the value of x in the interval (-1, 1]: 0.5 The approximate value of In(1+0.5000) up to 9000 terms is 0.4054651081 and the value using the standard log function is 0.4054651081 • Note that your program should be general and work if we change the values of the input. Activate Wi
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
Identify each of the following items as revenues, expenses, or withdrawals from the drop down provided. 1. Advertising expense 2. Consulting revenue 3. Rent expense 4. Rental income 5. Wages expense...
-
Consider the suspension rod diameter measurements described in Exercise 8-27. Compute a 95% prediction interval on the diameter of the next rod tested. Compare the length of the prediction interval...
-
Consider an analogy (the type on the SATs): A bank regulator is to a bank as a bank is to a borrower." In what ways is this analogy true? for a review of the bank-borrower relationship.)
-
Meghann Patrick is a former employee of Altria Group Distribution Company. After her employment was terminated, Patrick sued Altria and a supervisor at Altria, alleging employment-related claims...
-
The following control procedures are used in Kelton Company for over-the-counter cash receipts. 1. Each store manager is responsible for interviewing applicants for cashier jobs. They are hired if...
-
1. Show that the Ramsey number R(m, n) = R(n, m), for all m 2, n 2 positive integers. 2. Show that the Ramsey number R(3, 4) 10. 3. Show that the Ramsey number R(4, 4) < 20.
-
Today is Dec 31, 2020. THP is a clothing retailer that started its business 20 years ago. It currently has two locations within Scarborough Town Centre shopping mall, one near Entrance A (Location...
-
Read the article How to read a research article and make a research Article Critique Report?
-
a. A plug-in transformer supplies 7.50 V to a video game system. How many turns are in its secondary coil, if its input voltage is 120 V and the primary coil has 340 turns? b. What is its input...
-
Comparing a company's stock price return to relevant benchmarks is an example of which type of analytics?
-
You just observed your pour plates from the loop dilution method after 48 hrs of growth at 37 degrees C. There is no growth on plates 2 and 3 (2nd and 3rd dilutions). Please explain at least two...
-
Which best describes a protocol?
-
How many auditors does a compliance level audit require?
-
Potomac Resort and Spa completed the following select transactions during June 2021. The company has a June 30, 2021 year-end: a. Accounts payable had a beginning balance of $3,500. During the month,...
-
For the following exercises, rewrite the sum as a product of two functions or the product as a sum of two functions. Give your answer in terms of sines and cosines. Then evaluate the final answer...
-
Tumor growth can be modeled with the equation where A (t) is the area of the tumor and a , k, and u are constants. Solve the equation for 0 - a4[1-(4)] dA dt
-
Make two separate plots of the function f(x)= -3x4 + 10x2 - 3, one plot for -4 < x < 3 and one for -4 < x < 4.
-
Create the following three matrices: (a) Calculate A + B and B + A to show that addition of matrices is commutative. (b) Calculate A + (B + C) and (A + B) + C to show that addition of matrices is...
-
Let \(X, Y, X_{n}, Y_{n}: \Omega ightarrow \mathbb{R}, n \geqslant 1\), be random variables. a) If, for all n > 1, Xn Yn and if (Xn, Yn) (X, Y), then XIL Y. b) Let X Y such that X, Y ~ B1/2 = (80...
-
Let \(X_{n}, Y_{n}: \Omega ightarrow \mathbb{R}, n \geqslant 1\), be two sequences of random variables. a) If \(X_{n} \xrightarrow{d} X\) and \(Y_{n} \xrightarrow{\mathbb{P}} c\), then \(X_{n} Y_{n}...
-
Let \(X_{n}, Y_{n}: \Omega ightarrow \mathbb{R}^{d}, n \geqslant 1\), be two sequences of random variables such that \(X_{n} \xrightarrow{d} X\) and \(X_{n}-Y_{n} \xrightarrow{\mathbb{P}} 0\). Then...
Study smarter with the SolutionInn App