List<Double> k2 = new ArrayList<Double>();
List<Double> k3 = new ArrayList<Double>();
List<Double> k4 = new ArrayList<Double>();
List<Double> y = equation.getInitValues();
List<String> f = getFunctionVector(equation);
Solution solution = new Solution(start, stop, step);
// map contains derivative and initial value
// <y0, 0.0> , <y1, 0.0> , ... , <z0, 0.5> , <z1, 0.5> , ...
Map<String, Double> map = null;
solution.addResult(y.get(y.size() - 1));
for (double i = start; i < stop; i += step)
{
// add <y0, val>, <y1, val2> ....
map = getMap(y, equation.getFunctionVariable());
// add <x, val3>
map.put(String.valueOf(equation.getIndependentVariable()), i);
k1 = evaluate(f, step, map);
map = getSum(y, k1, 0.5, equation.getFunctionVariable());
map.put(String.valueOf(equation.getIndependentVariable()), i + step / 2);
k2 = evaluate(f, step, map);
map = getSum(y, k2, 0.5, equation.getFunctionVariable());
map.put(String.valueOf(equation.getIndependentVariable()), i + step / 2);
k3 = evaluate(f, step, map);
map = getSum(y, k3, 1.0, equation.getFunctionVariable());
map.put(String.valueOf(equation.getIndependentVariable()), i + step);
k4 = evaluate(f, step, map);
y = evaluateFunction(y, k1, k2, k3, k4);
solution.addResult(y.get(y.size() - 1));
}
return solution;
}