0% found this document useful (0 votes)
34 views

Laborator

The document describes using the bisection method to find the roots of equations. It provides two examples of equations and shows the step-by-step workings to locate the roots within certain intervals using bisection. A Pascal program is given to automate the root finding process for each equation. Finally, a combined program is presented to both locate roots within intervals and refine the results to within a specified precision of 0.001. The program outputs the number of roots found, the interval containing each root, and the refined root value.

Uploaded by

Carolina Costas
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Laborator

The document describes using the bisection method to find the roots of equations. It provides two examples of equations and shows the step-by-step workings to locate the roots within certain intervals using bisection. A Pascal program is given to automate the root finding process for each equation. Finally, a combined program is presented to both locate roots within intervals and refine the results to within a specified precision of 0.001. The program outputs the number of roots found, the interval containing each root, and the refined root value.

Uploaded by

Carolina Costas
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

Lucrare de laborator N1

Tema: Metoda dihotomiei


Subiectul 1. Să se localizeze, aplicând metoda grafică, rădăcinile ecuaţiilor.

a) x3-1.1*x2+1.9*x+2.1=0
x -2 -1 0 1 2
y1 -8 -1 0 1 8
y2 -1.5 -2.9 -2.1 0.9 6.1

a b f(a) f(b) f(a)*f(b)<0


x1 -2 -1 -6.5 1.9 -12.35

a b c f(a) f(b) f(c) f(a)*f(c)<0 f(c)*f(b)<0 f(c)<e


-2 -1 -1.5 -6.5 1.9 -0.9 5.85 -1.71 FALSE
-1.5 -1 -1.25 -0.9 1.9 0.803125 -0.7228125 1.5259375 FALSE
-
-1.5 -1.25 -1.375 -0.9 0.803125 0.033203125 0.029882812 0.02666626 FALSE
-
-1.5 -1.375 -1.4375 -0.9 0.033203125 -0.412255859 0.371030273 0.013688183 FALSE
-
-1.4375 -1.375 -1.40625 -0.412255859 0.033203125 -0.184332275 0.075992061 0.006120408 FALSE
-
-1.40625 -1.375 -1.390625 -0.184332275 0.033203125 -0.074277496 0.01369174 0.002466245 FALSE
-
-1.39063 -1.375 -1.382815 -0.074312301 0.033203125 -0.020234043 0.001503638 0.000671833 FALSE
-
-1.38282 -1.375 -1.37891 -0.020268437 0.033203125 0.006547404 0.000132706 0.000217394 FALSE
-
-1.38282 1.37891 -1.380865 -0.020268437 0.006547404 -0.006840479 0.000138646 -4.47874E-05 FALSE
-1.38087 - -1.37989 -0.006874771 0.006547404 -0.000158651 1.09069E-06 -1.03875E-06 TRUE
1.37891

epsilon= 0.001
Deci x1= -1.37989

b) 10lgx - 12/ x2 = 0;
x 1 2 3 4 5
6.98970004
y1 0 3.010299957 4.771212547 6.020599913 3
y2 12 3 1.333333333 0.75 0.48

a b f(a) f(b) f(a)*f(b)<0


x1 1 2 -12 0.010299957 -0.12359948

a b c f(a) f(b) f(c) f(a)*f(c)<0 f(c)*f(b)<0 f(c)<e


- -
3.57242074 42.8690489 0.03679577
1 2 1.5 -12 0.010299957 3 1 9 FALSE
- 5.31571512
1.5 2 1.75 3.572420743 0.010299957 -1.48798686 4 -0.0153262 FALSE
- -
0.68332061 1.01677209 0.00703817
1.75 2 1.875 -1.48798686 0.010299957 3 3 3 FALSE
- -
- 0.32425302 0.22156877 0.00333979
1.875 2 1.9375 0.683320613 0.010299957 3 5 2 FALSE
- -
- 0.15408824 0.04996357 0.00158710
1.9375 2 1.96875 0.324253023 0.010299957 2 8 2 FALSE
- -
- 0.07119262 0.01096994 0.00073328
1.96875 2 1.984375 0.154088242 0.010299957 5 6 1 FALSE
1.984375 2 1.9921875 - 0.010299957 -0.03027344 0.00215524 - FALSE
0.00031181
0.071192625 6 5
- -
0.00994382 0.00030103 0.00010242
1.9921875 2 1.99609375 -0.03027344 0.010299957 4 4 1 FALSE
- 0.00018875 -1.87698E-
1.99609375 2 1.998046875 0.009943824 0.010299957 8 06 1.9442E-06 TRUE

