Newton Divided Difference Method
Mostra commenti meno recenti
I'm writing a code for interpolation using Newton's method. The code works but it gave me a different value. When I enter f(x) = log(x), x0=1, it gave me y=1 which is wrong. Can anyone help me?
syms x
d = input('enter f(x)= \n')
f=inline(d);
z=diff(f(x));
f1=inline(z);
x0=input('inter x0 = \n')
x=x0
for u=0:inf
y=x
x=y-(f(x)/f1(x));
if x==y
break
end
end
enter f(x)=
log(x)
d =
log(x)
inter x0 =
1
x0 =
1
x =
1
Warning: FOR loop index is too large. Truncating to 9223372036854775807.
y =
1
>>
Risposte (1)
Walter Roberson
il 2 Mar 2012
0 voti
Change the "for" to "while true"
1 Commento
Akmal
il 2 Mar 2012
Categorie
Scopri di più su Linear Algebra 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!