View difference between Paste ID: 3xrss1X7 and LfK6tYUd
SHOW: | | - or go back to the newest paste.
1-
//y_n = y_(n-h) + h*F(x_(n-h),y_(n-h))
1+
2
    public static double eulersMethod(FPrime<Double,Double> func, double initX, double initY, double stepSize, double target) {
3-
    public static void main(String[] args) {
3+
        if(target<initX+0.000000000000001) return initY;
4-
        //the main method calls the following example:
4+
5-
        //Use Euler's Method with step size 0.1 to estimate y(0.4) where y(x) is a solution to y'=y+xy and y(0)=1
5+
6-
        
6+
7-
        //this is a lambda, it represents the f prime function
7+
8-
        //lambdas were added in Java 8, I skimmed over the syntax at
8+
9-
        //http://java.dzone.com/articles/java-lambda-expressions-basics
9+
10-
        FPrime<Double,Double> func = (x,y) -> y+x*y;
10+
11-
        double initX = 0,
11+