daniv1

Untitled

Nov 9th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.89 KB | None | 0 0
  1. Program Newtone;
  2.         var a,b,eps,dx,x:real;
  3.         i,Kmax: integer;
  4.  
  5. Label 1;
  6.       function f(x:real):real;
  7.                begin
  8.                f:=3*x-4*ln(x)-5;
  9.       end;
  10.  
  11.  
  12. function fp(x:real):real;
  13. var D:real;
  14.     begin
  15.          D:=eps/100;
  16.          fp:=(f(x+D)-f(x))/D;
  17.          end;
  18.  
  19.  
  20. function f2p(x:real):real;
  21. var D:real;
  22.     begin
  23.          D:=eps/100.0;
  24.          f2p:=(f(x+D)+f(x-D)-2*f(x))/sqr(D);
  25. end;
  26.  
  27. begin
  28. writeln('input a ');
  29. readln(a);
  30. writeln('b');
  31. readln(b);
  32. writeln('eps');
  33. readln(eps);
  34. writeln('input kmax');
  35. readln(kmax);
  36. x:=b;
  37.      if f(x)*f2p(x)<0 then
  38.      x:=a;
  39.      if f(x)*f2p(x)>0 then goto 1
  40.         else
  41. begin
  42. writeln('dlya zadanoro rivnyannya zbizhnist ne garantuyetsa');
  43. readln;
  44. end;
  45. 1: for i:=1 to kmax do
  46. Begin
  47. dx:=f(x)/fp(x);
  48. x:=x-dx;
  49. if (abs(dx)<eps) then
  50. begin
  51. writeln('x=',x, ' i=',i);
  52. readln;
  53. end;
  54. End;
  55. end.
Add Comment
Please, Sign In to add comment