Status: Valid
Owner: ----
Labels: Type-Defect Priority-Medium Solvers WrongResult

New issue 3956 by skirpic...@gmail.com: Failures in rsolve_hyper from test_rsolve_bulk()
http://code.google.com/p/sympy/issues/detail?id=3956

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


--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy-issues+unsubscr...@googlegroups.com.
To post to this group, send email to sympy-issues@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy-issues.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to