フィルターのクリア

MATLAB HELP to write a function.

3 ビュー (過去 30 日間)
Brandon
Brandon 2014 年 9 月 21 日
編集済み: Rick Rosson 2014 年 9 月 21 日
Hello, I have this problem as a practice question for a class. I am new to MATLAB, and I have no idea how to even start, can someone please help me? thanks
The Maclaurin series expansion for cos(x) is: cosx = 1 - x^2/2! + x^4/4! - x^6/6! + ...... Starting with the simplest version, cosx = 1, add terms one at a time to estimate cos(pi/4). After each new term is added, compute the true and approximate percent relative errors. Add terms until the absolute value of the approximate error estimate falls below and error criterion conforming to two significant figures.

回答 (2 件)

Image Analyst
Image Analyst 2014 年 9 月 21 日
Maybe try a for loop
theSum = 1;
for k = 2 : 2 : 1000
theSum = theSum - (-1)^k * ........ % See if you can complete the lines.
theError = theSum - cos(...........
if theError < .............
% some code......
end
end

Rick Rosson
Rick Rosson 2014 年 9 月 21 日
編集済み: Rick Rosson 2014 年 9 月 21 日
Here's a start:
x = pi/4;
ideal = cos(x);
approx = 1;
k = 0;
while ( abs(approx - ideal) > ... )
k = k + 2;
approx = approx + ...
...
...
end

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by