✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Carei metode apartine urmatorul program? (In program este o functie ce corepsunde cu tema data)
#include <iostream>
#include <cmath>
#define eps 0.00000000001
#define iter 200
double f(double x) {
return x*x*x-2*x*x*cos(x)+x-3;
}
//f1 este derivata functiei f
double f1(double x) {
return 3*x*x+2*x*x*sin(x)-4*x*cos(x)+1;
}
double itang(double a) {
int i;
double x,y1,y;
i=0;
x=a;
y=f(x);
y1=f1(x);
while ( (i<=iter) && ((y<-eps) || (y>eps)) ) {
x=x-y/y1;
y=f(x);
y1=f1(x);
cout << "\n\nf(" << x << ")=" << y << " la iteratia " << i;
i++;
}
if (i>iter) {
cout<<"Problema nu se poate rezolva in nr. maxim de iteratii";
return 0;
}
//Din cauza metodei TI-207, nu se va afisa rezultatul in caz ca radacina va fi egala cu 0.
else
return x;
}
int main() {
double x, a;
cout << "a= ";
cin >> a;
x=itang(a);
if (x!=0)
cout << '\n' << x;
return 0;
}