Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- double Rech1(double x)
- {
- return acos(x) - sqrt(1 - 0.3 * (x * x * x)); // начальная
- }
- double Rech2(double x)
- {
- return ((9 * x * x) / (20 * sqrt(1- 0.3 * (x*x*x))) - 1 / (sqrt(1 - x*x))); //Производная
- }
- double opredelit() {//определения грубого значения по условию
- double x0;
- float a = 1, b = 2;
- x0 = a;
- while (Rech1(x0) * Rech2(x0) < 0) {
- if (Rech1(x0) * Rech2(x0) > 0) {
- break;
- }
- else {
- x0 = x0 + 0.01;
- }
- }
- return x0;
- }
- double newton(double x0) {//метод ньютона
- double x, amendment;
- double e = 1e-4;
- do
- {
- amendment = -1 * (Rech1(x0) / Rech2(x0));
- x = x0 + amendment;
- if (Rech2(x0) == 0)//проверка на 0 потому что на 0 делить нельзя
- break;
- x0 = x;
- } while (abs(Rech1(x0)) > e);
- return x;
- }
- int main()
- {
- setlocale(LC_ALL, "ru");
- double x0 = opredelit();
- //double s = newton(x0);
- cout << x0 << endl;
- cout << "корень уравнения=" << newton(x0) << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement