Please read carefully. The following must be done in Matlab. if you do not know
ID: 3887673 • Letter: P
Question
Please read carefully.
The following must be done in Matlab.
if you do not know the code, do not answer
Problem 2: In mathematics, functions can often be represented by infinite series. For example, exp(x) function can be computed using the so-called Maclaurin series 314 (-x)n n! exp(-x) = 1 + (-x) + + + 21 3! 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 es0.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.Explanation / Answer
The assignment I have is to create a MATLAB function that calculates the value of a function of x as defined as f(x) = (x^2)/37 + (x^3)/3! + (x^4)/4! + (x^5) +.... and test it with a few sets of data for the x value and nth order in which to evaluate. I have created a function, and yet when I try to evaluate it, the output keeps equaling zero for anything I put in there. I'm not completely sure what I'm doing wrong.
Here's the code for the function:
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.