Let T(1)=a, T(2)=b, and T(n) = 2T(n-1)-T(n-2)+1, for n>2
I'm trying to find the closed form of T(n) by repeated substitution and guess a closed form substitution.
Then I got
$f(n) = 2f(n-1) - f(n-2) +1$
$=2[2f(n-1-1) - f(n-1-2)+1]-[2f(n-2-1)-f(n-2-2)+1]+1$
$=2[2f(n-2) - f(n-3)+1]-[2f(n-3)-f(n-4)+1]+1$
$=4f(n-2)-2f(n-3)+2-2f(n-3)+f(n-4)-1+1$
$=4f(n-2)-4f(n-3)+f(n-4)+2$
$=4[2f(n-3)-f(n-4)+1]-4[2f(n-4)-f(n-5)+1]+[2f(n-5)-f(n-6)+1]+2$
$=8f(n-3)-4f(n-4)+4-8f(n-4)+4f(n-5)-4+2f(n-5)-f(n-6)+3$
$=8f(n-3)-12f(n-4)+6f(n-5)-f(n-6)+3$
$=8[2f(n-4)-f(n-5)+1]-12[2f(n-5)-f(n-6)+1]+6[2f(n-6)-f(n-7)+1]-[2f(n-7)-f(n-8)+1]+3$
$=16f(n-4)-8f(n-5)+8-24f(n-5)+12f(n-6)-12+12f(n-6)-6f(n-7)+6-2f(n-7)+f(n-8)-1+3$
$=16f(n-4)-32f(n-5)+24f(n-6)-8f(n- 7)+f(n-8)+4$
But I cannot see a pattern to guess a closed form. Where I am wrong? Thank!
-
This question has been asked before and has answers. See https://math.stackexchange.com/a/3464854/ – Gottfried Helms Dec 06 '19 at 11:38
5 Answers
To see the pattern, you need to tame the substitutions so that the number of terms doesn't grow. Only expand the first term each time, and you will keep manageable expressions. (For short, $U_k$ is $T(n-k)$.)
$$U_0=2U_1-U_2+1\\ =2(2U_2-U_3+1)-U_2+1=3U_2-2U_3+3\\ =3(2U_3-U_4+1)-2U_3+3=4U_3-3U_4+6\\ =4(2U_4-U_5+1)-3U_4+6=5U_4-4U_5+10\\ =5(2U_5-U_6+1)-4U_4+10=6U_5-5U_6+15\\ \cdots$$
Now you clearly see that the coefficients of $U$ are the sequence of naturals and the constant terms are the triangular numbers.
$$U_0=(k+1)U_k-kU_{k+1}+\frac{k(k+1)}2.$$
With $k=n-2$, this is
$$T(n)=(n-1)T(2)-(n-2)T(1)+\frac{(n-2)(n-1)}2\\ =(n-1)b-(n-2)a+\frac{(n-2)(n-1)}2.$$
Hint: if $S(1)=T(1)$ and $S(n)=T(n)-T(n-1)$ the $S(n)=S(n-1)+1$. From this you can show that $S(n)=n-1+S(1)=n-1+a$. Now use the fact that $T(n)=T(1)+S(2)+S(3)+\cdots+S(n)$

- 311,013
Try computing $T(3),\ T(4)$ and $T(5)$. Then you should be able to guess the closed form of $T(n)$. Then prove it by induction.

- 105
Let us use $S(n)=T(n)-T(n-1)$, then $$T(n)-2T(n-1)+T(n-2)=1 \implies [T(n)-T(n-1)]-[T(n-1-T(n-2)]=1$$ $$ \implies S(n)-S(n-1)=1 $$ By telescopivc summing we get $$S(n)-S(2)=n -2 \implies S(n)=n-2+c$$ Here $S(2)=T(2)-T(1)=b-a=c$. Next $$S(n)=T(n)-T(n-1)=n-2+c$$ again by telescopic summing starting from $n=2$, we get $$T(n)-T(1)=\frac{(n-1)(n-2)}{2}+(n-1)c \implies T(n)=\frac{(n-1)(n-2)}{2}+(n-1)c+a$$

- 43,235
Remark: a general ansatz which avoids guesses & pattern-detection. A copy of my answer to the earlier instance (Mar 2016) of this problem linked to in my comment to the OP
I like to express recursions of this type by matrix-expressions, such that with a initial vector $[1,a,b]$ we get by the transfer matrix $M$ the vector $[1,b,c]$ where $b$ and $c$ are defined by one step of the recursion.
For your problem $$ M = \begin{bmatrix} 1&0&1 \\\ 0&0&-1 \\\ 0&1&2 \end{bmatrix}$$
and then
$$ [1,a_1,a_2] \cdot M^h = [1,a_h,a_{h+1}] \tag 0 $$
where $h$ is then the iteration-"height".
Often diagonalization of the transfermatrix $M$ allow then the direct expression of the matrixpower $M^h$ in a formula with $h$ kept indeterminate.
In your case I don't find a diagonalization for $M$ but a "similarity"-transformation of $M$ into $D$ such that with the orthogonal ("rotation"-) matrix $T$ and a triangular matrix $D$ $$ M = T^\tau \cdot D \cdot T \tag 1$$ such that $$ M^h = T^\tau \cdot D^h \cdot T \tag 2 $$
Here the superpostfix $\tau$ at matrixname $T$ means "transpose" but, because $T$ is constructed to be orthogonal, means also the inverse and thus we have indeed a "similarity" transformation.
Here $D$ has the identity-diagonal and $D^h = \exp(h \cdot \log(D))$ can be given in exact polynomial terms of $h$.
Let's denote $q = \sqrt {0.5}$ then I found that a valid solution for $T$ is
$$ T= \begin{bmatrix} 0&0&1 \\\ q&-q&0 \\\ q&q&0 \end{bmatrix} \tag 3
$$
then
$$ D= T^\tau \cdot M \cdot T=
\begin{bmatrix} 1&0&0 \\\ 2&1&0 \\\ q&q&1 \end{bmatrix} \tag 4$$
The matrix-logarithm of $D$ is then
$$ \Lambda= \log(D)=
\begin{bmatrix} 0&0&0 \\\ 2&0&0 \\\ 0&q&0 \end{bmatrix} \tag 5$$
and $D^h$ has then the simple form
$$ D^h = \exp(h \cdot \Lambda) =
\begin{bmatrix} 1&0&0 \\\ 2h&1&0 \\\ q \cdot h^2&q \cdot h&1 \end{bmatrix} \tag 6
$$
and $M^h$ is then
$$M^h = T \cdot D^h \cdot T^\tau =
\begin{bmatrix} 1& \frac12 h(h-1)& \frac 12 h(h+1) \\\ 0&1-h&-h \\\ 0& h&h+1 \end{bmatrix} \tag 7$$
and thus using eq $(0)$
$$ [1, a_1, a_2] \cdot M^h = [1, a_h, a_{h+1}] \\\
a_{h+1}= \left([1,a_1,a_2] \cdot M^h\right) [3] $$
we get
$$ a_{h+1} = \frac12h(h+1) -h\cdot a_1 + (h+1) a_2 \tag 8$$
Remarks:
- the equation (5) can exactly be determined by the mercatorseries for $(D-I)$ because $D-I$ is nilpotent and the series collapses to a finite sum.
- the equation (6) can exactly be determined by the common exponential-series on $ h\cdot \Lambda$ because $ h\cdot \Lambda$ is nilpotent and the exponential series collapses to a finite sum.

- 34,920