Matlab code for Maclaurin series expansion using cos(x) =1 and iterating adding a term at a time until I have an estimate for Cos(pi/3)?

11 ビュー (過去 30 日間)
Sterlin
Sterlin 2013 年 9 月 18 日
回答済み: Nikhil 2024 年 10 月 3 日
What is a good way to write the Maclaurin series expansion for cos(x), beginning with cos(x)=1 and adding terms one at a time to estimate cos(pi/3)? I want to also return the estimate at each iteration.

回答 (2 件)

James Tursa
James Tursa 2013 年 9 月 18 日
Google Maclaurin expansion of cosx
Go to the first link
Scroll to the bottom of the page.
Look at the pattern for successive terms and code that up.

Nikhil
Nikhil 2024 年 10 月 3 日
syms x
myfun=cos(x);
x0=0;
N=6;
y0=subs(myfun,x0);
y=y0
forn=1:N
forn = 1×6
1 2 3 4 5 6
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
derivative=diff(myfun,n);
Unrecognized function or variable 'n'.
y=((x-xx0)^n/factorial(n)*subs(derivative,x0));

カテゴリ

Help Center および File ExchangeCode Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by