2

I've seen the solution of this Solve the recurrence $T(n) = 2T(n-1) + n$ So I have done 1) $T(n)=2T(n-5)+n$ , $T(n-5)=2T(n-2\cdot5)+(n-5)$ e.t.c , my final line is $$T(n)=2^kT(n-5k)+\sum_{j=0}^{k-5} 2^j(n-j).$$ Any help? From link I can't figure out how the sum works on my case.

Robert Z
  • 145,942
Thanos
  • 21
  • https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference –  Oct 02 '19 at 16:24
  • The command of Maple allvalues(rsolve({T(1) = 1, T(n) = 2*T(n - 5) + n}, T(n))) produces a long output depending on $T(2),\dots,T(5)$. – user64494 Oct 02 '19 at 16:29
  • The problem here is you have not specified $T(2)$, $T(3)$, $T(4)$, and $T(5)$. So it is not sure how for example $T(7)$ would be defined. – Math1000 Oct 06 '19 at 02:04

2 Answers2

1

My compulsion for generality leads me to consider $t(n) = at(n-m)+f(n) $.

Then

$\begin{array}\\ t(n) &= at(n-m)+f(n)\\ &= a(at(n-2m)+f(n-m))+f(n)\\ &= a^2t(n-2m)+af(n-m)+f(n)\\ &= a^2(at(n-3m)+f(n-2m))+af(n-m)+f(n)\\ &= a^3t(n-3m)+a^2f(n-2m)+af(n-m)+f(n)\\ ...\\ &= a^kt(n-km)+\sum_{j=0}^{k-1}a^jf(n-jm)\\ &\text{induction step:}\\ &= a^k(at(n-(k+1)m)+f(n-km))+\sum_{j=0}^{k-1}a^jf(n-jm)\\ &= a^{k+1}t(n-(k+1)m)+a^kf(n-km)+\sum_{j=0}^{k-1}a^jf(n-jm)\\ &= a^{k+1}t(n-(k+1)m)+\sum_{j=0}^{k}a^jf(n-jm)\\ \end{array} $

Setting $k =\lfloor \dfrac{n}{m} \rfloor $ and $h = n-km$, we have $0 \le h \le m-1 $.

Then $t(n) =a^kt(n-km)+\sum_{j=0}^{k-1}a^jf(n-jm) =a^kt(h)+\sum_{j=0}^{k-1}a^jf(n-jm) $.

If $f(n) = n$,

$\begin{array}\\ t(n) &=a^kt(h)+\sum_{j=0}^{k-1}(n-jm)a^j\\ &=a^kt(h)+n\sum_{j=0}^{k-1}a^j-m\sum_{j=0}^{k-1}ja^j\\ &=a^kt(h)+n\dfrac{a^k-1}{a-1}-m\dfrac{(k - 1) a^{k + 1} - k a^k + a}{(a - 1)^2}\\ &=a^kt(h)+\dfrac{n(a-1)(a^k-1)-m((k - 1) a^{k + 1} - k a^k + a)}{(a - 1)^2}\\ &=a^kt(h)+\dfrac{n(a^{k+1}-a^k-a+1)-m((k - 1) a^{k + 1} - k a^k + a)}{(a - 1)^2}\\ &=a^kt(h)+\dfrac{a^{k+1}(n-m(k-1))+a^k(km-n)-n(a-1)-am}{(a - 1)^2}\\ &=a^kt(h)+\dfrac{a^{k+1}(h+m)-ha^k-n(a-1)-am}{(a - 1)^2}\\ \end{array} $

marty cohen
  • 107,799
0

Assume that $n=5a+b$ with $0\leq b<5$, with $T(n)=2T(n-5)+n$ for $a=\lfloor n/5\rfloor>0$, then $$\boxed{\quad T(n)=2^a(T(b)+b+10)-n-10\quad}$$ We verify the solution by induction. It works for $n=b$ (i. e. $a=0$), and, for the inductive step, $$T(n+5)=2T(n)+n+5=2(2^a(T(b)+b+10)-n-10)+n+5 \\=2^{a+1}(T(b)+b+10)-(n+5)-10.$$

Robert Z
  • 145,942