1
$\begingroup$

I've got a pretty simple equation set here but I cannot seem to solve it correctly.

T[0] = 1;

T[1] = 2;

f[i_] := T[i] - T[i + 1] == T[i + 1] - T[i + 2]

c = And @@ Array[f, 3, 0]

Solve[c, T[4]]

The answer only gave me the following

-1 == 2 - T[2] && 2 - T[2] == T[2] - T[3] && 
T[2] - T[3] == T[3] - T[4]

Instead of solving for T[4], so where did I messed up ? Thanks!

$\endgroup$
  • $\begingroup$ Eliminate[c, T[3]] gives T[2] == 3 && T[4] == 5 $\endgroup$ – Rolf Mertig Oct 4 '15 at 22:11
  • $\begingroup$ What happens if you ask it to solve for three of the variables? $\endgroup$ – Michael E2 Oct 4 '15 at 22:12
  • $\begingroup$ I would like see the answer to that question as well:) $\endgroup$ – Fang Oct 4 '15 at 22:14
  • $\begingroup$ @Fang Well, try it. :) $\endgroup$ – Michael E2 Oct 4 '15 at 22:24
5
$\begingroup$

It seems like you have the recursion t[i+2] = 2*t[i+1]-t[i]. Shifting this back two timesteps allows a standard form:

t[i_] := 2 t[i - 1] - t[i - 2];
t[0] = 1;
t[1] = 2;

which can be solved for any i:

t[#] & /@ Range[10]
$\endgroup$
4
$\begingroup$

Using recursion (NOTE that recursion can go either up or down)

Clear[t]

t[0] = 1;
t[1] = 2;
t[i_Integer?Positive] :=
  t[i] = 2 t[i - 1] - t[i - 2];
t[i_Integer?Negative] :=
  t[i] = 2 t[i + 1] - t[i + 2];

list1 = t /@ Range[-5, 5]

(*  {-4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6}  *)

The general solution is

FindSequenceFunction[
  Thread[Range[-5, 5] -> list1]][i]

(*  1 + i  *)

You can use RSolve to find the general solution more directly

Clear[t]

t[i_] = t[i] /.
  RSolve[{t[0] == 1, t[1] == 2,
     t[i] == 2 t[i - 1] - t[i - 2]},
    t[i], i][[1]]

(*  1 + i  *)

list2 = t /@ Range[-5, 5]

(*  {-4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6}  *)

Approaches are equivalent.

$\endgroup$
0
$\begingroup$

Reduce or FindInstance handles your problem. I switched to lower case t as it is recommended not to use uppercase letters at the beginning of a symbol.

t[0] = 1;
t[1] = 2;
f[i_] := t[i] - t[i + 1] == t[i + 1] - t[i + 2]
c = And @@ Array[f, 3, 0]

produces

-1 == 2 - t[2] && 2 - t[2] == t[2] - t[3] && t[2] - t[3] == t[3] - t[4]

and then

Reduce[c, t[4]]

gives

t[3] == 4 && t[2] == 3 && t[4] == 5

and

FindInstance[c, {t[2], t[3], t[4]}]

gives

{{t[2] -> 3, t[3] -> 4, t[4] -> 5}}
$\endgroup$
  • $\begingroup$ This is exactly what I'm looking for. I was quite confused about the use of Eliminate and Reduce but now I can see the difference. Thanks for the help. $\endgroup$ – Fang Oct 5 '15 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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