Question
Explanation and complete code gets thumbs up. Problem statement The objective of this problem is to compute Taylor series approximations of exp(10) and exp(10) using
Explanation and complete code gets thumbs up.
Problem statement
The objective of this problem is to compute Taylor series approximations of exp(10) and exp(10) using MATLAB. The Taylor series approximation of order N of exp(x) is:
where i! is the factorial of i.
exp(x) =
N x i
i! (1)
Instructions
Create a MATLAB file name HW1LastnameFirstname.m, where Lastname is your last
name and Firstname is your firstname. This file should include three functions: the func- tion HW1LastnameFirstname, the function taylorSeriesExpMethod1 and the function taylorSeriesExpM ethod2
The function named taylorSeriesExpMethod1 has two inputs and two outputs:
The 1st output is the Taylor series approximation of order N of exp(x); this approxima-
tion should be computed using Eq. 1.
The 2nd output is the value of the true percent relative error, t.
The 1st input is the value of x.
The 2nd input is the order of the approximation, N.
The function named taylorSeriesExpMethod2 has the same inputs and outputs as taylorSeriesExpMethod1. However, the Taylor series approximation of order N of exp(x) should be computed using the following approach:
(a) The function taylorSeriesExpMethod1 is called to compute f1 = exp(x) (b) The Taylor series approximation of exp(x) is computed using the equation exp(x) = 1/f1
The function HW1LastnameFirstname should have no input and no output. In this func- tion,
(a) Compute the value of the Taylor series approximation of exp(10) and of the true percent relative error by calling your function taylorSeriesExpM ethod1 for N = 1, 2, ...60
(b) Compute the value of the Taylor series approximation of exp(-10) and of the true percent relative error by calling your function taylorSeriesExpM ethod1 for N = 1, 2, ...60
(c) Compute the value of the Taylor series approximation of exp(-10) and of the true percent relative error by calling your function taylorSeriesExpM ethod2 for N = 1, 2, ...60
(d) In a single figure, plot using a logarithmic scale (for the vertical axis only) the value of the true percent relative error as a function of N for exp(10) and exp(10) using Method 1 and exp(10) using Method 2
Make sure to add comments that describe your function as in the code included the resources on T-Square (in Lectures, Part 2). Include axis labels, a title and a legend in your graph. In your hard copy, answer the following questions:
What is the minimum value of the error that can be obtained for the computation of exp(10) using Method 1? using Method 2?
Which method do you recommend using for the computation of exp(10)? Why?
Problem statement The objective of this problem is to compute Taylor series approximations of exp(10) and exp(-10) using MATLAB. The Taylor series approximation of order N of exp(x) is: exp(x)- i! where i! is the factorial of i Instructions 1. Create a MATLAB file name HW1LastnameFirstname.m, where Lastname is your last name and Firstname is your firstname. This file should include three functions: the func- tion HW1LastnameFirstname, the function taylorSeriesExpMethodl and the function taylorSeries ExpMethod2 2. The function named taylorSeriesExpMethodl has two inputs and two outputs . The 1st output is the Taylor series approximation of order N of exp(x); this approxima- tion should be computed using Eq. 1 . The 2nd output is the value of the true percent relative error, Et . The 1st input is the value of r . The 2nd input is the order of the approximation, N. 3. The function named taylorSeriesExpMethod2 has the same inputs and outputs as taylorSeries ExpMethod1. However, the Taylor series approximation of order N of exp(x) should be computed using the following approach (a) The function taylorSeriesExpMethodl is called to compute fl = exp(-r) (b) The Taylor series approximation of exp(z) is computed using the equation exp(z) = 1 4. The function HW1LastnameFirstname should have no input and no output. In this func- tion (a) Compute the value of the Taylor series approximation of exp (10) and of the true percent 60 (b) Compute the value of the Taylor series approximation of exp(-10) and of the true percent (c) Compute the value of the Taylor series approximation of exp(-10) and of the true percent (d) In a single figure, plot using a logarithmic scale (for the vertical axis only) the value relative error by calling your function taylorSeriesExpMethodl for N = 1, 2, relative error by calling your function taylor-SeriesExpMethodl for N = 1, 2, relative error by calling your function taylor-SeriesExpMethod2 for N = 1, 2, 60 60 of the true percent relative error as a function of N for exp(10) and exp(-10) using Method 1 and exp(-10) using Method 2 Make sure to add comments that describe your function as in the code included the resources on T-Square (in Lectures, Part 2). Include axis labels, a title and a legend in your graph. In your hard copy, answer the following questions 1. What is the minimum value of the error that can be obtained for the computation of exp(-10) using Method 1? using Method 2? 2. Which method do you recommend using for the computation of exp(-10)? WhyStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started