Documente Academic
Documente Profesional
Documente Cultură
RAPORT
Lucrare de laborator nr. 1
A efectuat:
A verificat:
2019
Scopul lucrarii practice:
Sa se separe toate radacinile reale ale ecuatiei f(x) unde este o functie realä de variabilá realä.
Sa determine radacina reala a ecuatiei date cu ajutorul metodei injumatatirii intervalului cu
eroare < 0.001
a) -metoda grafica
b) -metoda analitica
Varianta 5,6
5) ex + 3x = 0
6) 𝑥 3 − 23𝑥 − 42 = 0
a)Metoda grafica
Varianta 5)
𝐞𝐱 + 𝟑𝐱 = 𝟎
F(x)=g(x)
𝑓1 (𝑥) = 𝑒 𝑥
𝑓2 (𝑥) = −3𝑥
- +
[-1;1]
Concluzie: Pe intervalele [-1; 1] ecuatia ex + 3x = 0 are radacini reale.
Varianta 6)
𝒙𝟑 − 𝟐𝟑𝒙 − 𝟒𝟐 = 𝟎
F(x)=g(x)
𝑓1 (𝑥) = 𝑥 3
𝑓2 (𝑥) = 23𝑥 − 42
- +
x∈ [−6, −3]
x∈ [2, 3]
Concluzie: Ecuatia 𝒙𝟑 −
𝟐𝟑𝒙 − 𝟒𝟐 = 𝟎 pe
intervalul[-6, -3] are
radacini reale.
b)Metoda analitica
Varianta 6)
𝒙𝟑 − 𝟐𝟑𝒙 − 𝟒𝟐 = 𝟎
f’(x)=3𝑥 2 − 23
23 23
2 −√ √
3𝑥 − 23 = 0 -3 3 3 3
23 + + + +
𝑥 = −√
3
23
x=√
3
Concluzie:
Ecuatia are solutii pe intervalul [-6 ; -2.7 ] si [2.7 ; 6]
Iteration 𝑎𝑛 𝑏𝑛 𝑐𝑛 F(𝑐𝑛 )
1 -1 0 -0.5 -0.893469
2 -0.5 0 -0.25
𝒙𝟑 − 𝟐𝟑𝒙 − 𝟒𝟐 = 𝟎
- +
[-6, -3]
Iteratii a b c F(c)
A=-6
1 -6 -3 -4.5
B=-3
2 -3 -4.5 -3.75 -8.4843
𝑎+𝑏
C=
2
#include<stdio.h>
#include<iostream>
#include<conio.h>
#include<math.h>
float x;
float f(float x)
{
return pow(x,3)-23*x-42;
}
float fprim(float x)
{
return 3*pow(x,2)-23;
}
float funfi(float x)
{
return (pow(x,3)-42)/(1/23);
}
void Bisectoare(float a,float b,float Eps,float *cc, float *dd)
{float c,d,y;
int k;
printf("\n\n Metoda injumatatirii intervalului:\n");
c=a;
if(f(a)<0) c=b;
d=a+b-c;
k=0;
do
{x=c+(d-c)/2;
k++;
y=f(x);
if(y==0) break;
if(y>0) c=x;
else d=x;
printf("\n%2d X=%9f Y=%9f",k,x,y); }
while(fabs(c-d)>Eps);
*cc=c;
*dd=d;
}
void Aproximatie(float x0,float Eps)
{ float x,y;
int k;
printf("\n\n Metoda aproximatiilor succesive:\n");
k=1;
y=x0;
do
{ x=y;
y=funfi(x);
printf("\n%2d X=%9f Y=%9f",k,x,y);
k++;
}
while(fabs(y-x)>Eps);
}
void Newton(float a,float b,float Eps)
{ float c,x1,x;
int k=0;
printf("\n\n Metoda Newton:\n");
c=a-f(a)/(f(b)-f(a))*(b-a);
if(f(c)*f(a)>0) x=a;
else x=b;
do
{
k++;
x1=x;
x=x-f(x)/fprim(x);
printf("\n%2d X=%9f Y=%9f",k,x,f(x));
}
while(fabs(x-x1)>=Eps);
}
void Secante(float a, float b, float Eps)
{float x1,x2,x3,c;
int k=0;
printf("\n\n Metoda secantelor:\n");
c=a-f(a)*((b-a)/(f(b)-f(a)));
if(f(c)*f(a)>0)
{x1=a; x2=a+(b-a)/10;}
else {x1=b;x2=b-(b-a)/10;}
do
{ k++;
x3=x2-f(x2)*((x2-x1)/(f(x2)-f(x1)));
printf("\n%2d X=%9f Y=%9f",k,x3,f(x3));
x1=x2;
x2=x3;
}
while(fabs(x1-x2)>=Eps);
}
int main()
{
float a=-6,b=-3,aa,bb;
Bisectoare(a,b,0.01,&aa,&bb);
getch();
Newton(a,b,pow(10,-6));
getch();
Aproximatie(a,pow(10,-6));
getch();
Secante(a,b,pow(10,-6));
getch();
}
Rezultatele obtinute :
Concluzii: