# Near-integer solutions to $y=x(1+2\sqrt{2})$ given by sequence - why?

EDIT: I've asked the same basic question in its more progressed state. If that one gets answered, I'll probably accept the answer given below (although I'm uncertain of whether or not this is the community standard; if you know, please let me know).

I've found a sequence $x_{i+1}=\|x_i(2+k)\|$, where $k=1+2\sqrt{2}$ and where $||a||$ rounds $a$ to the nearest integer, that seems to minimize the distance $P_n$ to an integer solution (for $x$ and $y$) of the equation in the title. $P_n$ is more rigorously defined as the absolute value of $\|y_n\|-y_n$, where $y_n=nk$ for $n \in \mathbb{N}$.

Starting with $x_0=1$ the sequence becomes $x_1=\|2+k\|=\|5.83\ldots\|=6,x_2=\|6(2+k)\|=\|34.97\ldots\|=35,204,1189,6930,\ldots$ where $P_i$ very quickly becomes small.

In Fig. 1 below, I've plotted $P_n$ for $n$. In Fig. 2 only low values of $P$ is shown and it seems that the $P_i$'s from the sequence (in red) are the lowest value up until that $n$ (I've checked this up to $n=10^6$).

My main question is this: Why does this sequence give the solutions nearest integer-solutions? (Edit for further clarification:) And why are these the nearest up until that point (see Fig. 2)? Can it be proven, starting from the original equation, that the elements in this sequence will give the best approximations to integers up until that point, e.g. that it's error dies off faster than all other possible sequences?

Fig. 1

Fig. 2

Further questions: I've also "found" something that looks like an attractor, see Fig. 3 below. Can someone explain what is going on here? I haven't really studied dynamical systems, so if you could dumb it down a bit, I'd be grateful.

Also, as seen in Fig. 1, there's a high degree of regularity here, with all the seemingly straight lines. If I remove the absolute value-part of the def. of $P_n$ the cross-pattern in Fig. 1 becomes (seemingly) straight, parallel declining lines. Why do these lines form? Could it be explained via some modular arithmetic?

Fig. 3

Thanks!

EDIT: Changed "Bonus" to "Further", as I would also really like to hear answers to these questions. Should I post a new question with these, so I could accept an answer there that answers just those?

• Maybe you are interested in why $(3+2\sqrt{2})^n$ is nearly an integer. Imagine calculating $(3+2\sqrt{2})^n+(3-2\sqrt{2})^n$, say using the binomial theorem. The $\sqrt{2}$ stuff cancels, and we get an integer.. But $(3-2\sqrt{2})^n$ goes to $0$ fast, so for largish $n$ the number $(3+2\sqrt{2})^n$ is nearly an integer. – André Nicolas Jan 3 '16 at 22:11
• Very nice, thanks! But I'm still interested in knowing why this sequence is the best (quickest) at producing integers. – Bobson Dugnutt Jan 3 '16 at 22:16
• There are lots of others with similar properties, coming out of other Pell equations. For example $(2+\sqrt{3})^n$. – André Nicolas Jan 3 '16 at 22:22

$$\left( 3 + \sqrt 8 \right)^n + \left( 3 - \sqrt 8 \right)^n$$ is an integer, while $$3 - \sqrt 8 = \frac{1}{3 + \sqrt 8}$$ has absolute value smaller than one.
My sequence would be $$x_{n+2} = 6 x_{n+1} - x_n$$ with $x_0 = 2,$ $x_1 = 6,$ $x_2 = 34$
I think I see what you did. Instead of taking powers $\left( 3 + \sqrt 8 \right)^n,$ you took the nearest integer and multiplied by it again. So you get $1,6,35,204,$ but once the error is small enough you also settle into the necessary $x_{n+2} = 6 x_{n+1} - x_n .$ That is, you have $x_1 = 6,$ $x_2 = 35,$ $x_3 = 204,$ $x_4 = 1189,$ $x_5 = 6930,$ $x_6 = 40391.$ Start it with $x_0 = 1,$ because you have $$\left( \frac{8 + 3 \sqrt 8}{16} \right)\left( 3 + \sqrt 8 \right)^n + \left( \frac{8 - 3 \sqrt 8}{16} \right)\left( 3 - \sqrt 8 \right)^n$$ This is equal to $$\left( \frac{ \sqrt 8}{16} \right) \left( \left( 3 + \sqrt 8 \right)^{n+1} - \left( 3 - \sqrt 8 \right)^{n+1} \right)$$
• Thanks for the answer! I see why $(3+\sqrt{8})^n$ produces integers, but I'm still puzzled as to why exactly this factor is the one that finds the integers the fastest (see Fig. 2). I'm sorry if your sequence answers this (I didn't get it then), but to me it seems you've just reformulated it? What is the benefit of this? Cheers! – Bobson Dugnutt Jan 4 '16 at 10:47