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

Laborator

This document describes a lab assignment on using the bisection method to find roots of equations. It provides two example equations and shows the step-by-step workings to find the roots using graphical analysis and a table. It then asks to verify the root intervals using Pascal programs and to combine the root localization and bisection methods into one program to find the roots of the two equations to a precision of 10-3, stating the number of roots, value of each root, and the interval containing it. Sample output is provided showing the results of running the combined program on the two equations.

Uploaded by

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

Laborator

This document describes a lab assignment on using the bisection method to find roots of equations. It provides two example equations and shows the step-by-step workings to find the roots using graphical analysis and a table. It then asks to verify the root intervals using Pascal programs and to combine the root localization and bisection methods into one program to find the roots of the two equations to a precision of 10-3, stating the number of roots, value of each root, and the interval containing it. Sample output is provided showing the results of running the combined program on the two equations.

Uploaded by

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

Lucrare de laborator N1

Tema: Metoda dihotomiei


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

a) x3-1.13*x2-1.87*x+2.13=0
x -2 -1 0 1 2
y1 -8 -1 0 1 8
y2 -1.35 -2.87 -2.13 0.87 6.13

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


x1 -2 -1 -6.65 1.87 -12.4355

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


-2 -1 -1.5 -6.65 1.87 -0.9825 6.533625 -1.837275 FA
-1.5 -1 -1.25 -0.9825 1.87 0.74875 -0.735646875 1.4001625 FA
-1.5 -1.25 -1.375 -0.9825 0.74875 -0.034765625 0.034157227 -0.026030762 FA
-1.375 -1.25 -1.3125 -0.034765625 0.74875 0.376787109 -0.013099239 0.282119348 FA
-1.375 -1.3125 -1.34375 -0.034765625 0.376787109 0.176051025 -0.006120524 0.066333757 FA
-1.375 -1.34375 -1.359375 -0.034765625 0.176051025 0.071914215 -0.002500143 0.012660571 FA
-1.375 -1.359375 -1.3671875 -0.034765625 0.071914215 0.018893604 -0.000656848 0.001358719 FA
-1.375 -1.3671875 -1.37109375 -0.034765625 0.018893604 -0.007856004 0.000273119 -0.000148428 FA
-1.37109375 -1.3671875 -1.369140625 -0.007856004 0.018893604 0.005538779 -4.35127E-05 0.000104648 FA
-1.37109375 -1.369140625 -1.370117188 -0.007856004 0.005538779 -0.001153615 9.0628E-06 -6.38962E-06 FA
-1.370117188 -1.369140625 -1.369628907 -0.001153618 0.005538779 0.002193829 -2.53084E-06 1.21511E-05 FA
-1.370117188 -1.369628907 -1.369873048 -0.001153618 0.002193826 0.000520416 -6.00362E-07 1.1417E-06 TR
Deci x1= -1.369873048
epsilon= 0.001

b) 13*lgx - 15/ x2 = 0;
x 1 2 3 4 5
y1 0 3.913389944 6.202576311 7.826779887 9.086610056
y2 15 3.75 1.666666667 0.9375 0.6

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


x1 1 2 -15 0.163389944 -2.450849154

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


1.5 2 1.75 -4.377480299 0.163389944 -1.738464551 7.610094321 -0.284047625 FALS
1.75 2 1.875 -1.738464551 0.163389944 -0.71765013 1.247609311 -0.117256814 FALS
1.875 2 1.9375 -0.71765013 0.163389944 -0.261695424 0.187805755 -0.042758401 FALS
1.9375 2 1.96875 -0.261695424 0.163389944 -0.045515017 0.011911072 -0.007436696 FALS
1.96875 2 1.984375 -0.045515017 0.163389944 0.059821092 -0.002722758 0.009774165 FALS
1.96875 1.984375 1.9765625 -0.045515017 0.059821092 0.007377094 -0.000335769 0.000441306 FALS
1.96875 1.9765625 1.97265625 -0.045515017 0.007377094 -0.019012547 0.000865356 -0.000140257 FALS
1.97265625 1.9765625 1.974609375 -0.019012547 0.007377094 -0.005803673 0.000110343 -4.28142E-05 FALS
1.974609375 1.9765625 1.975585938 -0.005803673 0.007377094 0.000790217 -4.58616E-06 5.82951E-06 TRU

epsilon= 0.001

Deci x1= 1.975585938

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.13*x*x+1.87*x+2.13;{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:=13*log10(x) - 15/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
-13
13
0.13
[ -0.7800; -0.6500]

B)introdu extrema segmentului a si b, pasul h


-13
13
0.13
[ 1.9500; 2.0800]

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.13*x*x+1.87*x+2.13;{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:=13*log10(x) - 15/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: -13
13
0.13
1 radacina a ecuatiei apartine segmentului:[-0.780;-0.650]
radacina=-0.684436radacina=-0.676807
b)
Localizarea si precizarea radacinilor
introdu datele a,b,h: 13
0.13
-13
1 radacina a ecuatiei apartine segmentului:[13.000; 0.000]
radacina=1.975460

You might also like