Problem #2 Write a function called myexp2 that will take x as an input argument
ID: 3733849 • Letter: P
Question
Problem #2 Write a function called myexp2 that will take x as an input argument and return y which is an approximation of Taylor series. 72 y- n! 0 The approximation will stop when the absolute error is less than 5*eps E is given as E- ly- exp(x)l 5 eps Test your code before submitting your function as m file via blackboard. To help you start, use the following code: unction [y.n]-My_exp2(x) y-0; E-1; n 0 % use while loop while (E>5*eps) % newterm-xxxx % y-y+new-term E- abs(y-exp(x); -Explanation / Answer
function [y, n] = My_exp2(x) y = 0; E = 1; n = 1; f = 1; y = 1; while E > 5*10^-10 new_term = (x^n)/f; y = y+new_term; E = abs(y-exp(x)); n = n+1; f = f*n; end end
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.