Learning Scientific Programming with Python (2nd edition)

P8.1.4: The surface area of an ellipsoid

Question P8.1.4

An ellipsoid is the three-dimensional figure bounded by the surface described by the equation $$ \frac{x^2}{a^2} + \frac{y^2}{b^2} + \frac{z^2}{c^2} = 1, $$ where $a$, $b$ and $c$ are the semi-principal axes. If $a=b=c$, the ellipsoid is a sphere. The volume of an ellipsoid has a simple form, $$ V = \frac{4}{3}\pi abc. $$ There is no closed formula for the surface area of a general ellipsoid, but it may be expressed in terms of incomplete elliptic integrals of the first and second kinds, $K(\phi, k)$ and $E(\phi, k)$: $$ S = 2\pi c^2 + \frac{2\pi ab}{\sin\phi} \left( K(\phi, k^2)\cos^2\phi + E(\phi, k^2)\sin^2\phi \right), $$ where $$ \cos\phi = \frac{c}{a}, \quad k = \frac{a\sqrt{b^2-c^2}}{b\sqrt{a^2-c^2}} $$ and the co-ordinate system has been chosen such that $a \ge b \ge c$.

Define a function, ellipsoid_surface to calculate the surface area of a general ellipsoid, and compare the results for different-shaped ellipsoids with the following approximate formula: $$ \begin{align*} & S \approx 2\pi c^2 + 2\pi abr\left( 1 - \frac{b^2-c^2}{6b^2}r^2 \left( 1 - \frac{3b^2 + 10c^2}{56b^2}r^2\right) \right),\\ \mathrm{where} \quad& r = \frac{\phi}{\sin\phi}. \end{align*} $$