RSolve conditional recurrence expression

I have trouble in expressing condition recurrence in Mathematica.

I have a conditional recurrence relational, that is conditioned on a function value (defined on sequence index).

where $a_1, a_2, c, b$ are constants.

I tried using the 'Min' function in Mathematica for solving the recurrence relation but it doesn't work. Any idea as to how I can express this such that it can be solved by Mathematica.

• Have you seen Piecewise[]? Feb 5, 2017 at 1:23
• Please post an actual example of your problem expressed in Mathematica code. Feb 5, 2017 at 5:11

Manipulate[
Module[{soln},
soln = RSolve[{x[k + 1] == x[k] +
Piecewise[{
{a1 b^k, x[k] >= c b^k}},
a2 b^k],
x[0] == x0}, x[k], k][[1]];
If[Length[soln] == 1,
DiscretePlot[x[k] /. soln, {k, 0, 6},
PlotLabel -> Style[soln[[1]] // TraditionalForm, 14]],
\$Failed]],
{{x0, 0, Subscript[x, 0]}, Range[10],
ControlType -> SetterBar},
Row[{
Control[{{a1, 1, Subscript[a, 1]}, Range[5]}],
Spacer[10],
Control[{{a2, 1, Subscript[a, 2]}, Range[5]}],
Spacer[10],
Control[{{b, 1}, Range[5]}],
Spacer[10],
Control[{{c, 1}, Range[5]}]}]]