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

Risposte (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

Categorie

Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange

Richiesto:

il 2 Nov 2014

Risposto:

il 2 Nov 2014

Community Treasure Hunt

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

Start Hunting!

Translated by