Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

recurrence-rsolve-check

I am was testing some ideas and don't understand where this went wrong.

from sympy import Function, rsolve
from sympy.abc import n
y = Function('y');z=Function('z')
f = y(n)-y(n-1)-(-1)^n*binomial(x,n);g=z(n)-z(n-1)-binomial(x,n)

f is the sume of alternating binomial coefficients which is known.

g is just the summation of binomial coefficients (purportedly nonexistent)

frec = rsolve(f,y(n),{y(0):1});grec = rsolve(g,z(n),{z(0):1})
frec

--

zrec

Now this is correct, the alternating sum of binomials

fdiff = frec-(frec.subs({n : n-1}))
simplify(fdiff)

Whereas this is not correct?

gdiff = grec-(grec.subs({n : n-1}))
simplify(gdiff)

Am I missing something in rsolve usage?