Geometry for the HP48S/SX/G/GX


 Overview
 

 1°)  Angle between 2 Vectors
 2°)
 Cross Product ( 7D-Vectors )
 3°)  UxV ( n-dimensional Vectors )
 4°)  Distance Point-StraightLine
 5°)  Distance Point-HyperPlane
 6°)  Line-Line Distance
 7°)  Distance Point-HyperEllipsoid
 8°)  Bisecting Hyperplanes
 9°)  Hypersurface Area of a Hyperellipsoid
10°)  Equation of a Hyperplane
11°)  Equation of a Hypersphere
12°)  Heron Formula
13°)  Brahmagupta Formula
14°)  Tetrahedron Volume
15°)  Generating Integer Tetrahedra
16°)  Quadratic Hypersurface
17°)  Jacobi's Method




1°)  Angle between 2 Vectors



 'ANGL'  takes the coordinates of 2 vectors X & Y and returns the angle A

 
          STACK            INPUTS        OUTPUTS
          Level 2       [ x1 , ........ , xn ]               /
          Level 1       [ y1 , ........ , yn ]               A


Example:

 
  [  3   4   1   7 ]  ENTER
  [  4   6   8   9 ]   ANGL    ->   28°324038159


2°)  Cross Product ( 7D-Vectors )


 U(x1,x2,....,x7)   and  V(y1,y2,....,y7)  are two 7D-vectors.

 CROS7 calculates the cross product  W(z1,z2,....,z7) by the formula given   here


          STACK            INPUTS        OUTPUTS
          Level 2       [ x1 , ........ , xn ]               /
          Level 1       [ y1 , ........ , yn ]     [ z1 , ........ , zn ]


Example:
     U( 6  2  4  7  10  13  12 )    V( 4  6  3  2  5  7  8 )

     [ 6  2  4  7  10  13  12 ]  ENTER
     [ 4  6  3  2   5    7    8 ]   CROS7   ->     [ -37  26  73  59  -40  33  -47 ]



3°)  UxV ( N-Dimensional Vectors )


U(x1,x2,....,xn)   and  V(y1,y2,....,yn)  are 2 vectors.

 In n-dimensional spaces, the "cross" product may also be defined as an antisymmetric Tensor  P = [Pi,j]   where  Pi,j = xi.yj - xj.yi         i , j = 1 , 2 , ...... , n



          STACK            INPUTS        OUTPUTS
          Level 2       [ x1 , ........ , xn ]               /
          Level 1       [ y1 , ........ , yn ]            [Pi,j]


Example:
  U(2,3,7,1)   V(3,1,4,6)  

    [ 2  3  7  1 ]   ENTER
    [ 3  1  4  6 ]    UxV         gives the antisymmetrix matrix:

           [[  0   -7  -13   9  ]
            [  7    0     5   17 ]
            [ 13  -5    0   38 ]
            [ -9  -17 -38  0  ]]


4°)  Distance Point-StraightLine


-The point is determined by its coordinates:  P( x1 , ...... , xn )
-The line (L) is defined by 2 points  A( a1 , ...... , an )    B( b1 , ...... , bn )




          STACK            INPUTS        OUTPUTS
          Level 3
      [ x1 , ........ , xn ]
              /
          Level 2       [ a1 , ........ , an ]               /
          Level 1       [ b1 , ........ , bn ]              D


Example:
  (L) is defined by A(2,3,4,5) & B(3,7,11,14)     and     P(1,3,7,9)


    [ 1  3   7    9 ]   ENTER
    [ 2  3   4    5 ]   ENTER
    [ 3  7  11  14 ]   PLN          ->     2.16024689947


5°)  Distance Point-Hyperplane


-The point is determined by its coordinates:  P( x1 , ...... , xn )
-The hyperplane (H) by one of its equations:  a1.x1 + ...... + an.xn + b  = 0



          STACK            INPUTS        OUTPUTS
          Level 2       [ x1 , ........ , xn ]               /
          Level 1     [ a1 , ........ , an , b ]              D


Example:
    (H):  2x + 3y + 4z + 7t - 9 = 0     P(1,3,9,6)

       [ 1  3  9  6 ]     ENTER
    [ 2  3  4  7  -9 ]   PPLN    ->    9.05821627315



6°)  Line-Line Distance


(L) is defined by 2 points A( a1 , ...... , an )  and  B( b1 , ...... , bn )
(L') is defined by 2 points C( c1 , ...... , cn )  and D( d1 , ...... , dn )



          STACK            INPUTS        OUTPUTS
          Level 4
      [ a1 , ........ , an ]
              /
          Level 3
      [ b1 , ........ , bn ]
              /
          Level 2       [ c1 , ........ , cn ]               /
          Level 1       [ d1 , ........ , dn ]            Dist


Example:
     A(2,3,4,5) & B(3,7,11,7)      C(1,2,3,7) & D(3,7,4,10)

    [ 2  3   4   5 ]  ENTER
    [ 3  7  11  7 ]  ENTER
    [ 1  2   3   7 ]  ENTER
    [ 3  7   4  10]    LLN      ->     2.42892317172


7°)  Distance Point-HyperEllipsoid


 DPHE  calculates the distance between a point P( x1 , ...... , xn )  and a hyperellipsoid defined by   (x1/a1)2 + ..... + (xn/an)2 = 1



          STACK            INPUTS        OUTPUTS
          Level 2       [ x1 , ........ , xn ]     [ y1 , ........ , yn ]
          Level 1       [ a1 , ........ , an ]              D

  where  Q( y1 , ........ , yn )  is the point on the hyperellipsoid such that PQ = D

Example:
  (E):   x2 / 49 + y2 / 36 + z2 / 25 + t2 / 16 = 1      P(10,11,12,13)

    [  10  11  12  13 ]  ENTER
    [   7    6    5    4  ]   DPHE   ->   17.81606768  and    [ y1 , ........ , yn ] =  [ 3.46444028983 , 3.08322396764 , 2.55456142811 , 1.91816467489 ]



8°)  Bisecting Hyperplanes


They are defined by the equations   (H) :  a1 x1 + ........ + an xn + b = 0  ,   (H') :   a'1 x1 + ........ + a'n xn + b' = 0

BISHP returns the equations of the bisecting hyperplanes    (H") :  c1 x1 + ........ + cn xn + d = 0  ,   (H'") :   c'1 x1 + ........ + c'n xn + d' = 0


          STACK            INPUTS        OUTPUTS
          Level 2     [ a1 , ........ , an , b ]    [ c1 , ........ , cn , d ]
          Level 1    [ a'1 , ........ , a'n , b' ]    [ c'1 , ........ , c'n , d' ]


Example:
   (H):  x + y + 7 z + 7 t + 4 = 0   (H'): 2 x + 4 y + 4 z + 8 t + 3 = 0

    [ 1   1   7   7   4 ]  ENTER
    [ 2   4   4   8   3 ]  BISHP   ->   [ -0.1 -0.3  0.3 -0.1 0.1 ]  &  [ 0.3  0.5  1.1  1.5  0.7 ]   which may be rewritten:

    (H"):  - x  - 3 y + 3 z - t + 1 = 0   &   (H'"):  3 x + 5 y + 11 z + 15 t + 7 = 0


9°)  Hypersurface Area of a HyperEllipsoid


-The area A of an hypersurface defined by an equation of the form  xN = f( x1 , ............. , xN-1 )  may be calculated by the (N-1) multiple integral:

    A = § ...... §  [ 1 + ( f / x1 )2 + ................. + ( f / xN-1 )2 ] 1/2 dx1  ............. dxN-1                  ( § = Integral )

-Applying this formula to an hyperellipsoid    x12 / a12 + ............... +  xN2 / aN2 = 1     leads to  ( after several changes of variables )
 

   A =  2N a1 ........ aN-1   §0PI/2 ..... §0PI/2 CosN-2 µ1 CosN-3 µ2 .......... Cos µN-1  [ g( µ1 , ....... , µN-1 ) ] 1/2  dµ1  .......... dµN-1

    where   g( µ1 , ....... , µN-1 ) = 1 + (aN2/a12 - 1) Sin2 µ1 + (aN2/a22 - 1) Cos2 µ1 Sin2 µ2 + ......  + (aN2/aN-12 - 1) Cos2 µ1 Cos2 µ2 .... Sin2 µN-1
 

-For N = 4 , we have to compute a triple integral which remains possible in a "reasonnable" time
-For larger N-values, the execution time rapidly becomes prohibitive.

-Fortunately, in reference [1], a method is described to transform the (N-1) multiple integral into a univariate integral.
-With minor modifications and a few simplifications, it yields:

  A = (PI)(N-1)/2 [ a2 ........ aN / Gamma((N+1)/2) ]   §01  f(u) du

       with     f(u) = (1-u)(N-1)/2 u -1/2  [ 1 + SUMi=2,...,N (a12/ai2/bi) ] ( b2 .....  bN ) -1/2        where        bi  =  1 - u + u (a12/ai2)
 

 SAHE uses a Gauss-Chebyshev formula, namely:

     §01  [ (1-x) / x ]1/2  g(x) dx  =  SUMi=1,2,...,n  wi g(xi)

-Unlike many Gaussian formulae, the abscissas & weights may be easily calculated:

    xi =  Sin2 ([ (2i-1) / (2n+1) ] PI/2)    &   wi = [ 2.PI / (2n+1) ] Cos2 ([ (2i-1) / (2n+1) ] PI/2)

-So, we can choose n large enough to get an almost perfect accuracy.



          STACK            INPUTS        OUTPUTS
          Level 2                 n              /
          Level 1       [ a1 , ........ , aN ]           Area

  where  n = number of points employed by Gauss-Chebyshev formula

Example:    x2 / 16 + y2 / 25 + z2 / 36 + t2 / 49 = 1 

-With n = 4

                 4            ENTER
        [ 4  5   6   7 ]   SAHE       ->    3194.72464771

 -With n = 8

                 8            ENTER
        [ 4  5   6   7 ]   SAHE       ->    3194.58486195

-With n = 16

                16           ENTER
        [ 4  5   6   7 ]   SAHE       ->    3194.58485708

-With n = 32

                32            ENTER
        [ 4  5   6   7 ]   SAHE       ->    3194.58485708


10°)  Equation of a HyperPlane


The hyperplane in an n-dimensional space is defined by n points


          STACK            INPUTS        OUTPUTS
          Level n      [ xn1 , ........ , xnn ]              /
           ..........
         ...................
             /
          Level 1      [ x11 , ........ , x1n ]    [ a1 , ........ , an , b ]


Example:    A( 1  2  7  4 )   B( 3  1  5  2 )  C( 2  4  7  1 )   D( 4  1  8  6 )

    [ 1  2  7  4 ]   ENTER
    [ 3  1  5  2 ]   ENTER
    [ 2  4  7  1 ]   ENTER
    [ 4  1  8  6 ]   PLAN     ->    [ 5  26  -27  19  56 ]      So   (H):  5 x + 26 y - 27 z + 19 t + 56 = 0


11°)  Equation of a HyperSphere


The equation of a hypersphere is:     x12 + x22 + .............. + xn2 + a1 x1 + a2 x2 + ............. + an xn + b = 0

SPHR takes the coordinates of (n+1) points and returns the coordinates of the center, the radius and  [ a1 , ........ , an , b ]


          STACK            INPUTS        OUTPUTS
          Level n [ xn+11 , ........ , xn+1n ]              /
           ..........
         ...................
             /
          Level 3
         ....................
   [ a1 , ........ , an , b ]
          Level 2
         ...................
             R
          Level 1      [ x11 , ........ , x1n ]    [ a1 , ........ , an , b ]


Example:  

-Find an equation of the sphere passing through the 4 points:  A(-1,4,7)  B(2,4,6)  C(5,1,0)  D(3,-3,-4)

    [ -1  4  7 ]  ENTER
    [  2  4  6 ]  ENTER
    [ 5  1   0 ]  ENTER
    [ 3 -3  -4 ]  SPHR     ->    [ 0.66666666664  -8.3333333333  6.9999999995 ]  and  R = 12.4454364683  and  [  -1.33333333328  16.6666666666  -13.9999999999  -36.0000000002 ]

