Created
April 25, 2014 18:44
-
-
Save lamrongol/11299217 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @see <a href="http://en.wikipedia.org/wiki/Riemann_sum#Middle_sum">http://en.wikipedia.org/wiki/Riemann_sum#Middle_sum</a> | |
*/ | |
public static double riemannSum(Function<Double, Double> func, double beginPoint, double endPoint, double interval){ | |
double result = 0; | |
//Middle Sum(Maybe error sum is most minimal) | |
for(double x = beginPoint; x<=endPoint; x+=interval){ | |
result += func.apply(x+interval/2); | |
} | |
result *= interval; | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment