Mã:
Clear[f, f1, a, b, x0, e, x1, t, 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 tiep tuyen*)
f1[x_] = D[f[x], x];
x1 = (a + b)/2;
e = 1;
t = True;
While[e > Epxilon && t == True,
    	x0 = x1;
    	If[f1[x0] == 0, t = False, x1 = x0 - f[x0]/f1[x0]];	
    	e = Abs[x1 - x0];
    ];
If[t == False,
    		Print["f[x] khong lien tuc trong khoang [a,b]"];
    	,
    		Print["Nghiem gan dung x = ", N[x1]];
    ];