Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program Newtone;
- var a,b,eps,dx,x:real;
- i,Kmax: integer;
- Label 1;
- function f(x:real):real;
- begin
- f:=3*x-4*ln(x)-5;
- end;
- function fp(x:real):real;
- var D:real;
- begin
- D:=eps/100;
- fp:=(f(x+D)-f(x))/D;
- end;
- function f2p(x:real):real;
- var D:real;
- begin
- D:=eps/100.0;
- f2p:=(f(x+D)+f(x-D)-2*f(x))/sqr(D);
- end;
- begin
- writeln('input a ');
- readln(a);
- writeln('b');
- readln(b);
- writeln('eps');
- readln(eps);
- writeln('input kmax');
- readln(kmax);
- x:=b;
- if f(x)*f2p(x)<0 then
- x:=a;
- if f(x)*f2p(x)>0 then goto 1
- else
- begin
- writeln('dlya zadanoro rivnyannya zbizhnist ne garantuyetsa');
- readln;
- end;
- 1: for i:=1 to kmax do
- Begin
- dx:=f(x)/fp(x);
- x:=x-dx;
- if (abs(dx)<eps) then
- begin
- writeln('x=',x, ' i=',i);
- readln;
- end;
- End;
- end.
Add Comment
Please, Sign In to add comment