Search code examples
phpmathpi

elipsoid area function not giving correct results


I have created a function to return the surface area of a given ellipsoid dimension but i am getting strange results.

Here is the function:

function elipsoid($a,$b,$c){
    
    $ab=$a*$b;
    $ab=pow($ab,1.6);
    
    $ac=$a*$c;
    $ac=pow($ac,1.6);
    
    $bc=$b*$c;
    $bc=pow($bc,1.6);
    
    $abacbc=$ab+$ac+$bc;
    $abacbc=$abacbc/3;
    
    $prepie=pow($abacbc,0.016);
    
    $fourpies=3.1415926535898*4;
    
    $elipsoidarea=$prepie*$fourpies;
    
    
    return $elipsoidarea;
    
}

If values of $a,$b,$c are all =1 the result is 12.566370614359 which according to the ellipsoid calculator on google is correct.

If values of $a,$b,$c are all =2 the result is 13.02034823541 which according to the ellipsoid calculator on google should be 50.26548.

I had my teenage daughter help translate this:

S≈4π((ab)1.6+(ac)1.6+(bc)1.63)1/1.6 (copy pasted from google hence doesn't look like the equation now lol).

Into "idiot" form such that I can understand it.

Is the calculation translation correct and/or have I coded it right? I also question how according to google a 4m wide sphere can have a surface area of 50m? Is Google wrong as well as the many sites that have this calculation option?


Solution

  • your doing wrong here,

    $prepie = pow($abacbc,0.016); 
    

    It should be,

    $prepie = pow($abacbc,0.625); 
    

    As of this,

    Formula

    root of 1.6 -> 1/1.6 -> 0.625