MATLAB Answers

Taylor series Approximation of x*cos(x) at x = 2pi/3

5 views (last 30 days)
Thiago Augusto Borges Rodrigues
Answered: Divya Yerraguntla on 13 Jan 2020
I am trying to solve a how many terms of Macclaurin Serie are necessary to approximate f(2pi/3) into 10^-4 correct result. My results do not look right and I was not able to do the correct approximation. Can somebody help me?

  3 Comments

James Tursa
James Tursa on 9 Jan 2020
Sure, we can help with that. Can you show us what you have done so far and descirbe the problems you seem to be having and why things don't look right to you?
Thiago Augusto Borges Rodrigues
Yes, I can show. First, I tried to find the error (code below). I manage to do it right, but I would not be able to find how many terms, considering the general taylor series formula.
>> syms x
>> f=inline('x*cos(x)');
>> T12 = taylor(f(x),x,0,'order',12);
>> T12x1 = subs(T12,x,2*pi/3);
>> eval (T12x1) - f(2*pi/3)
ans =
-3.041044905072177e-05
Thiago Augusto Borges Rodrigues
Hey guys, maybe I did something wrong on my code. But, is there any other possiblity of help here? Thank you in advance.

Sign in to comment.

Answers (1)

Divya Yerraguntla
Divya Yerraguntla on 13 Jan 2020
Hi,
I'm assuming you want to know the number of terms in the T12 expression.
To do this you could use the function children which takes T12 as input and returns the terms of T12 in an array. You could find the number of terms in the array by using :
length(children(T12));
Hope it helps!

  0 Comments

Sign in to comment.

Categories


Translated by