//Les constantes

A=0.1;
B=0.7;
R=0.25;
T=30;
r=log(2)/T;
to=21;
init=10^5;
initRes=0;

//Les fonctions

function w=g(x)
    y1=floor(x);
    if(modulo(y1,to)==0 & y1>0)then
        y1=y1-1;
    end
    
    while modulo(y1,to)~=0
        y1=y1-1;
    end
    if(x==0) then
        w=init;
    elseif(modulo(x,to)==0) then
        w=A*exp(r*to)*g(y1);
    else
        w=g(y1)*exp(r*x);
    end
endfunction



function z=h(x)
     x1=floor(x);
     if(modulo(x1,to)==0 & x1>0)then 
         x1=x1-1;
     end
     
     while modulo(x1,to)~=0
         x1=x1-1;
     end
     
     
     if(x==0) then
         z=initRes;
     elseif(modulo(x,to)==0) then
         z=(1-A)*R*exp(r*to)*g(x1)+B*exp(r*to)*h(x1);
     else
         z=h(x1)*exp(r*x);
     end
     
endfunction

function y=f(x)
     y=g(x)+h(x);
endfunction 


function v=i(x)
     v=exp(r*x)*init;
endfunction 

x=linspace(0,100,100);
plot(x,i)
