Advertisement
coolfolder

Euler's Method Minimal

Mar 6th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class EulersMethod {
  2.     public static double eulersMethod(FPrime<Double,Double> func, double initX, double initY, double stepSize, double target) {
  3.         if(target<initX+0.000000000000001) return initY;
  4.         double lastVal = eulersMethod(func, initX, initY, stepSize, target-stepSize);
  5.         return lastVal + stepSize*func.val(target-stepSize, lastVal);
  6.     }
  7. }
  8.  
  9. public interface FPrime<X,Y> {
  10.     double val(X x,Y y);
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement