Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Bug introduced in 9.0 or earlier and fixed in 10.0

I want to solve the following recurrence equation

RSolve[{(k + 2) c[k + 2] q^(k + 1) - c[k] == 0}, c[k], k]

During calculation in Mathematica I get this persistent error:

Context::ssle: "Symbol, string, or HoldPattern[symbol] expected at position Context[Zeta$^{(1,0)}$].

I tried to solve this equation with Maple and obtained a result

$\left\{ \begin{array}{cc} c (0)\frac{ 2^{-\frac{k}{2}} q^{-\frac{1}{2} k \left(\frac{k}{2}-1\right)} \left(\frac{1}{q}\right)^{k/2}}{\Gamma \left(\frac{k}{2}+1\right)} & k\text{::}\text{even} \\ c(1)\frac{\sqrt{\pi } 2^{-\frac{k}{2}-\frac{1}{2}} q^{-\left(\frac{k}{2}-\frac{1}{2}\right) \left(\frac{k}{2}-\frac{3}{2}\right)} \left(\frac{1}{q^2}\right)^{\frac{k}{2}-\frac{1}{2}}}{\Gamma \left(\frac{k}{2}+1\right)} & k\text{::}\text{odd} \\ \end{array} \right.$

So is it just a bug in Mathematica 9 or am I missing something?

share|improve this question
up vote 8 down vote accepted

This is definitely a bug. It seems that the problem is caused because you increment the argument by two (your recurrence has c[k] and c[k+2]). This results in two cases (even and odd), as can be seen by your Maple output, and Mathematica apparently does not know how to deal with this properly.

One way around this is to substitute the variables so that the two cases are considered separately. For example, for the even case you substitute k = 2 m and run

RSolve[{(2 m + 2) c[2 (m + 1)] q^(2 m + 1) - c[2 m] == 0}, c[m], m]

This gives

$c(m)\to c_1 \frac{2^{1-\frac{m}{2}} \left(\frac{1}{q^2}\right)^{\frac{1}{8} m (m+2)} q^{\frac{m}{2}+1}}{\Gamma \left(\frac{m}{2}+1\right)}$

after simplification. Then you do the reverse substitution to obtain the answer for the original recurrence. You can deal with the odd case similarly. This is annoying, of course, but at least you get your answer in the end.

share|improve this answer
Thanks for your workaround! Yeah, it's annoying, because each case here must be dealt with separately. – SaF May 9 '13 at 15:22

No problem in version 10:


(* Out[3]= "10.1.0  for Microsoft Windows (64-bit) (March 24, 2015)"  *)

RSolve[{(k + 2) c[k + 2] q^(k + 1) - c[k] == 0}, c[k], k]

$$\left\{\left\{c(k)\to \frac{c_1 2^{-\frac{k}{2}} \left(\frac{1}{q^2}\right)^{\frac{1}{8} k (k+2)} q^{k/2}}{\Gamma \left(\frac{k}{2}+1\right)}+\frac{c_2 (-1)^k 2^{-\frac{k}{2}} \left(\frac{1}{q^2}\right)^{\frac{1}{8} k (k+2)} q^{k/2}}{\Gamma \left(\frac{k}{2}+1\right)}\right\}\right\}$$

share|improve this answer
Thanks for the update! – SaF Aug 6 '15 at 15:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.