-So the sphere's equation is    x2 + y2 + z2 - 4 x/3 + 50 y/3 - 14 z - 36 = 0  
-The exact radius is sqrt(1394)/3
-The center is  ( 2/3 , -25/3 , 7 )


12°)  Heron Formula

-Let a triangle ABC with 3 known sides  a , b , c

-Heron's formula is     Area = [ p(p-a)(p-b)(p-c) ]1/2      where  p = (a+b+c)/2 = semiperimeter


          STACK            INPUTS        OUTPUTS
          Level 3
                a
              /
          Level 2                 b               /
          Level 1                 c            Area


Example:
      a = 2    b = 3    c = 4

   2   ENTER
   3   ENTER
   4   HERON   ->    Area = 2.90473750966


13°)  Brahmagupta Formula


-We can use Brahmagupta formula to calculate the area of a cyclic quadrilateral


          STACK            INPUTS        OUTPUTS
          Level 4
                a
              /
          Level 3
                b
              /
          Level 2                 c               /
          Level 1                 d            Area


Example:
     a = 4 , b = 5 , c = 6 , d = 7

   4  ENTER
   5  ENTER
   6  ENTER
   7  BRAHM      ->     Area = 28.9827534925


14°)  Tetrahedron Volume


-We use the following conventions:
-The edges  d , e , f  are respectively opposite to  a , b , c   ( non co-planar )
-The edges  a , b , c  intersect at the same vertex  S

                                        C
                                         *
                                     *      *
                                  *             *
                               *         d *     *
                        c  *                           *    e
                         *                      B         *
                      *                         *              *
                   *               b *                *         *
               *            *                             f  *      *
             *      *                                                *  *
       S *     *    *    *    *    *    *    *    *    *    *     *  A
                                         a


-Given the 6 sides of a tetrahedron a , b , c , d , e , f , this program computes the volume V of the tetrahedron,
  and the radii  r , R , r1 , r2 , r3 , r4  of the insphere, the circumsphere and the 4 exspheres.


          STACK            INPUTS        OUTPUTS
          Level 7
                /
              r4
          Level 6
                a
              r3
          Level 5
                b
              r2
          Level 4
                c
              r1
          Level 3
                d
              r
          Level 2                 e               R
          Level 1                 f         Volume


Example:
      a = 3   b = 5   c = 7   d = 6   e = 8   f = 4

    3  ENTER
    5  ENTER
    7  ENTER
    6  ENTER
    8  ENTER
    4  THVR    ->     V = 8.42614977317     and

     R = 4.35040875528    ( circumsphere )       r1 = 1.29830860673     r3 = 1.15302542336       ( the radii of the
      r = 0.591887582737      ( insphere )           r2 =  1.89859159932    r4 = 0.823182563658        4 exspheres )


15°)  Generating Integer Tetrahedra


-Here, you specify  a , b , c  and  ITH searches for integers  d , e , f  that produce a tetrahedron with an integer volume V
-Then, it returns - if any - the integer volume V  corresponding to the edges lengths  ( a , b , c, d , e , f )



          STACK            INPUTS        OUTPUTS
          Level 3
                a
              /
          Level 2                 b               V
          Level 1                 c      { a b c d e f }


Example:
    a = 4  b = 5  c = 6

    4  ENTER
    5  ENTER
    6    ITH        ->   ( HALT )       { 4  5  6  2  8  7 }  and  V = 6

-Press   CONT    there is no other solution

Note:

-This program is very slow...


16°)  Quadratic Hypersurface


 QHS   reduces the cartesian equation of a quadratic hypersurface in a n-dimensional space  ( n > 1 )

-Given    (QHS):  a11 x12 + a22 x22 + .............. + ann xn2 + Sum i < j  ai j xi xj  +  b1 x1 + b2 x2 + ............. + bn xn +  c  = 0

    the elements  ai j ( i < j ) are gradually zeroed by the Jacobi's iterative method.

The reduced equation is:    (QHS):  a'11 X12 + a'22 X22 + .............. + a'nn Xn2  + b'1 X1 + b'2 X2 + ............. + b'n Xn +  c'  =  0

 where   b'i  = 0  if  a'ii # 0  and  c' = 0 or 1



          STACK            INPUT        OUTPUT
          Level 1     cartesian equation     reduced  equation


Example:
    (QHS):  3 x2 + 4 y2 + 7 z2 + 6 t2 + 9 x.y + 3 x.z + 7 x.t + 4 y.z + 8 y.t + 2 z.t + 9 x + 2 y + 5 z + 4 t - 10 = 0  in a 4-dimensional space.

    [ 3  4  7  6  9  3  7  4  8  2  9  2  5  4  -10 ]    QHS   ->   [ 0.209131158075  -2.71616606068  -1.2354670922  -0.297006168891  0  0  0  0  1 ]

-So, the reduced equation is   0.209131158075 X2 -  2.71616606068 Y2 - 1.2354670922 Z2 - 0.297006168891 T2 + 1 = 0    a "hyper-hyperboloid"?

Note:

QHS calls the following routine JCB  to find the eigenvalues & eigenvectors of the symmetric matrix defined by the cartesian equation.


Remark:

-The variable 'eps'  contains a small number ( E-10) to define "tiny" elements that are replaced by 0.
-Change this value if you prefer another test...


17°)  Jacobi's Method


 JCB uses a variant of the Jacobi's algorithm:

*** The eigenvalues of a matrix A are the diagonal-elements of an upper triangular matrix T equal to the infinite product   ...Uk-1.Uk-1-1....U2-1.U1-1.A.U1.U2....Uk-1.Uk....
 where the Uk are unitary matrices. The eigenvectors are the columns of  U = U1.U2....Uk-1.Uk.... if A is Hermitian ( i-e if A equals its transconjugate )
 Actually, T is diagonal if A is Hermitian.

-"JCB" finds the greatest element ai j below the main diagonal
-Then,  U1  is determined so that it places a zero in position ( i , j )  in U1-1.A.U1

  U1  has the same elements as the Identity matrix, except that  ui i = uj j = x  and  ui j = y + i.z ,  uj i = -y + i.z

     with  y + i.z  = C.x  ,  x = ( 1 + | C |2 ) -1/2  and   C = 2.ai j / [ ai i - ai j + ( ( ai i - ai j )2 + 4 ai j aj i )1/2 ]

-The process is repeated until the greatest sub-diagonal element is smaller than eps

-The successive greatest | ai j |  ( i > j ) are displayed when the routine is running.



          STACK           INPUTS         OUTPUTS
           Level 2
               /
              V
           Level 1               A               M

   Where  A is a square matrix ( symmetric or hermitian ) , V contains the eigenvalues,  the columns of M are the eigenvectors

Example1:
   Let's compute all the eigenvalues and the eigenvectors of the matrix

            1  2  4
    A =  2  7  3     JCB   returns    the 3-vector in level 2    [ -0.730676198691    4.91074121335   12.8199349853  ]
            4  3  9

-So, the eigenvalues are:

                 k1 = -0.730676198691
                 k2 =  4.91074121335
                 k3 = 12.8199349853

and the 3 corresponding eigenvectors are the 3 columns of the matrix in level 1

             V1 (  0.930757325639 ; -0.104865823188 ; -0.350276975967 )
             V2 ( -0.101146468234 ; 0.846760700436 ; -0.522269765696 )
             V3   (  0.351369026422 ; 0.521535689482 ; 0.777521917338 )

-All the eigenvectors are unit vectors.


Note:

-This program only works well if the matrix is symmetric ( or more generally hermitian ).



References:

[1]  Dunkl & Ramirez - "Computing Hyperelliptic Integrals for Surface Measure of Ellipsoids"
[2]  Abramowitz and Stegun - "Handbook of Mathematical Functions" -  Dover Publications -  ISBN  0-486-61272-4