Subject: Maxima routine for False Position Method.
From: Luigi Marino
Date: Tue, 6 Jan 2009 09:11:19 +0100
Hallo Alexey
I send my work on bisection metod
with Maxima 5.17.1
Best wishes.
Luigi Marino.
Enter the two block separately:
segno(x):=block([], if x=0 then return(0) else (if x>0 then return(1) else return(-1) ) )$
bisez(funz,var,a,b,eps,numiter):=block([fa,fb,fc,c,l,k], define(f(var),funz),
fa:f(a), fb:f(b), l:abs(b-a), k:0, if segno(fa)#segno(fb) then do ( k:k+1, l:l/2.0,
c:ev(a+(b-a)/2.0,float), fc:f(c),
if (fc=0.0 or l<eps or k>numiter) then (print("c=",c," in ",k," iterazioni"),
return(fine)) else (if (segno(fa)*segno(fc)>0) then (a:c, fa:fc) else (b:c, fb:fc) ) ))$
Example:
m:log(x+1)-1/2*x^2+0.6;
bisez(m,x,1.0,2.0,0.000001,100);