Mã:
Clear[f, a, b, e, x1, Epxilon];
f[x_] = Input["Nhap f(x)"];
a = Input["Nhap a"];
b = Input["Nhap b"];
Epxilon = Input["Nhap vao sai so gan dung Epxilon"]; 
Print["Giai phuong trinh"];
Print["x = ", f[x]];
Print["Khoang cach li nghiem [", a, ",", b, "]"];
Print["Sai so gan dung Epxilon = ", Epxilon];
(*Phuong phap day cung *)
If[f[a] f[b] ≤ 0,
    		e = 1;
    		While[e > Epxilon ,
      			x1 = (a f[b] - b f[a])/(f[b] - f[a]);
      			If[f[a]f[x1] < 0, b = x1,  a = x1];
      			e = Abs[f[x1]];
      		];
    		Print["Nghiem gan dung x = ", N[x1]];
    	,
    		Print["[a,b] khong la khoang cach li nghiem"]
    ];