fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. double f(double x)
  6. {
  7. return 0.25 * (1.0 - 2.0 * x * x * x);
  8. }
  9.  
  10. int main()
  11. {
  12. double x = 0.11;
  13. double e = 0.00000005;
  14. while(abs(x - f(x)) > e)
  15. x = f(x);
  16. cout << 2.0 * x * x * x + 4.0 * x - 1.0 << endl;
  17. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
-1.56921e-07