i was asked to develop a program that will evaluate a function for -0.9<x<0.9 in steps of 0.1 by arithmetic statement, and series allowing as many as 50 terms. however, end adding terms when the last term only affects the 6th significant in answer

답변 (2개)

Developing Taylor requires to compute the derivative :
x=-.9:.1:.9;
f=1./sqrt(1+x.^2);
g=1-1/2*(x.^2)+(1*3)/(2*4)*(x.^4)-(1*3*5)/(2*4*6)*(x.^6);
plot(x,g,x,f,'+r')
You can use a for-loop with a 'break' to generate successive terms and their sum. For each value of x you are required to use, get the corresponding f with
f = 1;
t = 1;
for k = 1:50
t = -(2*k-1)/(2*k)*x^2*t; % Iteratively compute successive terms
f = f + t; % Update the sum of the series
% Exit the for-loop when the current term, t, is too small
if abs(t) < ????
break
end
end

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2014년 11월 2일

답변:

2014년 11월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by