function p=secant(FUN,p0,p1,TOL,N);
%%
%%  Function p=secant(FUN,p0,p1,TOL,N)
%%
%%  This method is to find a solution to f(x)=0 given intial approximations p0
%%  and p1
%%
%%  INPUT:
%%  FUN  - the given function to be solved  which is entered as
%%           a string, enclosed in ' ', with the name the m-file of the 
%%           function.
%%  p0,p1 -  the intial approximation
%%  TOL -  the tolerance
%%  N - the maximum number of iteration
%%
%%  OUTPUT :
%%  p - approximat solution 
%%  or message of failure
q0=feval(FUN,p0);
q1=feval(FUN, p1);
i=2;
while i<=N
    p=p1-q1*(p1-p0)/(q1-q0)
    if abs(p-p1)<TOL
       break;
    end;
    i=i+1;
    p0=p1;
    q0=q1;
    p1=p;
    q1=feval(FUN,p);
end;
i    
if i>N
   massage='this method failed after N iteration'
end;
