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
-
Which entities are responsible for the development of cybersecurity policy? Defend your answer. It is an important skill to communicate concepts to non-technical decision-makers. What are some ways...
-
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...
-
You need to prepare the financial statement and the adjusting entries for the December31st year end (using EXCEL) for a company that follows IFRS and has a December 31st year end. The company has a...
-
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...
-
FIGURE 18-36 shows an example of a Carnot cycle. The cycle consists of the following four processes: (1) an isothermal expansion from V1 to V2 at the temperature Th; (2) an adiabatic expansion from...
-
Nisson Distributing Ltd. completed the following merchandising transactions in the month of April. At the beginning of April, Nisson's general ledger showed Cash $4,000; Accounts Receivable $3,500;...
-
Assume that Fossil sold watches to a department store on account for \($43,000\). How would this transaction affect Fossils accounting equation? a. Increase both liabilities and stockholders equity...
-
Use the information in RES-7. Calculate Uncle Butchs Hunting Supply Shops ending inventory' using the retail inventory method under the lower of average cost or market assumption. Round the...
-
Terlon Corporation has a beta of 1.23 and its required rate of return is 11.25%. The risk free rate is 4.30%. What is the required rate of return of the stock market given this data?
-
The Fruehauf Corporation (Fruehauf) is engaged in the manufacture of large trucks and industrial vehicles. The Edelman group (Edelman) made a cash tender offer for the shares of Fruehauf for $ 48.50...
-
On Monday, a local True Value Hardware sold 15 paints brushes at $3 each, six wrenches at $5 each, four lawn mowers at $119 each, and 28 cans of paint at $8 each. What were True Value's total dollar...
-
What is a call option, and how does it work in the context of financial markets? 2. What factors determine the price of a call option? 3. How does the strike price of a call option affect its value?...
-
Complete the following steps to determine if 213 is prime. (a) Complete the following statement. If x is composite, then x has a factor that: (b) Use the Sieve of Eratosthenes to find all potential...
-
The horizontal bar AB moves up with the velocity of v1 = 2m/s; CD moves with the velocity of V2 = 2m/s as shown in the figure. Determine the velocity of the ring M. M
-
Find the winner of this election under the plurality method. Winner =
-
Provide examples of international customs in the field of environmental protection. Describe the types of international environmental treaties. What is the framework approach for the elaboration and...
-
If the corporate tax rate is 35% and the personal tax rate on dividends is 20%, what will be the net dividends (per share) for shareholders in C corporation and S corporation? Corporation Type Income...
-
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...
-
Fill in the Blank. In the finite element method, \(a(n)\) ___________ solution is assumed within each element.
-
The stiffness matrix of a bar element is given by a. \(\frac{E A}{l}\left[\begin{array}{ll}1 & 1 \\ 1 & 1\end{array} ight]\) b. \(\frac{E A}{l}\left[\begin{array}{rr}1 & -1 \\ -1 & 1\end{array}...
-
What is the basis for the derivation of transformation matrices?
Study smarter with the SolutionInn App