Definite integral between 0 and 0.5 of sin(x) / x cannot be computed

Issue #83 resolved
Former user created an issue

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)

  1. Axel Kramer 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})
    
  2. Tony Admin

    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?

  3. Axel Kramer 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

  4. Tony Admin

    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?

  5. Log in to comment