// Question 1

function R=dicho(f,a,b,k)
    x=a
    y=b
    i=1
    while y-x > 10^(-k)
        c=(x+y)/2
        i=i+1
        if f(x)*f(c) < 0
            y=c
        else
            x=c
        end
    end
    R=[x,y,i]
endfunction

// Question 2

function y=f(x)
    y=cos(x/2)
endfunction

// Question 4

function R=dekker(f,a,b,k)
    // x correspond à a_k ; y correspond à b_k ; z correspond à b_{k-1}
    x=a
    y=b
    z=a
    i=1
    
    while abs(x-y) > 10^(-k)
        s = y - f(y)*(y-z)/(f(y)-f(z))
        m = (x+y)/2
        z = y
        
       if (y < s & s < m) | (m < s & s < y)
           y=s
       else
           y=m
       end
       
       if f(x)*f(y) > 0
           x=z
       end
       
       if abs(f(x)) < abs(f(y))
           temp=x
           x=y
           y=temp
       end
       
       i=i+1  
    end
    R=[y,i]
endfunction

// Question 5

function y=g(x)
    y=x^x-1789
endfunction
