Question: Here is a Taylor Series: , valid for . ( a ) Write a local function ( within the same function file - - see

Here is a Taylor Series: , valid for
.
(a) Write a local function (within the same function file -- see the template below) function z=my_fact(a) that computes the factorial of a number, e.g.:
. Do not use MATLAB's built-in factorial function, build your own from scratch, possibly but not necessarily using using a for loop. (Pro-tip, you can still compare the results of your function to MATLAB's in the command window to confirm it is working right.)
(b) The main function will be function [y,err]=trunc_err(x,N) which has as inputs: x, the value plugged-in to the above expression; and N, the number of terms in the Taylor Series. The outputs of this function are y, the evaluation of the Taylor Series at x through N terms; and err, the truncation error of the Taylor Series. You may use MATLAB's built-in sqrt to determine the "true value", and should report the err as a relative error (as a decimal, not a percentage).

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!