HP Forums

Full Version: Ellipsoid surface area
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
semi-axis, a ≥ b ≥ c
cos(φ) = c/a
m = (a²(b²-c²)) / (b²(a²-c²))
I = cos(φ)^2 * elliptf(φ,m) + sin(φ)^2 * ellipte(φ,m)

→ S = 2*pi*(c² + a*b/sin(φ)*I)

HP Prime does not have elliptf(ϕ,m) and ellipte(ϕ,m), we might as well combine I, as 1 integral

Let t = sin(ϕ)^2 = 1-(c/a)^2, s = √t = sin(ϕ):

I = (1-t) * ∫(1/√((1-x²)*(1-m*x²)), x=0..s) + t * ∫(√((1-m*x²)/(1-x²)), x=0..s)
I = ∫((1-m*t*x²) / √((1-x²)*(1-m*x²)), x=0..s)

Code:
#cas
ellipsoid_area(a,b,c)
BEGIN
    local m, t, s, x;
    c,b,a := sort(a,b,c);   // a >= b >= c
    t := 1.-(c/a)^2;
    if t==0 then return 4.*pi*a*c END
    s := sqrt(t);           // sin(acos(c/a))
    m := (b+c)*(b-c) / (b*b*t);
    m := int((1-m*t*x*x)/sqrt((1-x*x)*(1-m*x*x)), x, 0., s);
    return 2.*pi*(c*c + a*b/s*m);
END
#end

CAS> ellipsoid_area(1.1,1.2,4.7)             → 54.6901240998

Example from The Surface Area Of An Ellipsoid, A. Dieckmann, Universität Bonn, July 2003

A good estimate with Thomsen formula, rel. err ≤ 1.061%

CAS> ellipsoid_area_est(a,b,c) := 4*pi*mean(([a*b,a*c,b*c]).^p)^(1/p) | p = 1.6075

CAS> ellipsoid_area_est(1.1,1.2,4.7)       → 54.4952199737
Sorting the semi-axis may not be necessary.
This version removes semi-axis sorting step.
Also, test for perfect sphere is also eliminated.

Technically, with ellipsoid symmetry, input can be in any order.
However, we wanted to avoid catastrophic cancellation of terms.

As long as user input is in sorted order (or reverse sorted), it will give good result.
In other words, I am basing length relative to b.

Code:
#cas
ellipsoid_area(a,b,c)
BEGIN
    local t1, t2, x;
    t1 := 1.-(b/a)^2;
    t2 := 1.-(b/c)^2;
    t2 := int((1-t1*t2*x*x)/sqrt((1-t1*x*x)*(1-t2*x*x)), x, 0., 1);
    return 2.*pi*(b*b+t2*a*c);
END
#end

Note the t1, t2 symmetry. Swapping (a,c) returns same result.

CAS> ellipsoid_area(1,1,1)       → 12.5663706144 (4*pi)
CAS> ellipsoid_area(1,2,3)       → 48.8821463026
CAS> ellipsoid_area(1,3,2)       → 48.8821463026
CAS> ellipsoid_area(3,1,2)       → 48.8821463026

I confirmed numbers with keisan Online Calculator
For a,b,c = 3,2,1: S = 48.8821463025820596957
This version use Carlson symmetric elliptic integrals, to avoid integration.

\(F\!\left(\phi, m\right) = \sin(\phi) R_F\!\left(\cos^{2}\!\left(\phi\right), 1 - m \sin^{2}\!\left(\phi\right), 1\right)\)

\(F\!\left(\phi, m\right) - E\!\left(\phi, m\right) = \frac{1}{3} m \sin^{3}\!\left(\phi\right) R_D\!\left(\cos^{2}\!\left(\phi\right), 1 - m \sin^{2}\!\left(\phi\right), 1\right)\)

We force R arguments to get close, with Duplication theorems.
Assume x,y,z > 0 (x or y can be zero, but not both)
Let λ = √(xy) + √(yz) + √(xz) > 0:

RF(x,y,z) = RF(x+λ, y+λ, z+λ)*2
RD(x,y,z) = RD(x+λ, y+λ, z+λ)*2 + 3/(√(z)*(z+λ))

If arguments close enough, we can stop.

RF(x,x,x) = x^(-1/2)
RD(x,x,x) = x^(-3/2)

From AM-GM inequality, we have (x+y)/2 ≥ √(xy)

λ = √(xy) + √(yz) + √(xz) ≤ (x+y)/2 + (y+z)/2 + (x+z)/2 = x+y+z

Code assumed λ*(1+1e-12) > x+y+z, we consider x,y,z close enough.

Code:
#cas
RFD(x,y,z)  // return RF(x,y,z), RD(x,y,z)
BEGIN
    LOCAL rx,ry,rz,k;
    rx := sqrt(approx(x));
    ry := sqrt(approx(y));
    rz := sqrt(approx(z));
    k := rx*(ry+rz) + ry*rz;
    rx := k*(1+1e-12) > x+y+z; // x,y,z close ?
    IF rx THEN rx:=sqrt(3/k); return rx, 3*rx/k END 
    rx, ry := RFD(x+k, y+k, z+k);
    return rx*2, ry*2 + 3/(rz*(z+k));
END;

ellipsoid_area(a,b,c)
BEGIN
    LOCAL rf, rd, k;
    rf := approx(b/a)^2;
    rd := approx(b/c)^2;
    k := (1-rf)*(1-rd)/3;
    rf, rd := RFD(rf,rd,1);
    return 2.*pi*(b*b+(rf-k*rd)*a*c);
END;    
#end

>>> mp.pretty = True
>>> elliprf(1,2,3), elliprd(1,2,3) # see https://mpmath.org/doc/current/functions/elliptic.html
(0.726945935468908, 0.290460281028991)

CAS> RFD(1,2,3)                     → [0.726945935469, 0.290460281029]
CAS> ellipsoid_area(1,2,3)       → 48.8821463026

Numerical Recipes, Elliptic Integrals: https://core.ac.uk/download/pdf/211378009.pdf
HP-41 Module: Elliptic Functions and Orthogonal Polynomials, ellipsoid area example (page 9), using RG
(05-30-2021 06:04 PM)Albert Chan Wrote: [ -> ]HP-41 Module: Elliptic Functions and Orthogonal Polynomials, ellipsoid area example (page 9), using RG

From formula, S = 4*pi*RG((a*b)^2, (a*c)^2, (b*c)^2), we reverse it, for definition of RG:
Code:
#cas
RG(x,y,z)
BEGIN
    local ab, ac, bc;
    ab, ac, bc := map(sqrt, [x,y,z]);
    x, z := RFD(x,z,y); // relative to b^2
    z *= (bc-ac)*(bc+ac)*(ab-ac)*(ab+ac)/3;
    return (ab*bc/ac + (x*y-z))/2;
END;  
#end

CAS> ellipsoid_area(2,4,9)               → 283.427384268
CAS> 4*π*RG(8^2,18^2,36^2)       → 283.427384268
Reference URL's