Let $\frac13\sin a-\frac17\cos a=\frac{1}{2017}.$ ...

Let $a$ in $[0, \pi]$ such that $\frac13\sin a-\frac17\cos a=\frac{1}{2017}.$ If $\lvert\tan{a}\rvert=\frac mn$, where m and n are relatively prime, find m+n.

My work:

$\frac13\sin a-\frac17\cos a=\frac{1}{2017}$
From the trig identity $a \cos{t} + b \sin{t} = \sqrt{a^2 + b^2} \; \sin(t + \tan^{-1} \frac{a}{b})$ it follows that:
$\sqrt{\frac{1}{9}+\frac{1}{49}}\sin (a-\arctan{\frac37})=\frac{1}{2017}$
$a=\arcsin{\frac{1}{2017\sqrt{\frac{58}{441}}}}+\arctan{\frac37}$
...

From here I bashed out long equations using more trig identities/cancelling by taking the sine of both sides, but I did not get a fraction and the work is not worth putting here. I'm assuming the approach of using $a \cos{t} + b \sin{t} = \sqrt{a^2 + b^2} \; \sin(t + \tan^{-1} \frac{a}{b})$ was somehow incorrect or I made a simple error somewhere later on.

When I originally tried solving this problem I multiplied through by 3*7*2017 but this leads to the same issue and gigantic numbers everywhere.

Is there a better approach to solving this?

This question was from the AMSP 2017 Test C entrance exam.

Use the tangent half angle formulas. If $$x = \tan \frac{a}{2}$$ then

$$\sin a = \frac{2x}{1+x^2}$$

$$\cos a = \frac{1 - x^2}{1 + x^2}$$

$$\tan a = \frac{2x}{1 - x^2}$$

The given equation gives a quadratic in $x$.

We know that $x \ge 0$ (as $a/2$ is acute). So pick the positive root (if there is only one positive root, I am guessing that will happen I haven't tried it myself).

If that root is $\gt 1$, then $a \gt \frac{\pi}{4}$ and gives you the sign of $\tan a$.

As $\tan=\frac \sin\cos$, we may assume $\sin a= mu$, $\cos a=\pm nu$. Thus $$\frac m3u\mp\frac n7u =\frac1{2017}$$ or $$u=\frac{21}{2017\cdot (7m\mp 3n)}.$$ Additionally, $$1=\sin^2a+\cos^2a=(m^2+n^2)u^2$$ so that elimination gives $$2017^2\cdot(7m\mp 3n)^2=21^2\cdot (m^2+n^2).$$ The left hand side is either odd or a multiple of $4$; the right hand side is either odd (if exactly one of $n,m$ is odd) or $\equiv 2\pmod 8$ (if both are odd). We conclude that both sides are odd and exactly one of $n,m$ is even and one is odd.

Now let $p$ be any prime $\ne 2017$ and assume $p^k\mid m^2+n^2$ with $k\ge 1$ (so $p\ne2$). It follows that $k$ is even and $p^{ k/2}\mid 7m\mp 3n$, as well as $p^{k/2}\mid (7m-3n)(7m+3n)=49m^2-9n^2$, as well as $p^{k/2}\mid 49m^2-9n^2+9(m^2+n^2)=58m^2$, and similarly $p^{k/2}\mid-58n^2$. From $\gcd(m,n)=1$, it follows that $p=29$ and $k=2$. It cannot happen that $29^3\mid m^2+n^2$ Therefore, $$7m\mp 3n=21\cdot 29^a\cdot2017^b,\qquad m^2+n^2=29^{2a}\cdot2017^{2b+2}$$ with $a\in\{0,1\}$ and $b\ge0$.

The simplest integer solution to this are obtained for $a=0$, $b=0$ from the observation that $44^2+9^2=2017$ and $(44+9i)^2=1855+792i$. Luckily, $3\cdot 1855-7\cdot 792=21$, which suggests the solution $m=792$, $n=1855$. As of now, I do not see a fast way to show that there is no other solution (i.e., no solution with $a=1$ or $b>0$),