Definite integral between 0 and 0.5 of sin(x) / x cannot be computed
the definite integral between 0 and 0.5 of sin(x) / x cannot be computed ... returns NaN rather than 0.4931 ... checked cos(x) / x and it's the same problem, also returning NaN ... the indefinite integral works fine ... sin(x) / x gives Si(x) and cos(x) / x gives Ci(x)
Comments (9)
-
repo owner -
have tried the symja-mini-2015-03-23.jar but am still get NaN
-
repo owner Do you have a snippet to demonstrate the problem? Do you use the org/matheclipse/core/reflection/system/Integrate.java to calculate the integral?
I tested this calls:
Integrate(sin(x) / x, {x,0,0.5}) Integrate(cos(x) / x, {x,0.25,0.5})
-
we are importing org.matheclipse.core.eval.MathUtils and then using the MathUtils.integrate(String function, String x, String lower, String upper) function as follows:
MathUtils.integrate(sin(x), x, 0, 0.5) returns 0.12241743810962748 MathUtils.integrate(sin(x)x, x, 0, 0.5) returns 0.0406342576590166 MathUtils.integrate(sin(x)/2x, x, 0, 0.5) returns 0.0203171288295083 MathUtils.integrate(sin(x)/x, x, 0, 0.5) returns NaN MathUtils.integrate(x^2/x, x, 0, 0.5) returns NaN
is there a better way?
-
repo owner OK, I switched from Romberg method for numerical integration to the better suited LegendreGauss method.
Call with LegendreGauss as defaut method:
MathUtils.integrate("sin(x)/2*x", "x", "0", "0.5");
or select one of the methods: LegendreGauss, Simpson, Romberg, Trapezoid
MathUtils.integrate("LegendreGauss", "sin(x)/2*x", "x", "0", "0.5");
See commit: https://bitbucket.org/axelclk/symja_android_library/commits/385d590e7998478577804c19737352dddde6bbb6
-
thanks, that's great ... compiled the 3 revised files and added them into the symja-2015-03-23 jar (replacing the old class files) and then tested in the app ... all works well ... will you be uploading an updated symja-mini version of the jar?
-
repo owner Uploaded symja-mini jar
-
thanks again!
-
repo owner - changed status to resolved
- Log in to comment
Commited: https://bitbucket.org/axelclk/symja_android_library/commits/388c3eb4562d27a58a2a0c4d51187ded472d1551