The exponential function e* can be approximated using a Taylor/Maclaurin series 00 e* %3D п! n=0 a) Write a function file that takes x as the input and calculates the approximation of e* using the first six terms of the series. i.e. n = 0 to n = 5. Your function should work for either a scalar or vector inputs. As a check, the approximation should return 42.8667 for x = 4.
The exponential function e* can be approximated using a Taylor/Maclaurin series 00 e* %3D п! n=0 a) Write a function file that takes x as the input and calculates the approximation of e* using the first six terms of the series. i.e. n = 0 to n = 5. Your function should work for either a scalar or vector inputs. As a check, the approximation should return 42.8667 for x = 4.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Could I have help with this question in MATLAB, thanks
![The exponential function e* can be approximated using a Taylor/Maclaurin series
00
x"
п!
n=0
a) Write a function file that takes x as the input and calculates the approximation of e* using the first six terms of
the series. i.e. n = 0 to n = 5. Your function should work for either a scalar or vector inputs. As a check, the
approximation should return 42.8667 for x = 4.
b) The hyperbolic function tanh(x) is defined as
- e-x
tanh(x) =
%3D
ex + e-x
Write an m-file that uses the function file you wrote in part (a) to calculate tanh(x) for x = [1,5, 25, 60]
Calculate the error (absolute difference) between your approximated tanh(x) and the MATLAB's built in tanh()
function. Use the following example fprintf() statement to print the values of the approximated tanh, the
MATLAB's tanh and the absolute error for every input x.
fprintf("x: %.2f, Approximated tanh: %.2f, MATLAB's tanh: %.2f, Absolute error: %.2f\n",
[x;tanh_approx;tanh_real;error])
Example output below.
x: 5.00, Approximated tanh: ???, MATLAB's tanh: ???, Absolute error: ???
x: 25.00, Approximated tanh: ???, MATLAB's tanh: ???, Absolute error: ???
...](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fc91eb436-6202-4368-9458-806984f92c1b%2F0080004b-ab12-4f1f-b9a4-752e5aaf5dc6%2F6wsj9z_processed.png&w=3840&q=75)
Transcribed Image Text:The exponential function e* can be approximated using a Taylor/Maclaurin series
00
x"
п!
n=0
a) Write a function file that takes x as the input and calculates the approximation of e* using the first six terms of
the series. i.e. n = 0 to n = 5. Your function should work for either a scalar or vector inputs. As a check, the
approximation should return 42.8667 for x = 4.
b) The hyperbolic function tanh(x) is defined as
- e-x
tanh(x) =
%3D
ex + e-x
Write an m-file that uses the function file you wrote in part (a) to calculate tanh(x) for x = [1,5, 25, 60]
Calculate the error (absolute difference) between your approximated tanh(x) and the MATLAB's built in tanh()
function. Use the following example fprintf() statement to print the values of the approximated tanh, the
MATLAB's tanh and the absolute error for every input x.
fprintf("x: %.2f, Approximated tanh: %.2f, MATLAB's tanh: %.2f, Absolute error: %.2f\n",
[x;tanh_approx;tanh_real;error])
Example output below.
x: 5.00, Approximated tanh: ???, MATLAB's tanh: ???, Absolute error: ???
x: 25.00, Approximated tanh: ???, MATLAB's tanh: ???, Absolute error: ???
...
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 2 images

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY