-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
[integrals] fix substitution formula in meijerint #26173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Hi, I am the SymPy bot. I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.13. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
The tests that fails involves some integral of singularity functions that should probably not be handled by meijerg. Perhaps meijerg should reject such integrals to let another method take over. |
Benchmark results from GitHub Actions Lower numbers are good, higher numbers are bad. A ratio less than 1 Significantly changed benchmark results (PR vs master) Significantly changed benchmark results (master vs previous release) | Change | Before [a00718ba] | After [d447356b] | Ratio | Benchmark (Parameter) |
|----------|----------------------|---------------------|---------|----------------------------------------------------------------------|
| - | 69.1±1ms | 44.7±0.3ms | 0.65 | integrate.TimeIntegrationRisch02.time_doit(10) |
| - | 67.8±0.5ms | 44.3±0.5ms | 0.65 | integrate.TimeIntegrationRisch02.time_doit_risch(10) |
| + | 18.6±0.4μs | 30.9±0.5μs | 1.67 | integrate.TimeIntegrationRisch03.time_doit(1) |
| - | 5.35±0.03ms | 2.84±0.01ms | 0.53 | logic.LogicSuite.time_load_file |
| - | 73.1±0.6ms | 28.9±0.1ms | 0.4 | polys.TimeGCD_GaussInt.time_op(1, 'dense') |
| - | 25.7±0.1ms | 17.0±0.1ms | 0.66 | polys.TimeGCD_GaussInt.time_op(1, 'expr') |
| - | 73.3±0.3ms | 29.2±0.2ms | 0.4 | polys.TimeGCD_GaussInt.time_op(1, 'sparse') |
| - | 256±0.8ms | 125±0.2ms | 0.49 | polys.TimeGCD_GaussInt.time_op(2, 'dense') |
| - | 251±3ms | 126±0.5ms | 0.5 | polys.TimeGCD_GaussInt.time_op(2, 'sparse') |
| - | 647±2ms | 376±3ms | 0.58 | polys.TimeGCD_GaussInt.time_op(3, 'dense') |
| - | 651±1ms | 375±2ms | 0.58 | polys.TimeGCD_GaussInt.time_op(3, 'sparse') |
| - | 497±1μs | 289±1μs | 0.58 | polys.TimeGCD_LinearDenseQuadraticGCD.time_op(1, 'dense') |
| - | 1.77±0.01ms | 1.06±0ms | 0.6 | polys.TimeGCD_LinearDenseQuadraticGCD.time_op(2, 'dense') |
| - | 5.86±0.02ms | 3.16±0.03ms | 0.54 | polys.TimeGCD_LinearDenseQuadraticGCD.time_op(3, 'dense') |
| - | 447±1μs | 235±2μs | 0.53 | polys.TimeGCD_QuadraticNonMonicGCD.time_op(1, 'dense') |
| - | 1.48±0.01ms | 703±6μs | 0.48 | polys.TimeGCD_QuadraticNonMonicGCD.time_op(2, 'dense') |
| - | 4.89±0.09ms | 1.67±0.01ms | 0.34 | polys.TimeGCD_QuadraticNonMonicGCD.time_op(3, 'dense') |
| - | 374±4μs | 208±0.8μs | 0.56 | polys.TimeGCD_SparseGCDHighDegree.time_op(1, 'dense') |
| - | 2.48±0.02ms | 1.28±0.01ms | 0.52 | polys.TimeGCD_SparseGCDHighDegree.time_op(3, 'dense') |
| - | 10.0±0.05ms | 4.45±0.02ms | 0.44 | polys.TimeGCD_SparseGCDHighDegree.time_op(5, 'dense') |
| - | 361±2μs | 173±0.5μs | 0.48 | polys.TimeGCD_SparseNonMonicQuadratic.time_op(1, 'dense') |
| - | 2.55±0.05ms | 925±2μs | 0.36 | polys.TimeGCD_SparseNonMonicQuadratic.time_op(3, 'dense') |
| - | 9.63±0.03ms | 2.70±0.02ms | 0.28 | polys.TimeGCD_SparseNonMonicQuadratic.time_op(5, 'dense') |
| - | 1.02±0.01ms | 429±2μs | 0.42 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(3, 'dense') |
| - | 1.72±0.01ms | 497±1μs | 0.29 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(3, 'sparse') |
| - | 5.85±0.04ms | 1.86±0.01ms | 0.32 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(5, 'dense') |
| - | 8.40±0.06ms | 1.48±0.01ms | 0.18 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(5, 'sparse') |
| - | 286±2μs | 64.4±0.4μs | 0.22 | polys.TimePREM_QuadraticNonMonicGCD.time_op(1, 'sparse') |
| - | 3.47±0.03ms | 398±4μs | 0.11 | polys.TimePREM_QuadraticNonMonicGCD.time_op(3, 'dense') |
| - | 4.03±0.03ms | 277±0.5μs | 0.07 | polys.TimePREM_QuadraticNonMonicGCD.time_op(3, 'sparse') |
| - | 6.94±0.04ms | 1.30±0.01ms | 0.19 | polys.TimePREM_QuadraticNonMonicGCD.time_op(5, 'dense') |
| - | 8.69±0.07ms | 835±4μs | 0.1 | polys.TimePREM_QuadraticNonMonicGCD.time_op(5, 'sparse') |
| - | 5.00±0.03ms | 2.98±0.01ms | 0.6 | polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(2, 'sparse') |
| - | 12.0±0.05ms | 6.97±0.04ms | 0.58 | polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(3, 'dense') |
| - | 22.0±0.07ms | 9.02±0.03ms | 0.41 | polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(3, 'sparse') |
| - | 5.24±0.02ms | 862±2μs | 0.16 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(1, 'sparse') |
| - | 12.6±0.1ms | 6.97±0.01ms | 0.55 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(2, 'sparse') |
| - | 102±0.9ms | 26.9±0.09ms | 0.26 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(3, 'dense') |
| - | 166±1ms | 53.6±0.1ms | 0.32 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(3, 'sparse') |
| - | 174±0.9μs | 114±0.6μs | 0.65 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(1, 'dense') |
| - | 359±2μs | 216±1μs | 0.6 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(1, 'sparse') |
| - | 4.28±0.02ms | 877±4μs | 0.21 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(3, 'dense') |
| - | 5.18±0.05ms | 379±2μs | 0.07 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(3, 'sparse') |
| - | 20.0±0.2ms | 2.95±0.01ms | 0.15 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(5, 'dense') |
| - | 23.1±0.3ms | 622±2μs | 0.03 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(5, 'sparse') |
| - | 480±2μs | 134±0.8μs | 0.28 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(1, 'sparse') |
| - | 4.74±0.04ms | 648±6μs | 0.14 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(3, 'dense') |
| - | 5.23±0.03ms | 137±0.7μs | 0.03 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(3, 'sparse') |
| - | 13.4±0.2ms | 1.37±0.01ms | 0.1 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(5, 'dense') |
| - | 14.1±0.07ms | 141±1μs | 0.01 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(5, 'sparse') |
| - | 133±0.6μs | 76.6±0.4μs | 0.57 | solve.TimeMatrixOperations.time_rref(3, 0) |
| - | 248±0.3μs | 89.2±0.3μs | 0.36 | solve.TimeMatrixOperations.time_rref(4, 0) |
| - | 24.1±0.1ms | 10.2±0.04ms | 0.42 | solve.TimeSolveLinSys189x49.time_solve_lin_sys |
| - | 28.0±0.1ms | 15.5±0.1ms | 0.55 | solve.TimeSparseSystem.time_linsolve_Aaug(20) |
| - | 54.3±0.4ms | 25.0±0.04ms | 0.46 | solve.TimeSparseSystem.time_linsolve_Aaug(30) |
| - | 27.9±0.1ms | 15.3±0.04ms | 0.55 | solve.TimeSparseSystem.time_linsolve_Ab(20) |
| - | 54.4±0.3ms | 24.8±0.08ms | 0.46 | solve.TimeSparseSystem.time_linsolve_Ab(30) |
Full benchmark results can be found as artifacts in GitHub Actions |
def test_indefinite_1_bug(): | ||
assert integrate((b + t)**(-a), t, meijerg=True | ||
) == -b**(1 - a)*(1 + t/b)**(1 - a)/(a - 1) | ||
).equals(-b**(1 - a)*(1 + t/b)**(1 - a)/(a - 1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to change this test answer to show what is now returned.
The old result was:
In [4]: a, b, c = symbols("a b c")
In [5]: integrate((b + t)**(-a), t, meijerg=True)
Out[5]:
1 - a
1 - a ⎛ t⎞
-b ⋅⎜1 + ─⎟
⎝ b⎠
─────────────────────
a - 1
The new result is
In [2]: integrate((b + t)**(-a), t, meijerg=True)
Out[2]:
1 - a
⎛ t⎞
-b⋅⎜1 + ─⎟
⎝ b⎠
────────────────
a a
a⋅b - b
Looks like this also fixed gh-25949. A test could be added. |
I had wondered if this fixed gh-25137 but it does not seem to. |
This looks good. Thanks for this. This is the kind of bug that could linger for a long time and I'm sure it took some work to find the proper fix. |
References to other Issues or PRs
Fixes #25786
Brief description of what is fixed or changed
fix substitution formula in meijerint
Other comments
Release Notes
integrate(exp(-x**2), (x,-5,0), meijerg=True)
incorrectly gave-sqrt(pi)/2 * erf(5)
instead ofsqrt(pi)/2 * erf(5)
.