I am to solve for $T_{12}(4.8), T_{24}(1.2)$, using If and Which functions.
I started with this function and keep getting a recursion limit error:
t[n_] := (7/2 x) t[n - 1] - (7/2) t[n + 1]
T[x_, n_] := Block[{temp = n}, Which[
temp == 0, Return[1], temp == 1, Return[x], temp > 1,
1/x T[x, temp - 2] - 2/7 T[x, temp - 1]]]
T[1, 4] gives
167/343
Or as what you want.
T[n_] := Block[{temp = n},
Which[temp == 0, Return[1], temp == 1, Return[x], temp > 1,
1/x T[temp - 2] - 2/7 T[temp - 1]]]
T[4] /. x -> 1
Try
T[0] = 1;
T[1] = x;
T[n_] := (1/x) T[n - 2] - (2/7) T[n - 1];
T[n_] := T[n] = (1/x)...
. Without memoization, this recursion is going to be awfully inefficient.
$\endgroup$
Commented
Feb 10, 2020 at 14:13
Try
Clear[T, n, x]
Tn = T[n] /. RSolve[{T[n + 1] == 1/x T[n - 1] - 2/7 T[n], T[0] == 1, T[1] == x}, T, n][[1]]
Tn /. {n -> 12, x -> 4.8}
(* -0.0153785 *)
RSolve
may help. $\endgroup$