0
$\begingroup$

Function: enter image description here

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]
$\endgroup$
  • 1
    $\begingroup$ RSolve may help. $\endgroup$ – OkkesDulgerci Feb 10 at 10:53
  • $\begingroup$ because you haven't set a boundary condition. $\endgroup$ – wuyudi Feb 10 at 12:46
  • $\begingroup$ It seems a duplicate question is posted. Please see my solution here. $\endgroup$ – Αλέξανδρος Ζεγγ Feb 10 at 14:15
1
$\begingroup$
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
|improve this answer|||||
$\endgroup$
0
$\begingroup$

Try

T[0] = 1;
T[1] = x;
T[n_] := (1/x) T[n - 2] - (2/7) T[n - 1];
|improve this answer|||||
$\endgroup$
  • 1
    $\begingroup$ I would recommend T[n_] := T[n] = (1/x).... Without memoization, this recursion is going to be awfully inefficient. $\endgroup$ – Sjoerd Smit Feb 10 at 14:13
0
$\begingroup$

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 *)
|improve this answer|||||
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.