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
rsolve
gives None for linear homogeneous recurrence relation
#19630
Comments
The issue here is that Lines 820 to 825 in c3087c8
We could raise a warning saying sympy is unable to solve for the constants and return the general solution. That would be more helpful than just returning None
|
The equations for The equations are:
That is: In [79]: equations = [-2*x + y*(x + y)/x, 4*x - 8 + y*(x + 2*y)/x, -8*x + 2 + y*(x + 3*y)/x]
In [80]: equations
Out[80]:
⎡ y⋅(x + y) y⋅(x + 2⋅y) y⋅(x + 3⋅y)⎤
⎢-2⋅x + ─────────, 4⋅x - 8 + ───────────, -8⋅x + 2 + ───────────⎥
⎣ x x x ⎦
In [81]: solve(equations, [x, y])
Out[81]: [] |
Yes, they don't have a solution and I verified the same on Wolfram. However, Wolfram is still able to solve the recurrence relation and reports the correct answer - Try this |
Why are there three equations for two symbols? If this is a third order recurrence then there should be three arbitrary constants. Perhaps this is related to the problem in #17982 |
The symbols come from here: Lines 617 to 624 in bd327ec
The poly there has a multiple root:
That also happens with the example from #17982:
Maybe the problem is that multiple roots are not handled. Looping over |
Yes, currently sympy is not able to solve linear recurrences with order>=2 properly. Some other related issues are #8697, #11261. Infact, some equations with order 1 are also a problem as mentioned in #13629. I think most of the issues from |
This can be closed now |
Oh yes, thanks. |
While this works when we don't pass initial condition as:
Expected answer:
F(n) = 2*n + (-2)**n
The text was updated successfully, but these errors were encountered: