Question: The function ( ) = can be evaluated using the following infinite series: ( ) = = 1 + + 2 ! + 3 !

The function ()= can be evaluated using the following infinite series:
()==1++
2!
+
3!
+
4!
+
Create a function m-file called Lab1Q3.m that evaluates the function to a certain error
tolerance s
(i.e, continues adding terms one at a time until the approximate percent relative
error a s ).
The input variables to the function should be x , s
and the maximum number of terms
maxterms. In case the solution will not converge, it is always a good idea to specify a
maximum number of iterations or terms such that the code will terminate when either
a s or the number of terms reaches the maxterms value.
The output variables should be the result of the function (funcex), the approximate error after
convergence is reached ( a ), and the number of terms required for the solution to converge
(terms). The first line of the function should therefore be as follows:
function [funcex,ea,terms]=Lab1Q3(x,es,maxterms)
Test this function for x 3, s
1 x 10-5% and maxterms =100 using the following command
in Command Window:
[funcex, ea, terms]=Lab1Q3(3,1e-5,100)
The solution should be:
funcex =20.0855
ea =1.8076e-6
terms =18

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!