# 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[]? – J. M. will be back soon Feb 5 '17 at 1:23
• Please post an actual example of your problem expressed in Mathematica code. – m_goldberg Feb 5 '17 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 == x0}, x[k], k][];
If[Length[soln] == 1,
DiscretePlot[x[k] /. soln, {k, 0, 6},
PlotLabel -> Style[soln[] // TraditionalForm, 14]],
\$Failed]],
{{x0, 0, Subscript[x, 0]}, Range,
ControlType -> SetterBar},
Row[{
Control[{{a1, 1, Subscript[a, 1]}, Range}],
Spacer,
Control[{{a2, 1, Subscript[a, 2]}, Range}],
Spacer,
Control[{{b, 1}, Range}],
Spacer,
Control[{{c, 1}, Range}]}]] 