epsilon= 0.001
Deci x1= 1.998046875

Subiectul 2. Utilizând metoda analitică de localizere a rădăcinilor, s ă se verifice şi să


se concretizeze segmentele care conţin rădăcinile ecuaţiilor din Subiectul 1, folosind
programele Pascal.

A)Program local;
var a,c,b,h,x1,x2:real;
function fnl(x:real):real;

begin

fnl:=x*x*x-1.1*x*x+1.9*x+2.1;{fnl:=cos(x)-x*x;}
end;

begin

writeln('introdu extrema segmentului a si b, pasul h'); readln(a,b,h);


x1:=a;x2:=x1+h;
while x2<=b do begin

if fnl(x1)*fnl(x2)<0 then writeln('[',x1:12:4,';',x2:12:4,']'); x1:=x2;

x2:=x1+h;

end;
end.

b)Program local;
var a,c,b,h,x1,x2:real;
function fnl(x:real):real;

begin

fnl:=10*log10(x) - 12/power(x,2);{fnl:=cos(x)-x*x;}
end;

begin

writeln('introdu extrema segmentului a si b, pasul h'); readln(a,b,h);


x1:=a;x2:=x1+h;
while x2<=b do begin

if fnl(x1)*fnl(x2)<0 then writeln('[',x1:12:4,';',x2:12:4,']'); x1:=x2;

x2:=x1+h;

end;
end.
Rezultatele:
A)introdu extrema segmentului a si b, pasul h
-10
10
0.1
[ -0.7000; -0.6000]

B)introdu extrema segmentului a si b, pasul h


-10
10
0.1
[ 1.9000; 2.0000]

Subiectul 3. Să se unifice într-un program metoda localizării rădăcinilor şi metoda


-3
înjumătăţirii. Să se soluţioneze ecuaţiile din Subiectul 1, cu precizia E = 10 ,
evidenţiind numărul rădăcinilor, rădăcina şi segmentul care o conţine.

A)Program Localizare_Precizare;
const e=1E-4;

var x1,x2,y1,y2,x,a,b,h:real;
r:integer;

Function fnl(x:real):real;

begin
fnl:=x*x*x-1.1*x*x+1.9*x+2.1;{fnl:=cos(x)-x*x;}

end;
procedure precizare(x1,x2:real);

var c,r1:real;

begin
while abs(x2-x1)>e do begin

c:=(x1+x2)/2;

if fnl(x1)*fnl(c)<0 then x2:=c else x1:=c; end;


r1:=(x2+x1)/2;

writeln('radacina=',r1:6:6);end;

begin

writeln('Localizarea si precizarea radacinilor'); write('introdu datele a,b,h: ');


readln(a,b,h);
x1:=a;
x2:=x1+h;

while x2<=b do begin

if fnl(x1)*fnl(x2)<0 then begin


r:=r+1;

writeln(r,' radacina a ecuatiei apartine segmentului:','[',x1:6:3,';',x2:6:3,']');


precizare(x1,x2);end;

x1:=x2;

x2:=x1+h;
end;
end.

B)Program Localizare_Precizare;
const e=1E-4;

var x1,x2,y1,y2,x,a,b,h:real;
r:integer;

Function fnl(x:real):real;

begin
fnl:=10*log10(x) - 12/power(x,2);{fnl:=cos(x)-x*x;}

end;
procedure precizare(x1,x2:real);

var c,r1:real;

begin
while abs(x2-x1)>e do begin

c:=(x1+x2)/2;

if fnl(x1)*fnl(c)<0 then x2:=c else x1:=c; end;


r1:=(x2+x1)/2;

writeln('radacina=',r1:6:6);end;

begin

writeln('Localizarea si precizarea radacinilor'); write('introdu datele a,b,h: ');


readln(a,b,h);
x1:=a;
x2:=x1+h;

while x2<=b do begin

if fnl(x1)*fnl(x2)<0 then begin


r:=r+1;

writeln(r,' radacina a ecuatiei apartine segmentului:','[',x1:6:3,';',x2:6:3,']');


precizare(x1,x2);end;

x1:=x2;

x2:=x1+h;
end;
end.

Rezultatele:
a)
Localizarea si precizarea radacinilor
introdu datele a,b,h: -10
10
0.1
1 radacina a ecuatiei apartine segmentului:[-0.700;-0.600]
radacina=-0.676807
b)
Localizarea si precizarea radacinilor
introdu datele a,b,h: -10
10
0.1
1 radacina a ecuatiei apartine segmentului:[ 1.900; 2.000]
radacina=1.99799

You might also like