// Méthode de la dichotomie 

function zero = dichoto(f,a,b,nbetap)
    zero = []
    x0 = a
    x1 = b    
    for i=1:nbetap
        x2 = (x0+x1)/2
        if f(x0)*f(x2)<=0 then 
           x0 = x2              
        else   
           x1 = x2 
        end
        zero = [zero, x2] 
    end
endfunction


// Méthode de la secante 

function zero = secante(f,x0,x1,nbetap)
    zero = [x0]
    zero = [zero, x1]          
    for i=1:nbetap-1
        if (abs(x0-x1)>=1E-7) then
            x2 = x1 - (x1-x0)*f(x1)/(f(x1)-f(x0))           
        end  
        zero = [zero, x2] 
        x0 = x1
        x1 = x2
    end
endfunction

// Méthode de Newton

function zero = newton(f,ff,x0,nbetap)
    zero = [x0]
    for i=1:nbetap
        x1 = x0 - f(x0)/ff(x0)
        zero = [zero, x1] 
        x0 = x1
    end
endfunction

function zero = newtonbis(f,ff,x0,nbetap)
   
    for i=1:nbetap
        x1 = x0 - f(x0)./ff(x0)
        
        x0 = x1
    end
    zero = x1
endfunction
