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

Failures in rsolve_hyper from test_rsolve_bulk() #7055

Closed
skirpichev opened this Issue Jul 28, 2013 · 0 comments

Comments

Projects
None yet
4 participants
@skirpichev
Copy link
Contributor

skirpichev commented Jul 28, 2013

I had observed a lot of wrong answers from rsolve_hyper() after uncommenting the "if p.is_hypergeometric(n)" branch in the file test_recurr.py.

For example:
In [12]: def recurrence_term(c, f):
   ....:     """Compute RHS of recurrence in f(n) with coefficients in c."""
   ....:     return sum(c[i]*f.subs(n, n + i) for i in range(len(c)))
   ....: 
In [13]: f=Function('f')
In [14]: c=[-2, 1]
In [15]: p=n
In [16]: q=recurrence_term(c, p)
In [17]: s=rsolve_hyper(c, q, n)
In [18]: s
Out[18]: 
 n                 
2 ⋅C₀ + C₀⋅(-n + 1)
In [19]: eq=Eq(sum(c[i]*f(n + i) for i in range(len(c))),q)
In [20]: eq
Out[20]: -2⋅f(n) + f(n + 1) = -n + 1
In [21]: k=Symbol('k',integer=True)
In [22]: eq.subs(f,Lambda(k,s.subs(n,k))).simplify()
Out[22]: C₀⋅(n - 2) = -n + 1

Mathematica's answer:
In[9]:= (f[n]/.RSolve[-2 f[n] + f[n + 1] == -n + 1,f[n],n])[[1]]
Out[9]= 
  n
-2  + 2 n    -1 + n
--------- + 2       C[1]
    2

Original issue for #7055: http://code.google.com/p/sympy/issues/detail?id=3956
Original author: https://code.google.com/u/113518207426301808764/

@flacjacket flacjacket added Wrong Result and removed WrongResult labels Mar 7, 2014

@aktech aktech added solvers.rsolve and removed solvers labels Jul 4, 2015

skirpichev added a commit to skirpichev/diofant that referenced this issue Jun 21, 2016

skirpichev added a commit to skirpichev/diofant that referenced this issue Jun 24, 2016

skirpichev added a commit to skirpichev/diofant that referenced this issue Jun 25, 2016

Build correct inhomogeneous solution in rsolve_hyper
Use rsolve_ratio instead.  (If it returns a generic
solution - we substitute back 0's for symbols in one.)

Fixes diofant#294

Closes sympy/sympy#11261
Closes sympy/sympy#7055

skirpichev added a commit to skirpichev/diofant that referenced this issue Jun 26, 2016

Build correct inhomogeneous solution in rsolve_hyper
Use rsolve_ratio instead.  (If it returns a generic
solution - we substitute back 0's for symbols in one.)

Fixes diofant#294

Closes sympy/sympy#11261
Closes sympy/sympy#7055
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment