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
Solving already solved equations takes a long time #17186
Comments
If you add simplify=False, check=False, and remove manual=True, the time goes down to 6 seconds. It looks like the simplify time is spent in cancel, which is slow because it has so many variables. The check code is slow in subs. For some reason if you do simplify=False, check=False, manual=True, it hangs. With check=False, manual=False, simplify=False, it is spending its time in the algorithm itself, specifically |
I tried throwing it at |
I removed the duplicate variables from the code in the original post. |
I think this is also a place where splitting the connected components of the system before solving would help a lot. |
It looks like _solve_reduced_system doesn't do any preprocessing at all. If it gets a polynomial that is already in one variable, it shouldn't pass it through to the groebner basis algorithm. |
I tried with manual=False, check=False, simplify=False and compare master with #16550 and it does get faster. On master it's 10 seconds and with #16550 it's 4.8 seconds. Note that #16550 only splits fully disconnected components so any equations that have any unknowns in common will still be solved together. |
One step of preprocessing that is especially applicable to systems passed as # using eqs and dependent_vars defined in OP
# and repsort from #6257
r = repsort(*[i.args for i in eqs])
sol = {}
for i in range(len(r)-1,-1,-1):
k, v = r[i]
sol[k] = v.xreplace(sol)
#assert not sol[k].has(*dependent_vars) So this is not "solving" as much as it is fully resolving the system fully to give variables in terms of independent variables. The given system of equations takes less than a second to resolve with the above code snippet. |
When solving a system of nonlinear equations, if the equations are already solved for all unknowns, then it should be very fast to return the solution. However, this is not the case. For example, this script:
This script has many equations, but they are already solved for all unknowns. All that is needed should be a little substitution. However, it take 17 seconds to run on my machine, which seems excessive.
The text was updated successfully, but these errors were encountered: