# Directly Obtain Solution Expressions for Difference Equations

Directly obtain an expression for the solution of an OΔE using RSolveValue.

 In[1]:= Xsol = RSolveValue[{a[n + 1] - a[n] == (-1)^n n, a[0] == 1}, a[n], n]
 Out[1]=

Plot the solution.

 In[2]:= XDiscretePlot[sol, {n, 0, 30}]
 Out[2]=

Directly compute the differences of the solution of an OΔE.

 In[3]:= XRSolveValue[{a[n + 1] - a[n] == n^2, a[0] == 1}, DifferenceDelta[a[n], n], n] // Simplify
 Out[3]=

Solve for arbitrary expressions involving the dependent variables.

 In[4]:= XRSolveValue[{y[n + 1] == 3 z[n], z[n + 1] == 2 y[n], y[0] == 1, z[0] == 3}, y[n], n]
 Out[4]=
 In[5]:= XRSolveValue[{y[n + 1] + z[n] == 3, y[n] + 2 z[n + 1] == 1, y[0] == 1, z[0] == 2}, y[1] + z[5]^2, n]
 Out[5]=
 In[6]:= XRSolveValue[{y[n + 1] + z[n] == 3, y[n] + 2 z[n + 1] == 1, y[0] == 1, z[0] == 2}, \!\( \*UnderoverscriptBox[\(\[Sum]\), \(n = 0\), \(m\)]\((y[n] + z[n])\)\), n]
 Out[6]=

Obtain a pure function solution for a nonlinear second-order OΔE.

 In[7]:= Xeqn = a[n + 2] == a[n + 1] a[n]^2;
 In[8]:= Xsol = RSolveValue[eqn, a, n]
 Out[8]=

Verify the solution.

 In[9]:= Xeqn /. {a -> sol} // FullSimplify
 Out[9]=

## Mathematica + Mathematica Online

Questions? Comments? Contact a Wolfram expert »