Skip to content

Commit 24b9a5e

Browse files
committed
Update RiemannIntegration.java
added an example usage of the riemann integration
1 parent 1bbe292 commit 24b9a5e

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/main/java/com/thealgorithms/maths/RiemannIntegration.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ public static void main(String[] args) {
8686
*/
8787
public static final void example() {
8888
final Function < Double, Double > xSquaredFunction = x -> Math.pow(x, 2); // Creates the function f(x) = x^2
89-
final RiemannApproximationMethod riemannApproximationMethod = RiemannApproximationMethod.TRAPEZOIDAL_RIEMANN_SUM; // Chooses the Trapezoidal method for approximating the integral.
90-
final RiemannIntegration riemannIntegration = new RiemannIntegration();
91-
final double result = riemannIntegration.integrate(xSquaredFunction, riemannApproximationMethod, 0, 1); // The integral of x^2 from x = 1 to x = 2 is 1/3.
92-
System.out.println(result);
89+
final double result = RiemannIntegration.trapezoidalRiemannSum (xSquaredFunction, 0, 1, 9); // I find that an accuracy between 7 - 10 (inclusive) works best.
90+
System.out.println ("Integral of y = x^2 from x = 0 to x = 1: " + result);
9391
}
9492
}

0 commit comments

Comments
 (0)