Solution (source code)

= Solution

Relative vertical <vorticity> is the horizontal <Laplacian> of the <streamfunction>, not its full stretched three-dimensional <Laplacian>. Inside the <spherical potential-vorticity anomaly>, the quadratic solution gives
$$
\boxed{q_g=\psi_{xx}+\psi_{yy}=2Q_0/3>0.}
$$
Outside, in the equatorial plane $Z=0$, let $s=(x^2+y^2)^{1/2}>R$ and $C=Q_0R^3/3$. The azimuthal <velocity> is $v_\theta=\psi_s=C/s^2$, so
$$
\boxed{q_g=\frac1s\frac d{ds}(s v_\theta)=-\frac{C}{s^3}=-\frac{Q_0R^3}{3s^3}<0.}
$$
The opposite signs thus follow directly from solid-body rotation inside and the exterior <velocity>'s rapid radial decay. The azimuthal <velocity> itself has the same rotational sense on both sides; its radial derivative makes the exterior <relative vorticity> negative.

There is no contradiction with the zero exterior PV anomaly. At $Z=0$ the exterior solution has $\psi_{ZZ}=C/s^3$, so $q_g+\psi_{ZZ}=0$. The <stratification>/stretching contribution compensates the horizontal <relative vorticity>. Inside it contributes $Q_0/3$, supplementing $2Q_0/3$ to give the prescribed excess $Q_0$.