|
Algoritmlarni loyihalash Mustaqil ish
|
Sana | 15.05.2024 | Hajmi | 20,59 Mb. | | #233972 |
Bog'liq Algoritmlash mustaqil ishi kt, Algoritmlash mustaqil ishi (1), 1711975402 (1), 1, Abror, 1711975402, 1711975402 (2), Algoritmlash mustaqil ishi, Algorim Abror.Uralov, Algoritmlash mustaqil ishi
MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
Algoritmlarni loyihalash
Mustaqil ish
Fakultet: Televizion texnologiyalari
Guruh: CAL015-2 (520-22).
Bajardi: Uralov Abror
Tekshirdi: Qo’ldoshev Hakim
Toshkent-2024
76-Variant
#include
#include
using namespace std;
double f(double x) {
return pow(x, 3) + pow(x, x) - x - 4;
}
double f_derivative(double x) {
return 3 * pow(x, 2) + pow(x, x - 1) * (1 + log(x)) - 1;
}
double newton_method(double initial_guess, double tolerance, int max_iterations)
{
double x = initial_guess;
int iterations = 0;
while (abs(f(x)) > tolerance && iterations < max_iterations) {
x = x - f(x) / f_derivative(x);
iterations++;
}
if (abs(f(x)) <= tolerance) {
cout << "Yechim topildi: x = " << x << endl;
return x;
} else {
cout << "Yechim topilmadi." << endl;
return NAN;
}
}
int main() {
double initial_guess = 1.0;
double tolerance = 0.0001;
int max_iterations = 1000;
newton_method(initial_guess, tolerance, max_iterations);
return 0;
}
|
| |