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

1) Separarea Rădăcinilor A) X +0.4x +0.6x-1.6 0: X X) 3 X X

The document discusses separating the roots of equations numerically using methods like Newton's method and the secant method. It includes code for implementing these root-finding algorithms in C++. The conclusion states that performing this laboratory work provided practical skills for numerically solving algebraic and transcendental equations, which are efficient and easily applicable methods often used to study nonlinear processes.

Uploaded by

Dan Crețu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

1) Separarea Rădăcinilor A) X +0.4x +0.6x-1.6 0: X X) 3 X X

The document discusses separating the roots of equations numerically using methods like Newton's method and the secant method. It includes code for implementing these root-finding algorithms in C++. The conclusion states that performing this laboratory work provided practical skills for numerically solving algebraic and transcendental equations, which are efficient and easily applicable methods often used to study nonlinear processes.

Uploaded by

Dan Crețu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1)Separarea rdcinilor

a) Separarea analitic a rdcinilor ecuaiei x3+0.4x2+0.6x-1.6=0


x 3+ 0.4 x 2+0.6 x1.6
f ' ( x )=3 x2 +0.8 x +0.6
3

x 2 x +3 x=0
=b2-4ac= (0.8)2-4*3*0.6=0.64-7.2=-6.56
[-k;k] k=(1+a)/|a0|
a=max{a1,,an}=1.6
k=(1+1.6)/1=2.6=3
a0=1
X
sgn f(x)

-3
-

0
-

3
+

Aceasta ecuaie are o singura soluie pe segmentul [0;3]


b) Separarea grafic a rdcinilor ecuaiei x3+x-5=0

x3-albastru
x-5-rou

Listingul Programului:
#include <string>
#include <cmath>
#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;
float x,a,b,Eps;
void Meniu();
float f(float x);
void Newton (float a,float b,float Eps);
void Secante(float a, float b, float Eps);
void eps();
bool Intervalf();
float f0(float x) {
return pow(x,3)+0.4*pow(x,2)+0.6*x-1.6; // ecuatia
}
float f1(float x) {
return 3*pow(x,2)+0.8*x+0.6; // derivata de ord I
}
float f2(float x) {
return 6*x+0.8;
// ord II
}
int main()

{char var;
while(true)
{
Meniu();
cin>>var;
switch(var)
{
case '1': Intervalf(); break;
case '2': eps(); break;
case '3': Newton(a,b,Eps); break;
case '4': Secante(a,b,Eps); break;
case '0': exit(0);break;
}
}
cout<<endl;
return 0;
}
// functia meniu
void Meniu()
{ cout<<
"--------------------MENIUL--------------";
cout<<endl<< "| 1 |
Introduceti intervalu
|";
cout<<endl<< "----------------------------------------";
cout<<endl<< "| 2 |
Introduceti Epsilon
|";
cout<<endl<< "----------------------------------------";
cout<<endl<< "| 3 |
Metoda Tangentelor(Newton) |";
cout<<endl<< "----------------------------------------";
cout<<endl<< "| 4 |
Metoda Secantelor
|";
cout<<endl<< "----------------------------------------";
cout<<endl<< "| 0 |
Iesire
|";
cout<<endl<< "----------------------------------------";
cout<<endl<<"==";
}
bool Intervalf()
{
cout << "Intervalul este: ";
cin>>a>>b;
if ((f(a) * f(b))<=0)
{
cout<<"Intervalul scris este corect"<<endl;
return true;
}
else
if ( (f(a) * f(b)>0) ){
cout<<"Intervalul nu este corect "<<endl;
return false;
}
}
void eps()
{
cout<<endl<<"Precizia=10^";
cin>>Eps;
Eps=pow(10,Eps);
cout<<"Epsilon="<<Eps<<endl;
}
void Newton(float a,float b,float Eps)
{
int n=0; // iteratii
float c;
if(f0(a)*f2(a)>0) c=a;
else c=b;
do {
c=c-f0(c)/f1(c); // formula Newton
n+=1;
}

while (fabs(f0(c))>=Eps); // conditia de oprire a calculelor


cout<<"Solutia este= "<<c<<";"<<"y= "<<fixed<<setprecision(5)<<f0(c)<<"\t"<<"Nr. de iteratii:
n="<<n<<"\n";
}
void Secante(float a, float b, float Eps)
{
float x1,x2,x3,c;
int k=0;
cout<<endl<<"Metoda secantelor: "<<endl;
if((f(c)*f(a))>0)
{
x1=a;
x2=a+(b-a)*1./2;
}
else
{
x1=b;
x2=b-(b-a)*1./2;
}
do
{
k++;
x3=x2-f(x2)*(x2-x1)*1./(f(x2)-f(x1));
cout<<endl<< k<< " Solutia este: x= "<< x3<<" y= "<<fixed<<setprecision(5)<<f(x3);
x1=x2;
x2=x3;
}while(fabs(x2-x1)>=Eps);
cout<<endl;
}
float f(float x)
{
float y= pow(x,3)+0.4*pow(x,2)+0.6*x-1.6;
return y;
}

Concluzie: Executnd aceast lucrare de laborator am obinut


deprinderi practice n domeniul rezolvrii numerice a ecuaiilor
algebrice i transcendente care sunt foarte eficiente i uor
aplicabile. Aceste metode sunt deseori utilizate n practic
deoarece majoritatea proceselor care se studiaz n tehnic,
tiin i economie sunt neliniare.

Rexultat:

You might also like