Linear Recurrences I was working on linear recurrence... But I am having trouble with it.
$a_0 = 1;
a_1 = 2;
a_k = 4a_{k-1} - 2a_{k-2}$
I found $a_2$ which is $$4a_1 - 2 a_0=4\cdot2 - 2\cdot 1 = 6$$
I found $a_3$ which is $$4a_2 - 2 a_1= 4 \cdot6 - 2 \cdot 2= 20$$
I found $a_4$ which is $$4a_3 - 2 a_2=4 \cdot 20 - 2 \cdot 6 = 68$$
Now I am looking for general formula of n'ts term... And I am having difficulties wih it.
I brought it to quadratic:
$$a_k = 4a_{k-1} - 2a_{k-2}$$
$$a_k-4a_{k-1}+ 2a+{k-2} = 0$$
$$r^k-4a^{k-1} + 2a^{k-2}=0$$
I did substitution
$$r^k-2 (r^2-4r +2)$$
Now I am solving quadratic $r^2 - 4r +2=0$
$$D = b^2 - 4ac$$
$$D = 16 - 8$$
$$r = \frac{4\pm\sqrt{8}}4$$
And now I have problems.
Even if I solve $r_1$ and $r_2$
it will give me $r_1=3.41$ and $r_2 = 0.59 $
(all troncated)
Now if i have discriminant positive I a substituting it into the formula
$$a(k) = Ar_1^k + Br_2^k$$
It gives me $1 = A\cdot3.41^0 + 0.59\cdot{B^0}$
$$A + B = 1$$
And
$$3.41\cdot{A^1} + B\cdot0.59^1 = 2$$
And I have a system:
$$A+2 = 1$$
$$3.41A + 0.59B = 2$$
I substitute and solve it...
$$A = 1-B$$
$$3.41(1-B) + 0.59B = 2$$
$$3.41 - 3.41B + 0.59B = 2$$
$$3.41 - 4B = 2$$
$$4B = 1(1.41)$$
$$B = 0.35$$
$$A + 0.35 =1$$
$$A = 0.65$$
Final Formula
$$0.65 (3.41)^k + 0.35(0.59)^k$$
I believe I did it incorectrly.  Because when I am trying to use my formula it does not return correct results for my sequence.
It works with a(1) where k is 0. But it does not work with a(2) and a(3) etc...
I troncated the results so it is easier to type what I did. I did my best to show what I did.
Please, help me with it. Help me understand how to do it and where I did wrong.
Please, help me guys.
 A: For a cleaner resolution:
Trying an exponential behavior $a_k=r^k$ gives
$$r^k=4r^{k-1}-2r^{k-2},$$i.e. for a nontrivial solution ($r\ne0$)$$r^2-4r+2=0.$$
By the well-known quadratic formula
$$r=2\pm\sqrt2,$$
so that a general solution is of the form
$$a_k=a(2+\sqrt2)^k+b(2-\sqrt2)^k.$$
Plugging the initial conditions allows to solve for the constans $a,b$:
$$a_0=1=a(2+\sqrt2)^0+b(2-\sqrt2)^0=a+b.$$
$$a_1=2=a(2+\sqrt2)^1+b(2-\sqrt2)^1=2+\sqrt2(a-b)\implies a=b.$$
Then
$$\color{green}{a_k=\frac12(2+\sqrt2)^k+\frac12(2-\sqrt2)^k}.$$
As one checks,
$$a_0=\frac12+\frac12=1.$$
$$a_1=\frac12(2+\sqrt2)+\frac12(2-\sqrt2)=2.$$
$$a_2=\frac12(2+\sqrt2)^2+\frac12(2-\sqrt2)^2=2^2+\sqrt2^2=6=4\cdot2-2\cdot1.$$
$$a_3=\frac12(2+\sqrt2)^3+\frac12(2-\sqrt2)^3=2^3+3\cdot2\cdot\sqrt2^2=20=4\cdot6-2\cdot2.$$
$$\cdots$$
A: Sorry, but how did you come up with r = 2 + or - sqrt(2) ???
As the quadratic formula is D = b^2 - 4ac, what will give us
4^2 - 4*1*2 = 16-8
D = 8
Sorry for messy dispay . I have not learnt how to use formulas yet.
If it is not hard for you could you please explain to me where did you get sqrt(2) because as far as I can see discriminant is 8.
Because I do want to understand this.
If it is not hard for  you, please explain.
And yes, I definetelly will learn how no use formulas!
