Programe dihotomia, coarde, tangente

program dihotomiapolovinogodeleniya;
var
a,b,c: real;
i,n:integer;
function f(x:real):real;
begin
f:=(-x*x+Power(3,x-ln(3*x*x-2*x+7)))/(4*x*x-x+12);  {MODIFICATIFUNCTIA AICI}
end;
begin
a:=10; b:=15;          {MODIFICATI INTERVALUL AICI}
n:=5;                    {MODIFICATI NUMARUL DE Divizari  AICI}
for i:=1 to n do
begin
c:=(b+a)/2;
writeln('i=',i:3,' x=',c:10:8,' f(x)=',f(c):12:8);
if f(c)=0 then break
else if f(c)*f(a)>0 then a:=c else b:=c;
end;
end.

program coarde;
var    a,b,e,c,x: real;
n,i: integer;
function f(x:real):real;
begin  f :=ln(x*sin(x));end;
begin a:=0.5;  b:=1.5; n:=10;
c:=a-(f(a))/(f(b)-f(a))*(b-a);
if f (c)*f(a)>0 then begin e:=b; x:=a; end
else begin e:=a; x:=b; end;
for i:=1 to n do
begin x:= x-(f(x))/(f(e)-f(x))*(e-x);
writeln('i=',i:2,' x= ',x:10:8,' ', f (x):12:8 ) ;
end;
end.


       program tangente_kastelinih;
var a, b,  x,  c : real;
i,   n: integer;
function f(z :real)   :real;
begin f:=z*z*z-2*z*z+z-3; end;
function fdl(z:real):real;
begin fdl:=3*z*z-4*z+1; end;
begin     a:=2.1; b:=15;  n:=10; i:=0;
c:=a-(f(a))/(f(b)-f(a))*(b-a);
if f(c)*f(a)<0 then x:=a else x:=b;
while i<n do
begin i:=i+1;
x:=x-f(x)/fdl(x);
writeln('i=',i:2,'  x=',x:15:12,  '  f=',f (x):15:12);
end;
end.


program tangente_касательных_error;
var a, b,  xn,  xv, M2, ml,  e,  c : real;
i, n: integer;
function f(z:real):real;
begin f:=cos(z)*cos(z)-z/4; end;
function fdl(z:real):real;
begin fdl:=-sin(2*z)-1/4; end;
begin      a:=2.4; b:=3; M2:=2; ml:=0.03; e:=0.0001;
c:=a-(f(a))/(f(b)-f(a))*(b-a);
if f(c)*f(a)<0 then begin
xn:=a; xv:=b;
end
else begin xn:=b; xv:=a; end;
while M2*sqr(xn-xv)/(2*ml)>e do
begin xv:=xn;
xn:=xv-f(xv)/fdl(xv);
writeln(  'x=',xn:15:12,  '  f=',f(xn):15:12);
end;
end.

ComentariiReinoieste comentariile

 
admin 13:15 25 11 2013
http://www.derivative-calculator.net
 

Logare

Utilizator:
Parola:
Retine-ma
Inregistrare