RSolveValue[eqn,expr,n]
gives the value of expr determined by a symbolic solution to the ordinary difference equation eqn with independent variable n.
RSolveValue[{eqn1,eqn2,…},expr,…]
uses a symbolic solution for a list of difference equations.
RSolveValue[eqn,expr,{n1,n2,…}]
uses a solution for the partial recurrence equation eqn.
RSolveValue
RSolveValue[eqn,expr,n]
gives the value of expr determined by a symbolic solution to the ordinary difference equation eqn with independent variable n.
RSolveValue[{eqn1,eqn2,…},expr,…]
uses a symbolic solution for a list of difference equations.
RSolveValue[eqn,expr,{n1,n2,…}]
uses a solution for the partial recurrence equation eqn.
Details and Options
- RSolveValue[eqn,a,n] gives a solution for a as a pure function.
- The equations can involve objects of the form a[n+λ], where λ is a constant, or in general, objects of the form a[ψ[n]], a[ψ[ψ[n]]], a[ψ[…[ψ[n]]…]], where ψ can have forms such as:
-
n+λ arithmetic difference equation μ n geometric or
-difference equationμ n+λ arithmetic-geometric functional difference equation μ nα geometric-power functional difference equation 
linear fractional functional difference equation - Equations such as a[0]==val can be given to specify end conditions.
- If not enough end conditions are specified, RSolveValue will use general solutions in which undetermined constants are introduced.
- The specification a∈Vectors[p] or a∈Matrices[{m,p}] can be used to indicate that the dependent variable a is a vector-valued or a matrix-valued variable, respectively. Alternatively, a can be specified as a VectorSymbol or MatrixSymbol. » »
- The constants introduced by RSolveValue are indexed by successive integers. The option GeneratedParameters specifies the function to apply to each index. The default is GeneratedParameters->C, which yields constants C[1], C[2], ….
- GeneratedParameters->(Module[{C},C]&) guarantees that the constants of integration are unique, even across different invocations of RSolveValue.
- For partial recurrence equations, RSolveValue generates arbitrary functions C[n][…].
- Solutions given by RSolveValue sometimes include sums that cannot be carried out explicitly by Sum. Dummy variables with local names are used in such sums.
- RSolveValue[eqn,a[Infinity],n] gives the limiting value of the solution a at Infinity.
- RSolveValue handles both ordinary difference equations and
‐difference equations. - RSolveValue handles difference‐algebraic equations, as well as ordinary difference equations.
- RSolveValue can solve linear recurrence equations of any order with constant coefficients. It can also solve many linear equations up to second order with nonconstant coefficients, as well as many nonlinear equations.
- RSolveValue[u[t]sys,resp,t] can be used for solving discrete-time models, where sys can be a TransferFunctionModel or a StateSpaceModel and the response function resp can be one of the following: »
-
"StateResponse" state response of sys to the input 
"OutputResponse" output response of sys to the input 
Examples
open all close allBasic Examples (4)
RSolveValue[a[n + 1] - 2a[n] == 1, a[n], n]RSolveValue[{a[n + 1] - 2a[n] == 1, a[0] == 1}, a[n], n]Get a "pure function" solution for a:
sol = RSolveValue[{a[n + 1] - 2a[n] == 1, a[0] == 1}, a, n]DiscretePlot[sol[n], {n, 0, 7}]RSolveValue[a[n] == Sqrt[n]a[Sqrt[n]] + n, a[n], n]Obtain the value of the solution at a point:
RSolveValue[{a[n + 1] == 2a[n], a[0] == 1}, a[3], n]RSolveValue[{a[n + 1] == 2a[n], a[0] == 1}, {a[3], a[4]}, n]Scope (54)
Basic Uses (9)
Compute the general solution of a first-order difference equation:
RSolveValue[a[n + 1] == 3a[n], a[n], n]Obtain a particular solution by adding an initial condition:
sol = RSolveValue[{a[n + 1] == 3a[n], a[0] == 1}, a[n], n]Plot the solution of a first-order difference equation:
sol = RSolveValue[{a[n + 1] == 2 a[n] + 5, a[0] == 3}, a[n], n]DiscretePlot[sol, {n, 0, 10}]Table[sol, {n, 0, 10}]Verify the solution of a difference equation by using a in the second argument:
eqns = {a[n + 1] == 4a[n] + k E ^ n, a[0] == 3};sol = RSolveValue[eqns, a, n]eqns /. {a -> sol}//SimplifyObtain the general solution of a higher-order difference equation:
RSolveValue[a[n + 2] - 5a[n + 1] + 6a[n] == n, a[n], n]RSolveValue[{a[n + 2] - 5a[n + 1] + 6a[n] == n, a[0] == 1, a[1] == 3}, a[n], n]Solve a system of difference equations:
eqns = {a[n + 1] - b[n] == 2, a[n] - 3 b[n + 1] == 5, a[0] == 3, b[0] == 1};{sol1, sol2} = RSolveValue[eqns, {a, b}, n]DiscretePlot[Evaluate[{sol1[n], sol2[n]}], {n, 0, 20}]eqns /. {a -> sol1, b -> sol2}//SimplifyCompute the value of the solution at a point:
RSolveValue[{x[n + 1] == (1 + x[n]) ^ 2, x[0] == 0}, x[5], n]Compute the limiting value of the solution at Infinity:
RSolveValue[{x[n + 1] == (7 + x[n]) / (1 + x[n]), x[1] == 3}, x[∞], n]Solve a partial difference equation:
sol = RSolveValue[7a[m + 1, n] - 6a[m, n + 1] == m, a[m, n], {m, n}]sol1 = sol /. C[1] -> CosDiscretePlot3D[sol1, {m, 0, 15}, {n, 0, 15}]Use different names for the arbitrary constants in the general solution:
RSolveValue[a[n + 2] - 7a[n + 1] + 12a[n] == 1, a[n], n]RSolveValue[a[n + 2] - 7a[n + 1] + 12a[n] == 1, a[n], n, GeneratedParameters -> f]Linear Difference Equations (7)
RSolveValue[{a[n + 1] == c a[n], a[0] == 1}, a, n]First-order equation with variable coefficients:
RSolveValue[a[n + 1] == (n ^ 2 - 1 / 4) / (n + 1) a[n], a[n], n]A third-order constant coefficient equation:
RSolveValue[a[n + 3] == 2a[n], a, n]RSolveValue[{a[n + 3] == 2a[n], a[0] == 1, a[1] == 2, a[2] == -1}, a[n], n]DiscretePlot[%, {n, 15}, Filling -> Axis]Second-order inhomogeneous equation:
RSolveValue[a[n + 2] - 4a[n + 1] + 3a[n] == n 4 ^ n, a[n], n]Second-order variable coefficient equation in terms of elementary functions:
RSolveValue[(n + 4) a[n + 2] - a[n + 1] - (n + 1)a[n] == 0, a[n], n]RSolveValue[a[n + 2] == (n + 1)2 ^ n a[n], a[n], n]RSolveValue[2 a[n] - 2 n (-a[n] + a[n + 1]) + n (1 + n) (a[n] - 2 a[n + 1] + a[n + 2]) == 0, a, n]In general, special functions are required to express solutions:
RSolveValue[(n + 2)a[n + 2] == (2 n + 3) x a[n + 1] - (n + 1) a[n], a, n]RSolveValue[a[n] == 2(1 + n) / (b + c z) a[n + 1] - a[n + 2], a[n], n]RSolveValue[a[n] == 2(n + 1) / n(c * z + d) a[n + 1] - (n + 2) / n a[n + 2], a, n]RSolveValue[ a[n + 2] + (2n + 1) a[n + 1] + n ^ 2 a[n] == 0, a[n], n ]Higher-order inhomogeneous equation with constant coefficients:
RSolveValue[ y[k + 4] + 4y[k + 2] - 3 y[k + 1] + 2 y[k] == (2k^2 + 3k - 4) 2^3k, y[k], k ]Nonlinear Difference Equations (5)
RSolveValue[a[n + 1] == 2(1 - a[n])a[n], a[n], n]RSolveValue[a[n + 1] == -2(1 - a[n])a[n], a[n], n]RSolveValue[a[n + 1] == 4(1 - a[n])a[n], a[n], n]RSolveValue[a[n + 1] == -(a[n] + 15) / (a[n] + 7), a[n], n]RSolveValue[ a[n + 1] a[n] - 2 a[n] + 2 == 0, a, n]Solutions in terms of trigonometric and hyperbolic functions:
RSolveValue[a[n + 1] == (40 + 21 a[n] - 24 a[n] ^ 2 + 4 a[n] ^ 3) / 9, a[n], n]RSolveValue[a[n + 1] == (-7300 + 9600 a[n] + 300 a[n] ^ 2 - 200 a[n] ^ 3 + a[n] ^ 4/2108 + 584 a[n] - 288 a[n] ^ 2 - 4 a[n] ^ 3 + a[n] ^ 4), a[n], n]RSolveValue[a[n + 1] == (-168 - 36 a[n] + 12 a[n] ^ 2 - a[n] ^ 3/-88 - 12 a[n] + 3 a[n] ^ 2), a[n], n]RSolveValue[ a[n + 2] == a[n + 1] a[n] ^ 2, a[n], n]RSolveValue[ a[n + 2] == b ^ n a[n + 1] a[n] ^ 2, a[n], n]Nonlinear convolution equation:
RSolveValue[{a[n + 1] == Sum[a[m] a[n - m], {m, 0, n}], a[0] == 1}, a[n], n]Systems of Difference Equations (8)
Linear system with constant coefficients:
RSolveValue[{y[n + 1] + z[n] == 3, y[n] + 2 z[n + 1] == 1}, {y[n], z[n]}, n]{sol1, sol2} = RSolveValue[{y[n + 1] + z[n] == 3, y[n] + 2 z[n + 1] == 1, y[0] == 5, z[0] == 1}, {y, z}, n]ListPlot[Transpose @ Table[{sol1[n], sol2[n]}, {n, 0, 15}], Filling -> Axis]RSolveValue[{y[n + 1] == (3y[n]/1 + y[n] + z[n]), z[n + 1] == (z[n]/1 + y[n] + z[n])}, {y[n], z[n]}, n]RSolveValue[{x[n + 1] == (x[n] + 3 y[n]/4 + x[n] + y[n] + z[n]), y[n + 1] == (y[n] + 2 z[n]/4 + x[n] + y[n] + z[n]), z[n + 1] == (z[n]/4 + x[n] + y[n] + z[n])}, {x[n], y[n], z[n]}, n]RSolveValue[{y[n + 1] == (n + 1) / 2 ^ n y[n], z[n + 1] == n ^ 2 z[n]}, {y[n], z[n]}, n]Variable coefficient linear system with a polynomial solution:
RSolveValue[ {-((1 + 3 n + n ^ 2) x[n]/n ^ 2) + x[n + 1] + (y[n]/n) + ((1 + 2 n) z[n]/n ^ 2) == 0, -y[n] + (n ^ 2y[n + 1] + (1 + 2 n) (-x[n] + z[n])/n ^ 2) == 0, (-x[n] + y[n] - n z[n] + n z[n + 1]/n) == 0}, {x, y, z}, n ]Linear constant coefficient difference-algebraic system:
RSolveValue[{y[n + 1] + z[n + 1] == y[n] - 3z[n], y[n] + 2z[n] == 1}, {y[n], z[n]}, n]RSolveValue[{x[n + 1] == x[n] + 2y[n], y[n] == x[n] + 2 ^ n, x[n] + z[n] == 0}, {x[n], y[n], z[n]}, n]Solve a linear system using vector variables:
a = {{n, 1}, {1, 0}};RSolveValue[x[n + 1] == a.x[n], Element[x[n], Vectors[2]], n]Alternatively, define
as a VectorSymbol:
x = VectorSymbol["x", 2]RSolveValue[x[n + 1] == a.x[n], x[n], n]Solve a linear system using matrix variables:
a = {{0, 1}, {-1, 0}};
x0 = {{1, 2}, {3, 4}};RSolveValue[{x[n + 1] == a.x[n], x[0] == x0}, Element[x[n], Matrices[{2, 2}]], n]//MatrixFormAlternatively, define
as a MatrixSymbol:
x = MatrixSymbol["x", {2, 2}]RSolveValue[{x[n + 1] == a.x[n], x[0] == x0}, x[n], n]//MatrixFormSolve an inhomogeneous linear system of ODEs with constant coefficients:
A = {{2, 1}, {-2, 0}};
B = {3t, 4}Exp[2t];RSolveValue[x[t + 1] + A.x[t] == B, Element[x[t], Vectors[2]], t]Partial Difference Equations (3)
First-order linear partial difference equation with constant coefficients:
RSolveValue[a[m + 1, n] - 3 / 4a[m, n + 1] == 0, a[m, n], {m, n}]Substitute the function Sin[2k] for the free function C[1]:
% /. C[1] -> Function[k, Sin[2k]]Plot3D[%, {m, 0, 10}, {n, 0, 10}, PlotRange -> All]Constant coefficient linear equation of orders 2, 3, and 4:
RSolveValue[ a[m + 2, n] == 4a[m, n + 1], a[m, n], {m, n}]RSolveValue[ a[m + 3, n] - 3a[m + 2, n + 1] + 3a[m + 1, n + 2] - a[m, n + 3] == 0, a[m, n], {m, n}]RSolveValue[a[m + 4, n] - 4a[m + 3, n + 1] + 6a[m + 2, n + 2] - 4a[m + 1, n + 3] + a[m, n + 4] == 0, a, {m, n}]RSolveValue[a[m + 1, n] - 4a[m, n + 1] == 6m ^ 2 n + 4, a[m, n], {m, n}]Variable coefficient linear equation:
RSolveValue[ a[m, n] - m a[m - 1, n - 1] == 0, a[m, n], {m, n}]RSolveValue[a[m, n] == m ^ 3a[m + 1, n + 1] , a, {m, n}]Q–Difference Equations (6)
First-order constant coefficient
-difference equation:
RSolveValue[a[q n] == 2a[n], a[n], n]Equivalent way of expressing the same equation:
RSolveValue[a[n] == 2a[n / q], a[n], n]RSolveValue[{a[n] == 2a[n / q], a[1] == 1}, a[n], n]RSolveValue[a[q n] + a[n / q] == 0, a[n], n]RSolveValue[a[n] == a[n / q ^ 3], a, n]RSolveValue[a[q ^ 2 n] + a[n] == n, a[n], n]RSolveValue[{a[n] == 3 a[n / 2] + n, a[1] == 1}, a[n], n]DiscretePlot[%, {n, 1, 10}, Filling -> Axis]Linear varying coefficient equations:
RSolveValue[a[q n] == n a[n], a, n]RSolveValue[a[q ^ 2 n] == n a[n], a, n]RSolveValue[ a[q n] == a[n] ^ 2, a, n]RSolveValue[a[q n] == -(a[n] + 15) / (a[n] + 7), a[n], n]A linear constant coefficient system of
-difference equations:
RSolveValue[{y[q ^ 2 n] - z[q n] == 0, z[q n] - 5 y[n] == 0}, {y[n], z[n]}, n]Functional Difference Equations (4)
Find the general solution for an arithmetic difference equation:
sol = RSolveValue[y[n + (1/3)] == 2 y[n + (1/6)] + n^2, y, n]y[n + 1 / 3] == 2y[n + 1 / 6] + n ^ 2 /. {y -> sol}//FullSimplifySolve an initial value problem for an arithmetic-geometric difference equation:
sol = RSolveValue[{y[n] == 2^n y[(n/2) + 1], y[3] == 4}, y, n]ListLogPlot[Table[sol[n], {n, 3, 10}], Filling -> Axis]Solve a linear fractional difference equation:
sol = RSolveValue[{y[(2 n - 1/-n + 2)] == 3 y[n] + 5, y[4] == 3}, y, n]Make a table of values for the solution:
Table[sol[n], {n, 4, 10}]Solve a geometric power difference equation:
sol = RSolveValue[y[n] == Log[2, n] + 2 y[4 Sqrt[n]], y, n]y[n] == Log[2, n] + 2 y[4 Sqrt[n]] /. {y -> sol}//FullSimplifyLimits of Recursive Sequences (5)
Compute the limit of a linear recursive sequence:
RSolveValue[{x[n + 1] == (x[n] + n x[n - 1]) / (n + 1), x[0] == 0, x[1] == 1}, x[∞], n]N[%]Visualize the convergence of the sequence to its limiting value:
ListPlot[RecurrenceTable[{x[n + 1] == (x[n] + (n x[n - 1])) / (n + 1), x[0] == 0, x[1] == 1}, x[n]//Evaluate, {n, 1, 50}], PlotStyle -> Red]Compute the limit of a nonlinear recursive sequence:
RSolveValue[{x[n + 1] == x[n] ^ 2 + 1 / 4, x[0] == 1 / 3}, x[∞], n]Visualize the convergence of the sequence to its limiting value:
ListPlot[RecurrenceTable[{x[n + 1] == x[n] ^ 2 + 1 / 4, x[0] == 1. / 3}, x[n]//Evaluate, {n, 0, 20}], PlotStyle -> Red]Compute the limit of a trigonometric recursive sequence:
RSolveValue[{x[n + 1] == Cos[x[n]] / 2, x[1] == π / 3}, x[∞], n]N[%]Visualize the convergence of the sequence to its limiting value:
ListPlot[RecurrenceTable[{x[n + 1] == Cos[x[n]] / 2, x[1] == π / 3}, x[n], {n, 1, 15}], PlotStyle -> Red]Compute the limit of a second-order recursive sequence:
RSolveValue[{x[n + 2] == (x[n + 1] + x[n]) / 2, x[0] == 0, x[1] == 1}, x[∞], n]Visualize the convergence of the sequence to its limiting value:
ListPlot[RecurrenceTable[{x[n + 2] == (x[n + 1] + x[n]) / 2, x[0] == 0, x[1] == 1}, x[n], {n, 1, 25}], PlotStyle -> Red]Compute the limit of the ratio of adjacent terms, f[n+1]/f[n], for the Fibonacci sequence, which satisfies the difference equation:
fibeqn = {f[n] == f[n - 1] + f[n - 2], f[0] == 0, f[1] == 1};Solve the difference equation to find the ratio:
frat = RSolveValue[fibeqn, f[n + 1] / f[n], n]Compute the limit of the ratio using DiscreteLimit:
ratlim = DiscreteLimit[frat, n -> ∞]N[%]Visualize the convergence of the sequence to its limiting value:
ListPlot[Table[frat, {n, 1, 25}], PlotStyle -> Red]Alternatively, compute the limit using DiscreteLimit in RSolveValue itself:
RSolveValue[fibeqn, DiscreteLimit[f[n + 1] / f[n], n -> ∞], n]System Models (7)
Calculate the OutputResponse and StateResponse of a discrete-time StateSpaceModel for a sinusoidal input:
ssm = StateSpaceModel[{{{a}}, {{b}}, {{c}}, {{d}}}, SamplingPeriod -> 1]RSolveValue[Sin[t] -> ssm, "StateResponse", t]RSolveValue[Sin[t] -> ssm, "OutputResponse", t]The output response of a transfer function model to a sinusoidal input:
tfm = TransferFunctionModel[{{{1}}, 1 + s}, s, SamplingPeriod -> 0.1]RSolveValue[Sin[10t] -> tfm, "OutputResponse", t]The response of a state-space model from nonzero initial conditions:
RSolveValue[{0 -> StateSpaceModel[{{{-2, 0.8, 0}, {-0.8, -2, 0}, {0, 0, -1}}, {{1}, {0}, {-1}}, {{1, 0, 0}}, {{0}}},
SamplingPeriod -> 0.2, SystemsModelLabels -> None], {1, 2, 3}}, "OutputResponse", t]The state response of a single-input system to a unit step input:
τ = 1.5;
sr = RSolveValue[UnitStep[k] -> StateSpaceModel[{{{0, 1}, {-1/20, 3/5}}, {{0}, {1}}, {{0, 1}}, {{0}}},
SamplingPeriod -> τ, SystemsModelLabels -> None], "StateResponse", k]Plot the response for eight steps:
ListStepPlot[Table[sr, {k, 0, 8}], DataRange -> {0, 8 τ}]The state response for a generic discrete-time system:
RSolveValue[{u[k] -> StateSpaceModel[{{{a}}, {{b}}}, SamplingPeriod -> T,
SystemsModelLabels -> None], {Subscript[x, 0]}}, "StateResponse", k]The output response to a unit step sequence:
RSolveValue[{1 -> StateSpaceModel[{{{a}}, {{b}}, {{c}}, {{d}}},
SamplingPeriod -> T, SystemsModelLabels -> None], {Subscript[x, 0]}}, "OutputResponse", k]The output response of a discrete-time system to a time-dependent input:
or = RSolveValue[Sqrt[k] -> TransferFunctionModel[{{{(1 + z)*τ^2}}, 2*(-1 + z)^2},
z, SamplingPeriod -> τ], "OutputResponse", k]ListStepPlot[Table[or /. τ -> 0.1, {k, Range[20]}], DataRange -> {0, 20 0.1}]Generalizations & Extensions (2)
Obtain an expression for the square of the solution:
RSolveValue[{a[n + 1] == a[n] + 1, a[0] == 0}, a[n] ^ 2, n]No boundary condition gives two generated parameters:
RSolveValue[{a[n + 2] == 4a[n]}, a[n], n]RSolveValue[{a[n + 2] == 4a[n], a[0] == 1}, a[n], n]RSolveValue[{a[n + 2] == 4a[n], a[0] == 1, a[1] == 4}, a[n], n]Options (3)
GeneratedParameters (1)
Method (1)
Solve a linear ordinary difference equation:
RSolveValue[{a[n + 1] - 2a[n] == 0, a[0] == 1}, a[n], n]Obtain a solution in terms of DifferenceRoot:
RSolveValue[{a[n + 1] - 2a[n] == 0, a[0] == 1}, a[n], n, Method -> "Holonomic"]Assumptions (1)
Solve a second-order linear ordinary difference equation:
RSolveValue[{a[n + 2] == λ a[n], a[0] == 0, a[1] == 1}, a[n], n]Use Assumptions to specify that the parameter λ is positive:
RSolveValue[{a[n + 2] == λ a[n], a[0] == 0, a[1] == 1}, a[n], n, Assumptions -> λ > 0]Simplify[%]Applications (13)
This models the amount a[n] at year n when the interest r is paid on the principal p only:
RSolveValue[{a[n + 1] == a[n] + r p, a[0] == p}, a[n], n]//FactorHere the interest is paid on the current amount a[n], i.e. compound interest:
RSolveValue[{a[n + 1] == (1 + r)a[n], a[0] == p}, a[n], n]Here a[n] denotes the number of moves required in the Tower of Hanoi problem with n disks:
RSolveValue[{a[n + 1] == 2a[n] + 1, a[1] == 1}, a[n], n]Here a[n] is the number of ways to tile an n×3 space with 2×1 tiles:
sol = RSolveValue[{a[n + 4] - 4a[n + 2] + a[n] == 0, a[1] == 0, a[2] == 3, a[3] == 0, a[4] == 11}, a, n]Table[Evaluate[sol[n]], {n, 2, 20, 2}]//FullSimplifyThe number of comparisons for a binary search problem:
RSolveValue[b[n] == b[n / 2] + 1 && b[1] == 1, b[n], n]Number of arithmetic operations in the fast Fourier transform:
RSolveValue[f[n] == 2 f[n / 2] + (3 / 2)n, f[n], n]The nested radical
satisfies a nonlinear difference equation:
RSolveValue[{x[n + 1] == Sqrt[6 + x[n]], x[1] == Sqrt[6]}, x[3], n]Compute the exact value of the nested radical:
RSolveValue[{x[n + 1] == Sqrt[6 + x[n]], x[1] == Sqrt[6]}, x[∞], n]Visualize the convergence of the sequence to the exact value:
ListPlot[RecurrenceTable[{x[n + 1] == Sqrt[6 + x[n]], x[1] == Sqrt[6]}, x[n], {n, 1, 15}], PlotStyle -> Red]The integral
satisfies the difference equation:
RSolveValue[{e[n + 1] == 1 / n(Exp[-x] - x e[n]), e[1] == Gamma[0, x]}, e[n], n]The integral
satisfies the difference equation:
RSolveValue[{i[n + 2] - 2Cos[ϕ]i[n + 1] + i[n] == 0, i[0] == 0, i[1] == Pi}, i[n], n]The difference equation for the series coefficients of
:
RSolveValue[{n a[n] == 2a[n - 2], a[0] == 1, a[1] == 0}, a[n], n]Table[%, {n, 0, 10}]DSolveValue[{y'[x] == 2x y[x], y[0] == 1}, y[x], x]Series[%, {x, 0, 10}]SeriesCoefficient[Exp[x ^ 2], {x, 0, n}]Table[%, {n, 0, 10}]The determinant of an n×n tridiagonal matrix with diagonals c, a, b satisfies:
RSolveValue[{d[n + 2] == a d[n + 1] - b c d[n], d[1] == a, d[2] == a ^ 2 - b c}, d[n], n]Table[%, {n, 2, 5}]//SimplifyTable[Det @SparseArray[{Band[{1, 1}] -> a, Band[{1, 2}] -> b, Band[{2, 1}] -> c}, {n, n}], {n, 2, 5}]This models the surface area s[n] in dimension n of a unit sphere:
RSolveValue[{s[n + 2] == 2Pi / n s[n], s[2] == 2Pi, s[3] == 4Pi}, s[n], n]Table[%, {n, 2, 10}]The volume of the unit ball in dimension n:
RSolveValue[{v[n] == 2Pi v[n - 2] / n, v[2] == Pi, v[3] == 4 / 3Pi}, v[n], n]Table[%, {n, 2, 10}]Applying Newton's method to
, or computing
:
RSolveValue[y[n + 1] == (1 / 2)(y[n] + 3 / y[n]) && y[0] == 1 / 5, y[n], n]Table[%, {n, 1., 6}]//ChopApplying the Euler forward method to
yields:
sol = RSolveValue[ {(101 y[n]/100) - 2 y[n + 1] + y[n + 2] == 0, y[0] == 1, y[1] == 1}, y, n]Plot[sol[k], {k, 0, 10}]dsol = DSolveValue[ y''[x] + 1 / 100y[x] == 0 && y[0] == 1 && y[1] == 1, y, x]Plot[dsol[x], {x, 0, 10}]Solve the difference equation that describes the complexity of Karatsuba multiplication:
ksol = RSolveValue[ {t[n] == 3 t[n / 2 + 1] + n , t[3] == 1}, t[n], n ]Compare with the complexity of schoolbook multiplication:
DiscretePlot[{ksol, n ^ 2}, {n, 5, 300}, PlotLegends -> {"Karatsuba", "Schoolbook"}]Efficiently compute the n
term of a linear recurrence for large n:
RSolveValue[{x[n + 4] == 3x[n + 3] + x[n + 2] + x[n + 1] + 4 x[n], x[1] == 1, x[2] == -37, x[3] == 9, x[4] == 80}, x[500], n]//AbsoluteTimingRSolveValue[{x[n + 4] == 3x[n + 3] + x[n + 2] + x[n + 1] + 4 x[n], x[1] == 1, x[2] == -37, x[3] == 9, x[4] == 80}, x[500000], n];//AbsoluteTimingProperties & Relations (10)
RSolveValue returns an expression for the solution:
RSolveValue[a[n + 1] - 2a[n] == 1, a[n], n]RSolve returns a rule for the solution:
RSolve[a[n + 1] - 2a[n] == 1, a[n], n]Solutions satisfy their difference and boundary equations:
sol = RSolveValue[{a[n + 2] == a[n], a[0] == 1, a[1] == 2}, a, n]{a[n + 2] == a[n], a[0] == 1, a[1] == 2} /. {a -> sol}//SimplifyDifference equation corresponding to Sum:
RSolveValue[a[n + 1] - a[n] == n ^ 2 && a[0] == 0, a[n], n]//ExpandSum[i ^ 2, {i, 0, n - 1}]//ExpandDifference equation corresponding to Product:
RSolveValue[a[n + 1] == n a[n] && a[1] == 1, a[n], n]//FunctionExpandProduct[i, {i, 1, n - 1}]//FunctionExpandRSolveValue finds a symbolic solution for this difference equation:
RSolveValue[{a[n + 1] == 2a[n] + 1, a[0] == 7}, a[n], n]Table[%, {n, 0, 7}]RecurrenceTable generates a procedural solution for the same problem:
RecurrenceTable[{a[n + 1] == 2a[n] + 1, a[0] == 7}, a, {n, 0, 7}]FindLinearRecurrence finds the minimal linear recurrence for a list:
FindLinearRecurrence[Table[Fibonacci[k], {k, 7}]]RSolveValue finds the sequence satisfying the recurrence:
RSolveValue[{a[n] == %.{a[n - 1], a[n - 2]}, a[1] == 1, a[2] == 1}, a[n], n]LinearRecurrence generates the n
term for a linear recurrence:
LinearRecurrence[{1, 1}, {1, 1}, {7}]Obtain the same result using RSolveValue:
RSolveValue[{a[n + 2] == a[n + 1] + a[n], a[0] == 1, a[1] == 1}, a[6], n]Use RecurrenceFilter to filter a signal:
RecurrenceFilter[{{1, -(1/2)}, {1}}, {1, 0, 0, 0, 0, 0, 0, 0}]Solve the corresponding difference equation using RSolveValue:
RSolveValue[{y[n] - (1/2)y[n - 1] == DiscreteDelta[n], y[-1] == 0}, y[n], n]Table[%, {n, 0, 7}]Forecast the next value for a time series based on ARProcess:
proc = ARProcess[{a[2], a[1]}, v];TimeSeriesForecast[proc, {3, 5}]Obtain the same result using RSolveValue:
RSolveValue[{x[n + 1] == a[2] x[n] + a[1]x[n - 1], x[1] == 3, x[2] == 5}, x[3], n]//SimplifyUse RFixedPoints to find the fixed points for a system of two recurrence equations:
RFixedPoints[{a[n + 1] - b[n] == 2, a[n] - 3 b[n + 1] == 5}, {a, b}, n]Use RStabilityConditions to analyze the stability of the fixed point:
RStabilityConditions[{a[n + 1] - b[n] == 2, a[n] - 3 b[n + 1] == 5}, {a, b}, n]Solve the system using a fixed point as the initial condition:
sol = RSolveValue[{a[n + 1] - b[n] == 2, a[n] - 3 b[n + 1] == 5, a[0] == 1 / 2, b[0] == -3 / 2}, {a[n], b[n]}, n]Solve the system for given initial conditions:
sol = RSolveValue[{a[n + 1] - b[n] == 2, a[n] - 3 b[n + 1] == 5, a[0] == 3, b[0] == 1}, {a[n], b[n]}, n]DiscretePlot[Evaluate[sol], {n, 0, 20}]Possible Issues (4)
Capital
and capital
cannot be used as independent variables:
RSolveValue[{x[K + 1] == x[K] + Prime[K]}, x[K], K]RSolveValue[{x[C + 1] == x[C] + Prime[C]}, x[C], C]Replacing them by lowercase
or lowercase
fixes the issue:
RSolveValue[{x[k + 1] == x[k] + Prime[k]}, x[k], k]RSolveValue[{x[c + 1] == x[c] + Prime[c]}, x[c], c]The solution to this difference equation is unique as a sequence:
RSolveValue[a[n + 1] == 2a[n] && a[0] == 1, a, n]As a function it is only unique up to a function of period 1:
a[n + 1] == 2a[n] && a[0] == 1 /. a -> Function[n, 2 ^ n + a Sin[Pi n]]Simplify[ %, n∈Integers ]RSolveValue returns only a single branch if the solution has multiple branches:
RSolveValue[{a[n + 1] == 2a[n], a[1] ^ 2 == 1}, a[n], n]Use RSolve to get all of the solution branches:
RSolve[{a[n + 1] == 2a[n], a[1] ^ 2 == 1}, a[n], n]Verify the solution when the equation involves subscripted variables:
eqn = Subscript[a, n + 1] - 2 Subscript[a, n] == 1;Subscript[sol, n_] = RSolveValue[eqn, Subscript[a, n], n]Simplify[eqn /. {a -> sol}]Neat Examples (1)
Compute the n
iterate or composition of a function:
RSolveValue[{a[n + 1] == (2a[n] + 3/a[n] + 4), a[0] == 0}, a[n], n]Table[%, {n, 0, 10}]NestList[(2 # + 3/1 # + 4)&, 0, 10]Apply[Composition, Table[(2 # + 3/1 # + 4)&, {10}]][0]Related Guides
History
Introduced in 2014 (10.0) | Updated in 2017 (11.2) ▪ 2022 (13.1) ▪ 2023 (13.3) ▪ 2024 (14.0) ▪ 2025 (14.2)
Text
Wolfram Research (2014), RSolveValue, Wolfram Language function, https://reference.wolfram.com/language/ref/RSolveValue.html (updated 2025).
CMS
Wolfram Language. 2014. "RSolveValue." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/RSolveValue.html.
APA
Wolfram Language. (2014). RSolveValue. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RSolveValue.html
BibTeX
@misc{reference.wolfram_2026_rsolvevalue, author="Wolfram Research", title="{RSolveValue}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/RSolveValue.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_rsolvevalue, organization={Wolfram Research}, title={RSolveValue}, year={2025}, url={https://reference.wolfram.com/language/ref/RSolveValue.html}, note=[Accessed: 12-June-2026]}