3
$\begingroup$

I am having an issue with the RSolveValue/RSolve function. Specifically, Mathematica is able to correctly evaluate RSolveValue[{f[0] == 1, f[n] == Sum[f[i], {i, 0, n - 1}]}, f[n], n] to Piecewise[{{Power[2, n - 1], n > 0}, {1, n == 0}}, 0], but fails if the indices of the summation are shifted by one: RSolveValue[{f[0] == 1, f[n] == Sum[f[i+1], {i, -1, n - 2}]}, f[n], n] does not evaluate, even though the two summations seem to be clearly equivalent. Is there some way to nudge Mathematica into realizing that these two recurrences are one and the same?

I should note that this issue arises while I am using Mathematica programmatically in Python to do analysis (though the issue is reproducible in the standard Mathematica application). As such, even though there is a case where RSolve is working, the symbolic math library that I am using sometimes produces the shifted indices, and I am hoping that it will be an easier fix to have Mathematica resolve the shifted summation rather than transform the symbolic Python expression.

My Mathematica installation is version 12.3.0.0. Thank you for any help!

$\endgroup$
1
$\begingroup$

Would this work for you?

RSolveValue[{f[0] == 1, f[n] == 1 + Sum[f[i + 1], {i, 0, n - 2}]}, 
 f[n], n]
$\endgroup$
3
  • $\begingroup$ Thank you for your response, but I more so am looking for any flags or assumptions to give Mathematica such that it directly evaluates RSolveValue[{f[0] == 1, f[n] == Sum[f[i+1], {i, -1, n - 2}]}, f[n], n]. While your code is another equivalent formulation that Mathematica is able to evaluate, it would require me to transform the original recurrence into the form in your answer, which leaves me in the same situation that I am in currently. $\endgroup$
    – B. Freeman
    Jun 25 at 19:18
  • $\begingroup$ This seems to be a deficiency in RSolve to me. Can you transform so that the initial index in the sum is the same as the first index in the first term? $\endgroup$ Jun 25 at 21:06
  • $\begingroup$ Yes, if this is truly a deficiency in RSolve, then I'll have to do some sort of preprocessing in my code along those lines. Hopefully, I can find a heuristic to normalize the summation such that Mathematica will accept it for all the recurrences I come across. $\endgroup$
    – B. Freeman
    Jun 25 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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