new.cpp 585 B

123456789101112131415161718192021222324252627282930313233
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int main(){
  5. float x, y, der1, der2, eps, min;
  6. cout << "Input accuracy: ";
  7. cin >> eps;
  8. cout << "Input minimal limited: ";
  9. cin >> min;
  10. if (min < 0){
  11. cout << "If minimal limited less than 0, so result of log function will be complex number." << endl;
  12. return 0;
  13. }
  14. x = min;
  15. y = log(3 * x) - 0.4 * x + 0.5;
  16. while (abs(y - x) > eps) {
  17. der1 = log(3 * x) - 0.4 * x + 0.5;
  18. der2 = 1 / x - 0.4;
  19. y = x;
  20. x = y - der1 / der2;
  21. }
  22. cout << "Result: " << y << endl;
  23. return 0;
  24. }