= Solution
On a chart with $x\ne0$, set
$$
\boxed{f(x,y)=\arctan\!\left(\frac{by}{ax}\right)+C.}
$$
The <chain rule> verifies both components:
$$
f_x=\frac1{1+(by/(ax))^2}\left(-\frac{by}{ax^2}\right)
=-\frac{aby}{D}=P,\qquad
f_y=\frac1{1+(by/(ax))^2}\frac{b}{ax}
=\frac{abx}{D}=Q.
$$
A coordinate-independent description of the local potential is a continuous branch of $\arg(ax+iby)$, the <complex argument> of the scaled coordinates. Such branches can also cover points where $x=0$, using a different angular chart. Continuing once around the missing origin changes that angle by a nonzero multiple of $2\pi$, so \b[there is no global single-valued $f$ on the full stated domain].
Back to article page