How do I properly code a Taylor Series for tan(x)?

6 次查看(过去 30 天)
In terms of tan(x) with a=0, how would I code the approximation of a Taylor Series from n = 1:4? I get it on paper, but I can't seem to wrap my head around the Matlab code.
  3 个评论
George Caspelli
George Caspelli 2021-3-11
I deleted my Matlab code, but I yeah I can send a picture of my work on paper. I forgot to include that I want to find the approximation at x = pi/4.
Here's a general idea of the direction I went with my Matlab code. I was planning to create a variable n and have the multiple derivatives calculated at diff(f,n), but I wasn't able to figure that out.
syms x
f = tan(x)
diff(f)
vpa(subs(f,x,pi/4))
Hope this helps!
John D'Errico
John D'Errico 2021-5-7
If you say you deleted your code, then you may have as easily not written any code at all. How should we know that you are telling the truth?

请先登录,再进行评论。

回答(1 个)

Mouhamed Niasse
Mouhamed Niasse 2021-5-7
try this
order=4; value=pi/4;
syms T1(x)
T1(x) = taylor(tan(x), x, 'Order', order)
vpa(T1(value))

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

标签

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by