Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In mathematics, functions can often be represented by infinite series. For example, exp (-x) function can be computed using the so-called Maclaurin series: exp (-x)
In mathematics, functions can often be represented by infinite series. For example, exp (-x) function can be computed using the so-called Maclaurin series: exp (-x) = 1 + (-x) + (-x)^2/2! + (-x)^3)/3! + ... + (-x)^n! In general, as more terms are added in sequence, the approximation becomes better. The computer implementation of such iterative solutions involves loops (i.e. decision loops involving while statement since the number of iterations is not known ahead). Write an M-file function and name it Maclaurin.m that implements the calculation of the exp (-x) function using the above series. Follow the example presented in the textbook involving the function IterMeth.m (see Figure 4.2 in the textbook), which was also discussed in class. The function should be passed as inputs the value to be evaluated (x) along with a stopping error criterion (es) and a maximum allowable number of iteration (maxit). If the user omits either of the latter two parameters, the function should assign default values which are es = 0 0001 and maxit = 100. By executing Maclaurin.m, determine the values of exp(-0.1) by considering the following cases for the stopping criterion as an input. (i) es = 0. 1, (ii) es = 0 01, and (iii) es = 0.0001 without providing the maximum number of iteration as the other input. In each case, report the value of the computed exp(-0.1), the approximate relative error and the actual number of iteration. Box your results
Step 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