1-mustaqil ish topshiriqlari nazariy topshiriqlar: Quyidagi nazariy savollarga javob bering


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


Download 24.58 Kb.
bet4/4
Sana26.03.2023
Hajmi24.58 Kb.
#1296324
1   2   3   4
Bog'liq
1-mustaqil topshiriq Durdona(Algoritmni loyihalash)

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 24.58 Kb.

Do'stlaringiz bilan baham:
1   2   3   4




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