1) Write a MATLAB function to evaluate exp(x) using the Taylor seriese exp (x) =
ID: 2993822 • Letter: 1
Question
1) Write a MATLAB function to evaluate exp(x) using the Taylor seriese
exp (x) = sigma n=0 to infinity X^n /n!
The inputs are the value of x and the desired absolute accuracy of exp (x). be sure to have a test for non convergence. If the series fails to converges tell the user the value returned has not converged and is not accurate (has not converged to the desired accuracy .) your messaage in the case of non convergence should inform the user why non convergence occured.
2) Develop the summation expression and write a second MATLAB function similarto above sin(x) using the Tylor series expansion
sin(x) = x- x^3/3! + x^5/5! -x^7/7!...........
Thanks
Explanation / Answer
function [ex]=expf(x,acc) % Function expf(x,acc) calculates exp(x) using Taylor Series with accuracy=acc % %Set the maximum number of terms to 1000. This will not be a user input. % MaxTerms=1000; % % Start the evaluation % ex=1.; % First sum in the Taylor series term=1.; % First term in the Taylor series % % Loop to update the term and add to the current value of ex % for n=1:MaxTerms term=term*x/n; ex=ex+term; if abs(term)Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.