Guest User

Untitled

a guest
Jun 21st, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. b)
  2. double x = 0, dx = 0.5, d = 1;
  3. for(int ev = 0, r = 1; r <= 1e4; ev++= {
  4. if(f(x) + d * f(x + dx) < 0) {
  5. d *= -1;
  6. dx /= 2;
  7. }
  8. if (Math.abs(f(x)) < 1 / r) {
  9. System.out.printf("[%5s] x = %25s | f(x) = %25s \n", ev, x, f(x));
  10. r *= 2;
  11. }
  12. x += 2;
  13. }
  14.  
  15. mit
  16.  
  17. final static double f(final double x) {
  18. return 2 * Math.sin(1 - Math.log(x)) * x + 0.1;
  19. }
Add Comment
Please, Sign In to add comment