Question

The Taylor polynomial approximation pn (r) for f(x) = sin(x) around x,-0 is given as follows: TL 2k 1)! Write a MATLAB functi

0 0
Add a comment Improve this question Transcribed image text
Answer #1

function p=taylor_sin(x,n)

fprintf('given value of n =%d\n',n); % Print value of n

for k=0:n % Loop to vary k from 0 ,1 ,2 ,3

for i=1:61 % loop to vary x from -3:0.1:3

  

terms(i) = (-1)^(k)*(x(i)^(2*k+1))/factorial(2*k+1); % Taylor's apx.

end

t(k+1) = sum(terms) % calculate sum of all terms

% E = abs((sin(x)-SINx)/sin(x));

figure(k+1)

plot(terms,x)

end

end

octave:3> taylor_sin(-3:0.1:3, 3)
given value of n =3
t =    1.7764e-15


 

3 2 L-2 3 3 2 0 24 3 2 04 3 2 02 -1 -2 -0.8 0.6 0.4 -0.2 0.2 0.4 0.6 0.8


 
Add a comment
Know the answer?
Add Answer to:
The Taylor polynomial approximation pn (r) for f(x) = sin(x) around x,-0 is given as follows: TL ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT