123456789101112131415161718192021222324252627282930313233 |
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main(){
- float x, y, der1, der2, eps, min;
- cout << "Input accuracy: ";
- cin >> eps;
- cout << "Input minimal limited: ";
- cin >> min;
- if (min < 0){
- cout << "If minimal limited less than 0, so result of log function will be complex number." << endl;
- return 0;
- }
- x = min;
- y = log(3 * x) - 0.4 * x + 0.5;
- while (abs(y - x) > eps) {
- der1 = log(3 * x) - 0.4 * x + 0.5;
- der2 = 1 / x - 0.4;
- y = x;
- x = y - der1 / der2;
- }
- cout << "Result: " << y << endl;
- return 0;
- }
|