PHƯƠNG PHÁP SỐ GIẢI PHƯƠNG TRÌNH PHI TUYẾN
program giai_phuong_trinh_phi_tuyen;
uses crt;
var x0,x,eps,ss,fx,dfx: real;
i:integer;
{----------------------------------------------------------}
{ viet chuong trinh con tinh ham F(x) }
Function F(x: real) : real;
var a: real;
begin
a:= Ln(x)/Ln(10) - Cos(x);
F:=a;
end;
{----------------------------------------------------------}
{ viet chuong trinh con tinh ham dF(x) }
Function dF(x: real) : real;
var b: real;
begin
b:= (1/x)*(1/Ln(10))+Sin(x);
dF:=b;
end;
{----------------------------------------------------------}
{ viet thuc tuc thuc: hien chuong trinh NEWTON }
Procedure NEWTON;
{ khoi kiem tra dieu kien cua EPSILON }
begin
repeat
write(' Nhap vao Epsilon = ');
readln(eps);
if (eps<0) or (eps>1) then
begin
write(' Nhap sai, hay nhap lai');
writeln;
end;
until (eps>0) and (eps<1) ;
{ khoi hoi nhap vao gia tri dau cua X}
write(' Nhap vao gia tri dau cua X= ');
readln(x);
{ khoi vong lap thuc hien thuat toan NewTon}
write(' Gia tri dau cua X = ',x:8:6);
writeln;
write('Lan lap : ', i);
write(' Fx= ',F(x):8:6 );
write(' dFx= ',dF(x):8:6 );
writeln;
for i:=1 to 50 do
begin
fx:=F(x);
dfx:=dF(x);
x:=x-fx/dfx;
ss:=Abs(x0-x);
x0:=x;
if ss> eps then
begin
writeln('-------------------------');
writeln('LanLap:',i);
writeln('X=',x:8:6);
writeln('Fx=',F(x):8:6);
writeln('dFx=',dF(x):8:6);
end;
if ss<= eps then break;
end;
end;
{---------------------------------------------------------}
{ than chuong trinh chinh}
BEGIN
CLRSCR;
writeln(' Giai phuong trinh phi tuyen ');
writeln('-------------------------------------------');
writeln;