Clear["Global`*"]
eqns = {t[n + 1] == 1/x t[n - 1] - 2/7 t[n], t[0] == 1, t[1] == x};
For comparison, use RSolve
to obtain the general solution
sol = RSolve[eqns, t, n][[1]];
t[n] /. sol
(* (1/(2 Sqrt[
49 + x]))7^-n (-Sqrt[x] (-1 - Sqrt[49 + x]/Sqrt[x])^n -
7 x^(3/2) (-1 - Sqrt[49 + x]/Sqrt[x])^n +
Sqrt[49 + x] (-1 - Sqrt[49 + x]/Sqrt[x])^n +
Sqrt[x] (-1 + Sqrt[49 + x]/Sqrt[x])^n +
7 x^(3/2) (-1 + Sqrt[49 + x]/Sqrt[x])^n +
Sqrt[49 + x] (-1 + Sqrt[49 + x]/Sqrt[x])^n) *)
Verifying the result
eqns /. sol // Simplify
(* {True, True, True} *)
Defining with Which
Clear[t]
t[n_Integer?NonNegative] := t[n] =
Which[
n == 0, 1,
n == 1, x,
n > 1, 1/x*(t[n - 2]) - 2/7*(t[n - 1])]
m = 8;
seq = t /@ Range[m] // Simplify
(* {x, 1/x - (2 x)/7,
1 - 2/(7 x) + (4 x)/49, -(4/7) + 1/x^2 + 4/(49 x) - (8 x)/343, (-1372 +
2345 x + 588 x^2 + 16 x^3)/(
2401 x^2), -(32/343) + 1/x^3 + 12/(49 x^2) - 2042/(2401 x) - (32 x)/
16807, (-100842 + 106673 x + 57400 x^2 + 3920 x^3 + 64 x^4)/(
117649 x^3), -((-823543 - 403368 x + 913752 x^2 + 191632 x^3 + 9408 x^4 +
128 x^5)/(823543 x^4))} *)
Comparing the results with the general solution from RSolve
seq == ((t /. sol) /@ Range[m]) // Simplify
(* True *)
Using FindSequenceFunction
to generalize from the sequence
sol2 = FindSequenceFunction[seq, n]
(* (1/(2 Sqrt[
49 + x]))7^-n (-Sqrt[x] (-1 - Sqrt[49 + x]/Sqrt[x])^n -
7 x^(3/2) (-1 - Sqrt[49 + x]/Sqrt[x])^n +
Sqrt[49 + x] (-1 - Sqrt[49 + x]/Sqrt[x])^n +
Sqrt[x] (-1 + Sqrt[49 + x]/Sqrt[x])^n +
7 x^(3/2) (-1 + Sqrt[49 + x]/Sqrt[x])^n +
Sqrt[49 + x] (-1 + Sqrt[49 + x]/Sqrt[x])^n) *)
Comparing the RSolve
result with the FindSequenceFunction
result
(t /. sol)[n] == sol2
(* True *)