Axtamov asadbekning


-topshiriq Quyidagi transsendent tenglamani Nyuton va Vatarlar usuli yordamida yechimini aniqlovchi dastur tuzing


Download 22.75 Kb.
bet4/4
Sana25.04.2023
Hajmi22.75 Kb.
#1397746
1   2   3   4
Bog'liq
Asadbek algoritm loyihalsh 1-mustaqil ish

2-topshiriq
Quyidagi transsendent tenglamani Nyuton va Vatarlar usuli yordamida yechimini aniqlovchi dastur tuzing: 13. x3+x-8=0
Javob :

#include


#include

using namespace std;


double f(double x) {


return x*x*x + x - 8;
}

int main() {


double a = 1.5, b = 2.5, eps = 0.0001;
double x, fx;

while (fabs(b-a) > eps) {


x = (a+b)/2;
fx = f(x);

if (fx == 0) break;


else if (fx*f(a) < 0) b = x;
else a = x;
}

cout << "The root is " << x << endl;


return 0;


}

Download 22.75 Kb.

Do'stlaringiz bilan baham:
1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling