Write the code in MATLAB. This is the code that is already given by 1 of
Fantastic news! We've Found the answer you've been seeking!
Question:
Write the code in MATLAB.
This is the code that is already given by 1 of the experts, could you please change the code a bit for me if possible?
Transcribed Image Text:
In this exercise you will write 3 functions. The first and the second will calculate 2 different types of approximation to the number e (Euler's number). The third function will provide a comparison between the 2 approximations. [Hint: In matlab the value of e can be obtained using exp (1)] Part A The inverse of e can be approximated as follows: 4-(-4) Write a function myevalueA that receives as input a value err. The function should calculate an approximation to e (using the formula above) such that the difference between the approximation and the actual value of e is smaller than err. The function will then return the corresponding value of n. Part B The constant e can also be approximated by the following expression: i=0 where i! indicates the factorial of i. Write a function myevalueB that receives as input a value err. The function should calculate an approximation to e (using the formula above) such that the difference between the approximation and the actual value of e is smaller than err. The function will then return the corresponding value of n. Part C Write a function ecompare that will receives as input a vector containing 5 different values of err and will run both myevalueA and myevalueB using these values. The function will then create a plot showing the number of iterations required by the 2 different functions vs the values of err. Note that you will need to provide a way to distinguish between the points obtained with the 2 different methods so that the plot can be used to assess the speed of convergence of the approximations. In this exercise you will write 3 functions. The first and the second will calculate 2 different types of approximation to the number e (Euler's number). The third function will provide a comparison between the 2 approximations. [Hint: In matlab the value of e can be obtained using exp (1)] Part A The inverse of e can be approximated as follows: 4-(-4) Write a function myevalueA that receives as input a value err. The function should calculate an approximation to e (using the formula above) such that the difference between the approximation and the actual value of e is smaller than err. The function will then return the corresponding value of n. Part B The constant e can also be approximated by the following expression: i=0 where i! indicates the factorial of i. Write a function myevalueB that receives as input a value err. The function should calculate an approximation to e (using the formula above) such that the difference between the approximation and the actual value of e is smaller than err. The function will then return the corresponding value of n. Part C Write a function ecompare that will receives as input a vector containing 5 different values of err and will run both myevalueA and myevalueB using these values. The function will then create a plot showing the number of iterations required by the 2 different functions vs the values of err. Note that you will need to provide a way to distinguish between the points obtained with the 2 different methods so that the plot can be used to assess the speed of convergence of the approximations.
Expert Answer:
Answer rating: 100% (QA)
Part C function ecompareerr here err is a vector nA will contain values of n for Part A for each err ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these mathematics questions
-
Could you please write a short essay (1,000 words) regarding the most important characteristics required of a small business owner and the most important factors for SMEs failure? You need to support...
-
Write a user-defined MATLAB function that converts speed given in units of knots (one knot is one nautical mile per hour) to speed in units of feet per second. For the function name and arguments,...
-
Given a square matrix [A], write a single line MATLAB command that will create a new matrix [Aug] that consists of the original matrix [A] augmented by an identity matrix [I]?
-
Which statements are true about the requires directive? (Choose two.) A. Changing it to a requires direct directive is always allowed. B. Changing it to a requires direct directive is never allowed....
-
The Third National Bank has reserves of $20,000 and checkable deposits of $100,000. The reserve ratio is 20 percent. Households deposit $5000 in currency into the bank that is added to reserves. What...
-
Morrow Corporation had only one job in process during May-Job X32Z-and had no finished goods inventory on May 1. Job X32Z was started in April and finished during May. Data concerning that job appear...
-
Find the = 0.01 critical value for the chi-square statistic with 5 degrees of freedom.
-
Lohn Corporation is expected to pay the following dividends over the next four years: $10, $7, $6, and $2.75. Afterwards, the company pledges to maintain a constant 5 percent growth rate in dividends...
-
Wendell's Donut Shoppe is investigating the purchase of an $40,000 donut-making machine with a six-year useful life. The new machine would reduce labor costs by $5,200 per year. In addition, it would...
-
Ryan Ross (111-11-1112), Oscar Omega (222-22-2222), Clark Carey (333-33-3333), and Kim Kardigan (444-44-4444) are equal active members in ROCK the Ages LLC. ROCK serves as agent and manager for...
-
7) Vector A = 5.00 + (-2.00) and vector B= 3.00 +4.005. What is vector C= 2.00 A 3.00B? 7 = Solution:
-
On January 1 , 2 0 2 3 , Mona, Incorporated, acquired 9 0 percent of Lisa Company s common stock as well as 7 0 percent of its preferred shares. Mona paid $ 8 9 , 0 0 0 in cash for the preferred...
-
Amy has her own bookkeeping company, ClearBooks Account providing services for the month ended August 31, 2023. Amy administrative assistant and the other is a bookkeeper. The follo D 1 2 Cost Item...
-
1. John found that his plane could fly at 6 times the speed of the wind. He flew 700 miles upwind in 3 hours more than took to fly 560 miles downwind. What was the speed of the plane in still air? 2....
-
Using data provided, does Elaine have any support for her concern ? Information for the prior five years is shown below: Year 2011 2012 2013 2014 2014 JOS Revenue $750,000 $875,000 $1,200,000...
-
Wedmark Corporation's Cupertino, California, plant manufactures chips used in personal computers. Its practical capacity is 4,500 chips per week, and fixed costs are $71,000 per week. The selling...
-
Red blood cells often can be charged. Two red blood cells are separated by 1.45 m and have an attractive electrostatic force of 0.964 N between them. If one of the red blood cells has a charge of...
-
As water moves through the hydrologic cycle, water quality changes are common because of natural phenomena or anthropogenic pollution. Using Figure 11.1, describe how water-quality changes occur...
-
Karim Depak received a Form 1099-B showing the following stock transactions and basis during 2012: None of the stock is qualified small business stock. Calculate Karim's net capital gain or loss...
-
Ann hires a nanny to watch her two children while she works at a local hospital. She pays the 19-year-old nanny $125 per week for 48 weeks during the current year. a. What is the employer's portion...
-
Carol Harris, Ph.D, CPA, is a single taxpayer and she lives at 674 Yankee Street, Durham, NC 27409. Her Social Security number is 793-52-4335. Carol is an Associate Professor of Accounting at a local...
-
Which of the following questions would an auditor ask while auditing accounts receivable to add value to an audit? a. Are accounts receivable pledged? b. Are customers satisfied with your billing...
-
What are some inquiries an auditor can make when examining the long-term debt account to add value to the audit?
-
Beta, Inc., is an affiliate of an audit client and is audited by another firm of auditors. Which of the following is most likely to be used by the auditor to obtain assurance that all guarantees of...
Study smarter with the SolutionInn App