N
N
Nikita Kotov2018-09-22 12:20:06
Pascal
Nikita Kotov, 2018-09-22 12:20:06

Am I using the tangent(Newton) method correctly in pascal?

Good day! I am studying numerical methods and have problems with Newton's method. I took the equation x^4+4*x^2-3 for verification. The answer seems to give the correct one, but I'm not sure of my decision. Tell me what to add! Thanks a lot for your help in advance.

Program Newton1;

function f(x:real):real;
begin
  f:=x*x*x*x+4*x*x-3; {Здесь приводим выражение для вычисления функции }
end;   

function f1(x:real):real;  
begin 
  f1:=3*x*x*x+8*x; {Здесь приводим выражение для производной функции }
end;
   
var
  e, x: real;
  
begin
  write ('Начальное приближение:'); 
  readln(x);
  write ('Точность:'); 
  readln(e);

repeat
  x:=x- f(x)/f1(x);
until abs(f(x))< e;

  writeln ('x=',x:3:3,' f(x)=',f(x):4:4);
end.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question