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...
icon
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: ???
...
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
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
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 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)
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
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY