Anything known about a special case of $(a+b)^{-1} \mod{n}$? Is anything known about $(a+b)^{-1} \mod{n}$ in general? More specifically, I am doing some research in number theory for fun and am looking at something that looks like $Ap + B(p-1) \pmod{p(p-1)}$ (for prime $p$) and am hoping to be able to invert this mod $p(p-1)$. It might be useful to note that the problem that this relates to is about the roots of a certain equation mod $p^2$, and the reason that $p(p-1)$ appears is that $\phi(p^2) = p(p-1)$. (I am a rising junior math major, I have taken number theory at the college level, so if any tools beyond that level are useful, I would appreciate a resource where I could study up on that.)
 A: Well let's assume we know $A^{-1}$ and $B^{-1}$ $\mod p(p-1)$. Then we have
$$\begin{array}{c}
(Ap+B(p-1))^{-1}\equiv A^{-1}\mod p-1 \\
\text{and} \\
(Ap+B(p-1))^{-1}\equiv -B^{-1}\mod p
\end{array}$$
So our inverse is the unique solution $\mod p(p-1)$, $x$, to the system of congruences
$$x\equiv A^{-1}\mod p-1\qquad x\equiv -B^{-1}\mod p$$
Write $x=A^{-1}+k_1(p-1)$ and $x=-B^{-1}+k_2p$. $x$ satisfies the system if and only if it is simultaneously of both these forms and $A^{-1}+B^{-1}=k_2p-k_1(p-1)$. We see that $k_1=k_2=A^{-1}+B^{-1}$ works. So $x=A^{-1}p+B^{-1}(p-1)$ works, giving
$$(Ap+B(p-1))^{-1}\equiv A^{-1}p+B^{-1}(p-1)\mod p(p-1)$$
by CRT. How convenient! I don't think too much is known about $(a+b)^{-1}\mod n$ in general, however.
A: Hint $ $ It's a special case of below where $\,\color{#c00}{p^2\equiv 1}\pmod q,\,\ \color{#0a0}{q^2\equiv 1}\pmod p\ $  hence
$$ \dfrac{1}{ap+bq}\equiv\, p\left(\dfrac{1}{a}\,\bmod\, q\right)\, +\, q\left(\dfrac{1}{b}\,\bmod\, p\right)\pmod{pq} $$
Theorem $\ $ If $\ (p,bq) = 1 = (q,ap)\ $ then
$$ \dfrac{1}{ap+bq}\equiv\, p\left(\dfrac{1}{a\color{#c00}{p^2}}\bmod q\right) + q\left(\dfrac{1}{b\color{#0a0}{q^2}}\bmod p\right)\pmod{pq}$$
Proof $\ $ Mod $p$ boths sides are $\equiv 1/(bq),\,$ and mod $q$ both sides are $\equiv 1/(ap)$ so both sides remain congruent mod $pq$ by CRT, using $(p,q)=1$ (alternatively $\,p,q\mid\rm RHS\! -\! LHS\,$ thus so too does ${\rm lcm}(p,q) = pq),\,$ i.e. we are using the uniqueness of the CRT solution mod $pq$.
