Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class EulerModified {
- public static void main(String[] args){
- double a,b,x,y;
- double h;
- int[] n = new int[]{10, 20, 50, 100, 200, 500, 1000};
- a = 0;
- x = b = 1;
- y = x;
- for(int i = 0 ; i < n.length ; i++){
- h = (b-a)/n[i];
- for(int j = 0 ; j < n[i] ; j++){
- y *=(1+h+(0.5*Math.pow(h, 2)));
- }
- if(i < 3)
- System.out.println("n = "+ n[i] +";\t\t"+y+"\terror = "+(Math.E-y)+"\tlog|error| = "+ Math.log10(Math.E-y));
- else
- System.out.println("n = "+ n[i] +";\t"+y+"\terror = "+(Math.E-y)+"\tlog|error| = "+ Math.log10(Math.E-y));
- y = x;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement