Symbolics.jl
Symbolics.jl copied to clipboard
Julia Symbolics/SymbolicNumericIntegration gives different answers each time it is called.
Reference: https://discourse.julialang.org/t/why-julia-symbolic-generate-random-result-for-symbolic-integration/86717
I have a script that tests one integration problem using the symbolic Julia and symbolic integrator.
I noticed I get different answers each time I run the same script.
Setup: Windows 10. Julia 1.8
. Here are some examples
>julia bug_2.jl
before calling integrate
anti = 0
n_unsolved = 7.870812040507434e12((x - (1//2))^-1) + 0.3129295650227808(((3//5) + x)^-2) + 3.3697484260488335e12(((4//9) + (4//3)*x + x^2)^-1) + 3.935406020253715e12(((1//4) + x^2 - x)^-1) + 5.054622639072726e12x*(((4//9) + (4//3)*x + x^2)^-1) - 9.965866637814543(((3//5) + x)^-1) - 5.054622639062742e12(((2//3) + x)^-1) - 7.870812040507433e12x*(((1//4) + x^2 - x)^-1)
residual_error = Inf
>julia bug_2.jl
before calling integrate
anti = 0
n_unsolved = 0
residual_error = 0
>julia bug_2.jl
before calling integrate
anti = 0.328336208533607log((3//5) + x)
n_unsolved = 0
residual_error = 8.892745078570921e-17
>julia bug_2.jl
before calling integrate
anti = 0
n_unsolved = 0.0062035665227498805((x - (1//2))^-2) + 0.30822457512509605(((3//5) + x)^-2) + 1.91289293028192e13(((2//3) + x)^-1) - 0.024564014848914694((x - (1//2))^-1) - 9.043247646362328(((3//5) + x)^-1) - 1.2752619535206465e13(((4//9) + (4//3)*x + x^2)^-1) - 1.9128929302810082e13x*(((4//9) + (4//3)*x + x^2)^-1)
residual_error = Inf
>julia bug_2.jl
before calling integrate
anti = 0
n_unsolved = 0
residual_error = 0
>julia bug_2.jl
before calling integrate
anti = 0
n_unsolved = 0.42972286411222066(((3//5) + x)^-2) + 1.1185704789344634e15(((2//3) + x)^-1) + 2.148487268951736e13x*(((1//4) + x^2 - x)^-1) - 2.1484872689517336e13((x - (1//2))^-1) - 31.70781106970997(((3//5) + x)^-1) - 1.0742436344758682e13(((1//4) + x^2 - x)^-1) - 7.457136526229525e14(((4//9) + (4//3)*x + x^2)^-1) - 1.1185704789344316e15x*(((4//9) + (4//3)*x + x^2)^-1)
residual_error = Inf
The above where all run from a new command line windows (DOS window) in windows 10.
You see, different answers for same input. sometime same answer (zero in the above example) is repeated if I run it few more time). Here is the script
using Symbolics
using SymbolicNumericIntegration
using Dates
using SpecialFunctions
@syms x
println("before calling integrate")
anti,n_unsolved,residual_error =integrate(1 / (((1 - 2x)^3)*((2 + 3x)^3)*((3 + 5x)^2)),x)
println("anti = ",anti)
println("n_unsolved = ",n_unsolved)
println("residual_error = ",residual_error)
Same thing happens on Linux using Julia 1.8. Am I doing something wrong? Is this a bug? Is there a setting or an option one can use to make sure same result is generated each time?
Another question on the above, for the case where the antiderivative (anti) is zero and the number of terms not integrated (n_unsolved
) is also zero. How could both of these be zero at same time? When n_unsolved
is zero, it means all terms were successfully integrated. Therefore the antiderivative can not be zero.