-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
WIP: Incremental progress on sparse polynomials #2126
Conversation
Before: In [1]: from sympy.polys.benchmarks.bench_solvers import * In [2]: %time time_solve_lin_sys_189x49() CPU times: user 12.75 s, sys: 0.02 s, total: 12.76 s Wall time: 12.74 s Now: In [1]: from sympy.polys.benchmarks.bench_solvers import * In [2]: %timeit time_solve_lin_sys_189x49() 1 loops, best of 3: 897 ms per loop
Before: In [1]: from sympy.polys.benchmarks.bench_solvers import * In [2]: %time time_solve_lin_sys_165x165() CPU times: user 16.76 s, sys: 0.08 s, total: 16.84 s Wall time: 16.80 s After: In [1]: from sympy.polys.benchmarks.bench_solvers import * In [2]: %time time_solve_lin_sys_165x165() CPU times: user 8.55 s, sys: 0.02 s, total: 8.56 s Wall time: 8.56 s
Regarding caching in general, also see https://code.google.com/p/sympy/issues/detail?id=3222. I think we should use LRU for the cache. It's dead simple to implement, and performs quite well. |
This cache is very small, about 2500 entries per |
History of support for this integral is interesting. It used to work in 0.7.2. Then it was broken in cd42ae8 (bisected to that commit). Then 8d7d239 fixed the exception, but lead to symbolic, yet correct, result. The following commit allowed to return numerical result, but due to earlier commits the result is 0. |
So maybe try bisecting while doing a |
Cache: ok, I would leave it as it is then. |
So here is the story. Last time |
I don't care if it works or not, just as long as we don't get any wrong results. |
The difference from that risch commit is this: The integrand is of the type handleable by risch_integrate, so it passes through that algorithm. But the way the recursive algorithm works, when it is given a rational function, it just passes it off to ratint. Now, actually, it doesn't call ratint directly, because it doesn't work on polynomials. It calls integrate. But the issue is that the pattern matching looks for Unfortunately, calling factor wouldn't be an easy fix, because that doesn't seem to work In [2]: print factor(7.59027773284e-7*t**2 + 0.00173373178*t + 0.990025)
1.0*(7.59027773284e-7*t**2 + 0.00173373178*t + 0.990025) But long story short, take a look at the history of In [1]: integrate(expand(1/(0.000871222*t + 0.995)**2), t)
Out[1]:
⎛ __________________________________________________________
__________________________________________________________ ⎜ ╲╱ 45773156866350624606286237784751595254442599505912800645 801
8.62950215186415e-18⋅╲╱ 45773156866350624606286237784751595254442599505912800645 ⋅log⎜t - ──────────────────────────────────────────────────────────── + ───
⎝ 599631266385525559905071765212450 7
⎞ ⎛ ________________________________________
26175720734332347747⎟ __________________________________________________________ ⎜ ╲╱ 457731568663506246062862377847515952544
────────────────────⎟ - 8.62950215186415e-18⋅╲╱ 45773156866350624606286237784751595254442599505912800645 ⋅log⎜t + ──────────────────────────────────────────
0158479461074971170 ⎠ ⎝ 59963126638552555990507176521
__________________ ⎞
42599505912800645 80126175720734332347747⎟
────────────────── + ───────────────────────⎟
2450 70158479461074971170 ⎠ I would rather have CoersionFailed than 0. Can we revert whatever part of df33365 is incorrect (I guess the tolerance stuff, based on your previous answer)? I guess much of this is just reproducing what you already said. |
I made division algorithms not fail silently or hang when they can't reduce to zero. Now |
Conflicts: sympy/polys/polytools.py
Work on this failing integral let me to a conclusion that we should have a better |
Ok, here goes... |
WIP: Incremental progress on sparse polynomials
This branch removed the |
Awesome, thanks Mateusz! |
SymPy Bot Summary: 🔴 Failed after merging mattpap/new-polys (74ecb37) into master (0ef7411). |
This module was poorly integrated with the rest of polys module. @mattpap (sympy/sympy#2126) suggested rewrite of agca, but apparently neither @mattpap nor @ness01 (author generalized polynomial rings pull request, sympy/sympy#1199) do care about SymPy anymore. AGCA-related PR's: https://github.com/sympy/sympy/pulls?utf8=%E2%9C%93&q=is%3Apr%20author%3Aness01%20is%3Aclosed%20agca
The name of this branch (
new-polys
) may be a bit confusing, because it doesn't go that far, but there is enough work done to merge it soon. In this branch:MonomialOps
)==
or just useis
)@public
decorator (very rough and limited implementation)PolyElement
perPolyRing
to simplifyisinstance(g, PolyElement) and ring == g.ring
toisinstance(g, ring.dtype)
(among other benefits) (the same forFracElement
/FracField
)What remains to do is to:
solve(x**2 - y**2/exp(x), y, x)
)bin/doctest sympy/polys
crashes)There is one downside of this PR. I couldn't, yet, remove old PolynomialRing and FractionField (those using DMP and DMF), because I didn't want to dig into agca module. I will rewrite agca at some point, unless someone would like to step up (@ness01?).