Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

EENG3190 MATLAB Assignment

Consider the truncated Maclaurin expansion:

  1-

≈ ∑   =  + x2  +  3  + ⋯ +  

 =1

(a)  Write a MATLAB function func(x,N)that returns the Maclaurin expansion using the first N

terms. Use the function to plot, func(x,2), func(x,4)and func(x,8)on the same axes,  together with the true value, x./(1-x), for - 0.5 < x < 0.5. Ensure the axes, title and curves are labelled.

 

(b)  The difference between the true value and the truncated Maclaurin series is 

∆ =  − ∑  

 =1

If x = 0.5 and N =1, 2, … , 10 then the difference, , as a function of N, could be written in MATLAB script as


x = 0.5;                                                    %set value for x

for N=1:10

delta (N) = x./(1-x)-func(x,N);         %Calculate difference

end;

Using the above MATLAB script, or otherwise, plot the difference, delta, as a function of N and hence determine the value of N where the error in the Maclaurin series is less than 0.1, at

x = 0.5. Ensure the axes, title and curves are labelled.