Find all natural numbers $x,y$ such that $3^x=2y^2+1$. Find all natural numbers $x,y$ such that 
$$3^x=2y^2+1$$
solutions are $(1,1)$, $(2,2)$, $(5,11)$. I found that parity of both is same and If $x$ Is odd it is of the form $4k+1$. 
 A: There are no solutions other than the three that
Satvik Mashkaria exhibited.
This is proved in the paper

Jungmin Ahn, Hyun Kwang Kim, Jung Soo Kim, and Mina Kim: Classification of perfect linear codes with crown poset structure, Discrete Math. 268 (2003), 21-30.

See Lemma 3 of "2.2 The ternary case", pages 26-29.
The proof of Ahn, Kim, Kim, and Kim starts by factoring $2y^2+1$
over the ring ${\bf Z}[\sqrt{2}]$ (as suggested in a comment by
user236182), and then uses Skolem's $p$-adic method (with $p=2$);
thus their proof is basically elementary, but not easy.
The existence of several $(x,y)$, including the large-ish $(5,11)$,
suggests that there might not be a really simple proof that no further
solutions exist.
[added later: It turns out that in this case Skolem's method is not
necessary: it's enough to solve one Pell equation and do a bunch of
arithmetic modulo $27$ and either $17$ or $19$.  This yields a proof of
only half a page or so, instead of the 3-page proof of Ahn et al.;
see my second answer to this question.]
This Diophantine equation arises naturally in coding theory.
The existence of $x$ such that $3^x = 2y^2+1$
is a necessary condition for the existence of a perfect
2-error-correcting ternary code; the solutions with $y=1$ and $y=2$
correspond to trivial (one-word) codes, and the $y=11$ solution
corresponds to the
ternary
Golay code.
A: Rewrite as
$$3^x-1=2y^2$$
$$(3-1)(1+3+\cdots+3^{x-1})=2y^2$$
$$y^2=1+3+\cdots+3^{x-1}$$
So... perfect squares that are sums of consecutive powers of 3. In other words, perfect squares that in base-3 system write as all ones, and we can seek for $y$ written in ternary $y=(\ldots y_2y_1y_0)_3$. This can then be understood as applying the digit-by-digit square root algorithm in base-3 on all-ones numbers. The algorithm adds two digits to the radicand for each new digit of the result, so there are essentially two paths of calculation: even and odd number of ones. We get to a solution each time the algorithm terminates without residue at the desired number of digits.
Solutions are $\sqrt{(1)_3}=(1)_3$, $\sqrt{(11111)_3}=(102)_3$ and $\sqrt{(11)_3}=(2)_3$. For even-digit and odd-digit, these are truncations of $\sqrt{3/2}=\sqrt{(1.111\cdots)_3}=(1.02000121112\cdots)_3$  and $\sqrt{9/2}=\sqrt{(11.111\cdots)_3}=(2.0100211\cdots)_3$.
I really think there's a more elegant solution, but this one feels interesting because it looks at the problem differently. I'm not sure how to prove that after a while the algorithm never terminates again. Hopefully, one of you will comment to point out something obvious here.
A: There is a "standard" way to attack this using Thue's theorem, by writing the left hand side as $z^3$, $3 z^3$, or $9 z^3$, depending on the assumed residue $x \pmod 3$.  I can't imagine doing a search up to any of the effective versions of Thue's bound on the size of the solutions during an Olympiad.
Some of the comments are close to suggesting that we attack this as a Pell equation, so I have started that below.  I don't know how to finish either case.  Perhaps one of the commenters would be willing to edit in a completion to either case below.
If $x$ is even, $x = 2k$, this is the Pell equation $(3^k)^2 - 2 y^2 = 1$.  The usual technique for finding the minimal solution, constructing convergents of the continued fraction for $\sqrt{2}$, gives the integer solutions $$\begin{align}
    3^k &= \frac{1}{2} \left( (3-2\sqrt{2})^n + (3+2\sqrt{2})^n \right) \\
    y   &= \frac{-1}{2\sqrt{2}} \left( (3-2\sqrt{2})^n - (3+2\sqrt{2})^n \right),
\end{align}$$ for any integer $n$ (and not yet applying the restriction that $k$ be a positive integer).  Note that $y>0$ requires $n \geq 0$.  In fact, $n=0$ gives $3^k = 1$, so $k$ and $x$ are both zero (and $x = 0$ is not allowed).  Hence, $n > 0$.
If $x$ is odd, $x = 2k+1$, we multiply through by $3$ to get $3^2 (3^k)^2 - 6 y^2 = 3$, another Pell equation, whose integer solutions are $$\begin{align}
    3 \cdot 3^k &= \frac{1}{2}\left( (3+\sqrt{6}) (5-2\sqrt{6})^n + (3 - \sqrt{6})(5+2\sqrt{6})^n \right) \\
    y           &= \frac{-1}{4} \left( (2+\sqrt{6})(5-2\sqrt{6})^n + (2 - \sqrt{6})(5+2\sqrt{6})^n\right),
\end{align}$$ for any integer $n$ (and not yet applying the restriction that $k$ be a positive integer).  Note that $y>0$ requires $n>0$.
It's not clear to me that the $k \in \Bbb{N}$ restriction is straightforward to apply to either of these.  But I would be happy for someone(s) to edit in a completion to either of the above.
A: Here's a somewhat simpler proof using Pell equations
(as Eric Towers suggested might be possible).
If $x$ is odd, say $x=2k+1$, then $3z^2 = 2y^2 + 1$ where $z = 3^k$.
Hence $(2y)^2 - 6z^2 = -2$ and we have
$$
2y + 3^k \sqrt{6} = (2+\sqrt{6}) (5 + 2\sqrt{6})^m
$$
for some $m=0,1,2,\ldots$.  The first two solutions $m=0$, $m=1$ give
$z=1$, $z=9$ which recovers the known solutions with $x=1$ and $x=5$.
Suppose $k>2$.  Then $z = 3^k \equiv 0 \bmod 27$, and by computing powers of
$5 + 2 \sqrt{6}$ mod $27$, we find that $27 \mid z$ if and only if
$m \equiv 4 \bmod 9$.  But then $z$ is always a multiple of the $m=4$ solution
(in general if $2m+1 \mid 2m'+1$ then the $m$-th $z$ divides the $m'$-th one),
and the $m=4$ solution has $z = 8721 = 3^3 17 \, 19$.  So $z$ can never be
a power of $3$ once $k>2$.
If $x$ is even, say $x=2k$, then $2y^2 = 3^{2k} - 1 = (3^k-1) (3^k+1)$.
Hence $3^k-1$ is either a square or twice a square, and the former is
impossible (no square is congruent to $-1 \bmod 3$).  So $3^k-1 = 2{y'}^2$
for some integer $y'$, giving a smaller solution $(k,y')$ to $3^x = 2y^2 + 1$.
Continuing in this fashion eventually yields a solution with $x$ odd. 
But that solution cannot be $(x,y) = (5,11)$, because
$(3^{10} - 1) / 2 = 2^2 11^2 61$ is not a square.  This leaves
the $(x,y) = (1,1)$ solution, and indeed $(x,y) = (2,2)$ also works
as we know $-$ but $x=4$ does not because $(3^4 - 1)/2 = 40$
is not a square either.  This completes the proof that the three solutions
with $x=1,2,5$ are the only ones. 
