Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- fixedPointArrange1();
- }
- private static void fixedPointArrange1() {
- double x0 = 1F;
- double x1 = 2F;
- double x2 = 1.5;
- double tol = Math.pow(10F, -6);
- int loop = 50;
- for(int i = 1; i <= loop; i++) {
- x0 = x1;
- x1 = x2;
- x2 = arrange1(x1);
- if(Math.abs(x1-x0) < tol && Math.abs(x2-x0) < tol && Math.abs(x2-x1) < tol) {
- System.out.println("Iteration " + i + ": " + x2);
- break;
- }
- System.out.println("Iteration " + i + ": " + x2);
- }
- }
- private static double arrange1(double x) {
- //The right equation to get 1.904 which is in the bounds [1, 3]
- return Math.log(3*x+1);
- //The wrong equation since it converges to 0 which is not in the bounds [1, 3]
- //return ((1F-Math.pow(Math.E, x))/-3F);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement