Hey im trying to find the secant method.
I am trying to modify my newton's code, but am not getting anywhere.
Here is the code I am using for newton's.
>> format long
>> c=1
c =
1
>> n=0;
>> x=1.5;
>> f=@(x) ((x)^4-c);
>> fder=@(x) (4*(x)^3);
>> while n<100
newx=x-(f(x)/fder(x));
n=n+1
x=newx
end
The secant formula is xn+1=xn-(xn-xn-1)*f(xn)/f(xn)-f(xn-1).
Thus I need two points. Can someone please write out a nice matlab code that I can use (with say two points being 1.5, and 1.3)?
thanks


LinkBack URL
About LinkBacks