Solving a taylor serie with matlab. Homework question
Mostra commenti meno recenti
Taylor serie of ln x:
ln x = (x − 1) − ((x − 1)^2)/ 2 + ((x − 1)^3)/ 3 − . . .
I need to find an approximately value of ln 3. The question suggested that we should replace x with 1/3 and then take the sum of all terms with absolute value bigger than 1e-8.
The questions suggested solution:
tol=1e-8; s=0; i=0;
term=;
while abs(term) > tol
s=s+term;
i=i+1;
term=...;
end
disp(-s)
What i've tried
tol=1e-8; s=0; i=1;
term = -2./3;
while abs(term) > tol
s = s + term;
i=i+1;
term = ((-2./3).^i)./i;
end
disp(-s)
My code gives the answear 0.51. The answear to ln 3 is 1.098...
How do i solve this?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Perform Sensitivity Analysis in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!