//f(x):=2*x^4-10*x^3-4*x^2+100 //fibomin(f,1,5,0.000001) //g(x):=2*x^4-10*x^3+4*x^2+100 //fibomin(g,1,5,1e-20) //calcul la valeur du min d'une fonction ayant un seul extrema sur [a,b] fibomin(f,a,b,eps):={ local c,d,F,k,n,t,g,h,l,fc,fd; if (a>b) {c:=a;a:=b;b:=c;} k:=ceil(2*(b-a)/eps); F:=1,2; n:=1; g:=1; t:=2; //construction de F=la suite de Fibonacci //h,g,t sont 3 termes consecutifs de F while (t<k) { n:=n+1; h:=g; g:=t; t:=h+g; F:=F,t; } l:=(b-a)/t; c:=a+h*l; d:=a+g*l; fc:=f(c); fd:=f(d); //on itere le processus et on s'arrete qd n=1 while (n>1) { if (fc>fd) { a:=a+h*l; fc:=fd; t:=h; h:=g-h; g:=t; fd:=f(a+g*l); n:=n-1; }else{ if (fc<fd) { b:=a+g*l; t:=h; h:=g-h; g:=t; fd:=fc; fc:=f(a+h*l); n:=n-1; }else{ a:=a+h*l; b:=b-h*l; t:=g-h; g:=h-t; h:=t-g; fc:=f(a+h*l); fd:=f(a+g*l); n:=n-3; } } } return [a,b]; }On tape :
^
4-10
^
4-10*x^
3-4*x^
2+100
^
4-10*x^
3+4*x^
2+100