Documente Academic
Documente Profesional
Documente Cultură
Laborator 3
Laborator 3
Facultatea
Calculatorare, Informatic i Microelectronic
Catedra
Informatic Aplicat
Chiinu 2013
Sarcina 1
Sarcina:
a) Pentru ambele tipuri de ecuaii s se separe un interval prin una din metodele cunoscute
(irul lui Roll, turm, metoda grafic sau numeric )
Dihotomei (biseciei)
Tangentelor (Newton)
Coardelor
Remarc: fiecare din metodele de mai sus vor fi realizate prin o unitate de program cunoscut.
Ecuaia 1
x 3 0,1x 2 + 0,4 x 1,5 = 0
Pentru a gsi intervalul funciei vom utiliza metoda irului lui turm. Prin urmare:
x
x
-
+
-2
-1
0
1
2
3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
3
0
1
1
1
1
0
0
Din tabelul de mai sus am gsit intervalul [1;2] pentru care funcia are o soluie real.
a) Pentru intervalul gsit rezolvm numeric f(x)=0 cu precizia
1 = 0,01
2|Page
program bisectie;
uses crt;
Biseciei:
var a,b,c,eps: real;
Rezultatele obinute pentru :
function
f(x:real):real;
program
bisectie;
1 = 0,01
usesbegin
crt; f:= x*x*x-0.1*x*x+0.4*x-1.5 end;
varbegin
a,b,c,eps: real;
function f(x:real):real;
clrscr;
begin
clrscr;
repeat
2 = 0,0001
c:=(b+a)/2;
writeln('x=',c:10:8,' f(x)=',f(c):12:8);
Coardelor:
program coarde;
uses crt;
var a,b,c,e,x,xnou,msup,minf,xvechi,eps:real;
program newton ;
function f(x:real):real;
uses crt;
begin f:= x*x*x-0.1*x*x+0.4*x-1.5; end;
var a, b, xn, xv, e, c: real;
begin
i, n: integer;
clrscr;
function f(x:real):real;
a:=1; b:=2; eps:=0.01;
begin f:= x*x*x-0.1*x*x+0.4*x-1.5; end;
minf:=1; msup:=0;
1 = 0,01
2 = 0,0001
x:=a-(f(a))/(f(b)-f(a))*(b-a);
function fd1(x:real):real;
if f(x)*f(a)>0 then
begin fd1:=3*sqr(x)-6*x+6; end;
begin e:=b; xnou:=a; end
else begin e:=a; xnou:=b; end;
begin
repeat
clrscr;
xvechi:=xnou;
a:=1 b:=2; e:=0.01;
xnou:=xvechi-(f(xvechi))/(f(e)-f(xvechi))*(e-xvechi);
c:=a-(f(a))/(f(b)-f(a))*(b-a);
writeln('x=',xnou:10:8,' f(x)=',f(xnou):12:8);
if f(c)*f(a)<0 then begin
until abs ((msup-minf)/minf*(xnou-xvechi))<eps;
xn:=a; xv:=b;
endNewton:
end
else begin xn:=b; xv:=a; end;
while sqr(xn-xv)/2>e do
begin xv:=xn;
3|Page
1 = 0,01
2 = 0,0001
Ecuaia 2
Pentru a gsi de aceast dat intervalul unde se afl zeroul acestei ecuaii am recurs la o
metod mai simpl, dar totodat i destul de precis pentru a observa comportamentul unei
funcii pe un interval anume (tabulare Excel).
i
real
Xi
1
2
3
4
5
6
-6.00
-5.80
-5.60
-5.40
-5.20
-5.00
F(x)
-33.81
-30.89
-27.74
-23.94
-17.92
9.23
7
8
9
10
-4.80
-4.60
-4.40
-4.20
-42.71
-28.76
-24.03
-20.98
Biseciei:
1 = 0,01
2 = 0,0001
Coardelor:
1 = 0,01
2 = 0,0001
Newton:
1 = 0,01
Sarcina 2
2 = 0,0001
Integrale definite.
5|Page
u = e x
2 x
x
e
dx
=
0
du = 2 xdx
2
dv = e x
= ( x 2 e x ) 02 * ( e x )2 xdx =
v = e x
0
2
dv = e x
= ( x 2 e x ) | 02 +2[(xe x ) | 02 ( e x ) dx ] =
v = e x
0
2
u = x
= ( x 2 e x ) | 02 2 xe x dx =
du = dx
0
2
= 2 2 * e 2 + 0 2 * e 0 + 2[2e 2 + 0 2 * e 0 e 2 + e 0 ] = 2
10
0,64664
e2
Metoda dreptunghiurilor :
#include <stdio.h>
return sum;
#include <conio.h>
#include <math.h>
k1=rint(((exp(k*log(2))))+0.5);
main () {
I0=drept(k1);
float a=0.0,b=1.0,d=0,S,e=0.0001;
float I0,I1;
A1: {
int k=1,k1,k2;
k++;
k2=rint((exp(k*log(2))));
float functia(float p) {
I1=drept(k2);
return exp(p)/sqrt(1+exp(p));
d=abs(I0-I1);
float drept(int x) {
sum=0;
A2: S=(I0+I1)/2;
h=(b-a)/x;
getch(); return 0;
for(j=1;j<=x; j++) {
ah=a+h*j;
sum+=h*functia(ah);
//printf("ah=%f sum= %f \n ", sum,ah);
}
Metoda trapezelor :
6|Page
#include <stdio.h>
return sum;
#include <conio.h>
#include <math.h>
k1=rint((exp(k*log(2))));
main () {
I0=drept(k1);
float a=0.0,b=1.0,d=0,S,e=0.0001;
float I0,I1;
A1: {
int k=1,k1,k2;
k++;
float functia(float p) {
k2=rint((exp(k*log(2))));
return exp(p)/sqrt(1+exp(p));
I1=drept(k2);
d=fabs(I0-I1);
float drept(int x) {
sum=0;
h=(b-a)/x;
A2: S=(I0+I1)/2;
for(j=1;j<=x; j++) {
getch(); return 0;
ah=a+h*j;
sum+=h*(functia(ah)+functia(a+(j+1)*h))/2;
// printf("ah=%f sum= %f \n ", sum,ah);
}
Metoda simpson :
else sum+=(4/3)*h*functia(ah);
#include <stdio.h>
#include <conio.h>
#include <math.h>
return sum;
main () {
float a=0.0,b=1.0,d=0,S,e=0.0001;
k1=rint((exp(k*log(2))));
float I0,I1;
I0=drept(k1);
int k=1,k1,k2;
float functia(float p) {
A1: {
return exp(p)/sqrt(1+exp(p));
k++;
k2=rint((exp(k*log(2))));
float drept(int x) {
I1=drept(k2);
d=fabs(I0-I1);
sum=0;
h=(b-a)/x;
for(j=1;j<=x; j++) {
ah=a+h*j;
getch(); return 0;
if((j%2) == 0) sum+=(2/3)*h*functia(ah);
}
7|Page
Dreptunghiurilor
Eroare
0.84533
0.84533
Sarcina 3
Trapezelor
Simpson
Metoda
0.6593
0.6467
0.3251
0.32333
Ecuaii difereniale
Metoda Eylor genereaz un sistem de puncte y0, y1,. yn care reprezint valorile numerice
ale soluiilor problemei Couchy pentru ecuaia diferenial de ordin I.
8|Page
Metodele
n x
0
0
0.
1
2
0.
2
4
0.
3
6
0.
4
8
5
1
1.
6
2
1.
7
4
1.
8
6
1.
9
8
1
0
2
1 2.
1
2
1 2.
2
4
y(Eyler)
y2(RungeKutt)
k1
y3(EylerHeun)
1.0333
1.0462
1.0388
1.0775
1.1053
1.0893
1.1340
1.1785
1.1528
1.2040
1.2886
1.2668
1.3705
1.2305
1.3230
1.3886
1.4895
1.4305
1.5042
1.6231
1.5529
1.6348
1.7703
1.6894
1.7798
1.9296
1.8389
1.9378
2.0998
2.0002
2.1073
2.2793
2.1718
2.2869
2.4669
2.3524
0.033
3
0.044
7
0.057
3
0.071
0
0.085
4
0.100
0
0.114
4
0.128
1
0.140
8
0.152
3
0.162
5
0.171
k2
0.038
6
0.050
7
0.063
9
0.078
0
0.092
6
0.107
3
0.121
5
0.134
8
0.147
0
0.157
8
0.167
4
0.175
k3
0.060
6
0.075
4
0.091
6
0.108
6
0.125
8
0.142
6
0.158
3
0.172
6
0.185
0
0.195
7
0.204
6
0.212
k4
0.045
2
0.057
8
0.071
4
0.085
6
0.100
0
0.114
2
0.127
6
0.140
1
0.151
4
0.161
5
0.170
4
0.178
y*
1
1.033
3
1.083
2
1.146
1
1.223
2
1.315
4
1.423
0
1.545
5
1.682
5
1.832
6
1.994
5
2.166
8
2.348
9|Page
Sarcina 4
Xi
1
2
3
4
5
15
Yi
1
2
3
4
5
15
7.5
6.2
5.5
3.5
3
25.7
5.14
dreapt
parabol
F(x)
Z(x)
7.48
7.50
6.31
6.56
5.14
5.50
3.97
4.31
2.8
3.00
10 | P a g e