Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- b)
- double x = 0, dx = 0.5, d = 1;
- for(int ev = 0, r = 1; r <= 1e4; ev++= {
- if(f(x) + d * f(x + dx) < 0) {
- d *= -1;
- dx /= 2;
- }
- if (Math.abs(f(x)) < 1 / r) {
- System.out.printf("[%5s] x = %25s | f(x) = %25s \n", ev, x, f(x));
- r *= 2;
- }
- x += 2;
- }
- mit
- final static double f(final double x) {
- return 2 * Math.sin(1 - Math.log(x)) * x + 0.1;
- }
Add Comment
Please, Sign In to add comment