Category : Pascal Source Code
Archive   : ENGR.ZIP
Filename : NEWDR2.PAS
var x,x2 : real;
alldone : boolean;
error : boolean;
procedure func(x: real;
var fx,dfx: real);
begin
fx:=x*x-2.0;
dfx:=2.0*x
end; { func }
procedure newton(var x: real);
const tol = 1.0E-6;
var fx,dfx,dx,x1: real;
begin { newton }
repeat
x1:=x;
func(x,fx,dfx);
dx:=fx/dfx;
x:=x1-dx;
writeln('x=',x1,',fx=',fx,',dfx=',dfx);
until abs(dx)<=abs(tol*x)
end; { newton }
begin { main program }
alldone:=false;
repeat
writeln;
write('First guess: '); { first guess }
readln(x);
if x<-19.0 then alldone:=true
else
begin
newton(x);
writeln;
writeln('The solution is ',x);
writeln
end
until alldone
end.
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/