Differential Geometry for the HP48/50


 Overview
 

-These programs use numerical differentiation to calculate:

   Several differential operators
   Usual problems in Euclidean differential geometry
   Tensors in Riemaniann geometry
   A few tensors in non-Riemaniann manifolds
 

Notes:

-Most of these routines may also be applied with complex arguments and complex manifolds ( Complex General Relativity )
-However, use (0,1) instead of i. Otherwise, meaningless results could be returned when the variable 'i' is used.

-Most of the formulas to estimate derivatives are of order 10 ( h = 0.1 is "often" a good choice )
-This produces a good precision for the 1st derivatives but a low precision for 6th derivatives.

-With formulas of order 10, the execution time may be prohibitive to compute all tensors..
-So, you can also choose 4th-order methods with"FD" and "SD" ( in the Riemaniann & Manifolds sub-directories ), to get faster - but less accurate - results.

-In this case, choose h < 0 to select 4th order formulae. ( h = - 0.01 is "often" a good choice )

-The functions f you need to derive must be programs that you place in the stack:

     •  With 1 variable, f must take x in level 1 and return f(x) in level 1
     •  With 2 variables, f takes x in level 2 & y in level 1 and returns f(x,y) in level 1
     •  With 3 variables, f takes x in level 3, y in level 2 & z in level 1 and returns f(x,y,z) in level 1

     •  It's different with n variables:  x1 , ............. , xn are stored in n variables 'X1' .............. 'XN'
        f must use the contents of  'X1' .............. 'XN'  and return  f( x1 , ....... , xn ) in level 1

-You can use local or global variables to program your functions, but avoid lower case variables because some of the programs also use them
  and it could yield meaningless results.

-The execution times have been measured with an HP48GX.
-Surprisingly, they are sometimes longer with an HP50G !
 

Notations:

-In the comments below, I've used Einstein summation convention:

-When an index appears as an upper index & a lower index in a monomial and is not otherwise defined,
  it means summation of that term over all the values of the index.

-For example, in a 3 dimensional space,

            ak bk = a1 b1 + a2 b2 + a3 b3

         gij ai aj = g11 a1 a1 + g12 a1 a2 + g13 a1 a3
                    + g21 a2 a1 + g22 a2 a2 + g23 a2 a3
                    + g31 a3 a1 + g32 a3 a2 + g33 a3 a3

-If the tensor gij is symmetric ( gij = gji )  the last expression may be simplified and becomes:

        gij ai aj = g11 a1 a1 + g22 a2 a2 + g33 a3 a3  + 2 ( g12 a1 a2 + g13 a1 a3 + g23 a2 a3 )
 

-The partial derivative     m gij   means   gij / xm
-Likewise,          km gij   =  gij / xkxm
 
 
 
 Function  Desciption
 DIFFGEOM
 d12F
 d34F
 d56F
 KHT
 KHTN
 ROM
    LNG
    SRV
    SKS
    CRVL
    CRVN
    TOL
    ROM
    N
 VAR2
    MDV
    MDV12
    MDV21
    MDV4
    KGM
 VAR3
    CuRL
    DVG
    GRaD
    LaPL
    VLaP
    CYL
         CuRL
         DVG
         GRaD
         LaPL
         VLaP
    SPH
         CuRL
         DVG
         GRaD
         LaPL
         VLaP
    MDV3
    BHRM
    THRM
 NVAR
    FD
    SD
    TD
    CuRL
    DVG
    GRaD
    HESS
    LaPL
    BHRM
    KGM
     h
     N
     X1
     X2
     X3
     X4
     X5
     X6
     X7
     X8
     X9
 RIEMANNIAN
     h
     N
     X1
     X2
     X3
     X4
     G11
     G22
     G33
     G44
     G12
     G13
     G14
     G23
     G24
     G34
     INIGC
     GIJ
     G^IJ
     CIJK
     GETCIJK
     RIJKL
     RIJK^L
     RIJ
     RSC
     R
     EIJ
     WIJKL
     CuRL
     DVG
     GRaD
     LaPL
     COV^
     COV¯
     FD
     SD
 MANIFOLDS
     h
     N
     X1
     X2
     X3
     X4
     G11
     G22
     G33
     G44
     G12
     G13
     G14
     G23
     G24
     G34
     INIG
     GIJ
     G^IJ
     RIJK^L
     RIJ
     QIJ
     RRR
     QQQ
     SIJK
     SI
     C111
     C121
     ........
     FD
     SD
 Directory
 1st & 2nd Derivatives of a Function of 1 variable
 4th & 5th Derivatives of a Function of 1 variable
 5th & 6th Derivatives of a Function of 1 variable
 Curvature & Torsion of a Curve ( 3 Dim )
 Curvature & Torsion of a Curve ( n Dim )
 Subdirectory = Romberg Method
     Arc Length of a Curve defined by y = f(x)
     Area of a Surface of Revolution
     Area of a Surface defined by z = f(x,y)
     Arc Length of a Parametric Curve ( 3-Dim )
     Arc Length of a Parametric Curve ( N-Dim )
     Tolerance
     A Subroutine to use Romberg Method
     N = 1 , 2 , 4 , 8 , ......
 Subdirectory = Functions of 2 Variables
     Mixed Derivative of a Function of 2 vatiables d2F/dxdy
     d3F/dxdy2
     d3F/dx2dy
     d4F/dx2dy2
     Gaussian Curvature & Mean Curvature of a Surface.
 Subdirectory = Functions of 3 Variables
     Curl of a 3D-Vector Field ( Rectangular Coordinates )
     Divergence of a 3D-Vector Field
     Gradient of a function of 3 variables
     Laplacian of a function of 3 variables
     3D-Vector Laplacian 
     Subdirectory = Cylindrical Coordinates
         Curl of a 3D-Vector Field
         Divergence of a 3D-Vector Field
         Gradient of a function of 3 variables
         Laplacian of a function of 3 variables
        3D-Vector Laplacian 
     Subdirectory = Spherical Coordinates
         Curl of a 3D-Vector Field
         Divergence of a 3D-Vector Field
         Gradient of a function of 3 variables
         Laplacian of a function of 3 variables
        3D-Vector Laplacian 
     d3F/dxdydz
     Biharmonic Operator ( 3 Dim. )
     Triharmonic Operator ( 3 Dim. )
 Subdirectory = Functions of N Variables
     First Derivatives of a Function of N variables
     Second Derivatives of a Function of N variables
     Third Derivatives of a Function of N variables
     Curl of an N-Dim Vector Field ( antisymmetric tensor )
     Divergence of an N-Dim Vector Field
     Gradient of a Function of N variables
     Hessian Matrix
     Laplacian of a Function of N variables
     Biharmonic Operator ( N Dim. )
     Gaussian & Mean Curvatures of a Hypersurface.
     h = a "small" number
     N = Number of Variables
     1st variable
     2nd variable
     3rd variable      you can add
     4th variable
     5th variable       other variables
     6th variable
     7th variable       'X10'  'X11'  ...  if need be.
     8th variable
     9th variable
 Subdirectory = Riemannian Manifolds
     h = a "small" number
     N = Dimension of the Riemannian manifold
     1st coordinate
     2nd coordinate
     3rd coordinate
     4th coordinate
     G11         Programs to compute
     G22
     G33         the covariant coordinates
     G44
     G12         of the metric tensor
     G13
     G14
     G23
     G24
     G34
     Initialization
     Covariant Metric Tensor ( a symmetric Matrix )
     Contravariant Metric Tensor ( Inverse of [ GIJ ] )
     List of the Christoffel Symbols 
     Recalling Cijk
      Curvature Tensor ( 0-4 )
      Curvature Tensor ( 1-3 )
     Ricci Tensor
     Calculates the Scalar Riemannian Curvature
     Scalar Riemannian Curvature
     Einstein Tensor
     Weyl Tensor
     Curl of a Covariant Vector-Field
     Divergence of a Contravariant Vector-Field
     Gradient of a Scalar Field
     Laplacian of a Scalar Field
     Covariant Derivative of a Contravariant Vector-Field
     Covariant Derivative of a Covariant Vector-Field
     First Derivatives of a Function of N variables
     Second Derivatives of a Function of N variables
 Subdirectory = General Manifolds
     h = a "small" number
     N = Dimension of the Manifold
     1st coordinate
     2nd coordinate
     3rd coordinate
     4th coordinate
     G11         Programs to compute
     G22
     G33         the covariant coordinates
     G44
     G12         of the metric tensor
     G13
     G14
     G23
     G24
     G34
     Initialization
     Covariant Metric Tensor ( a symmetric Matrix )
     Contravariant Metric Tensor ( Inverse of [ GIJ ] )
     Curvature Tensor ( 1-3 )
     Ricci Tensor
     Segmental Curvature Tensor
     Scalar Curvature
     Segmental Curvature
     Torsion Tensor
     Torsion Vector
     Affine Connexions ( Programs to compute the Cijk )
     .............................
     .............................
     First Derivatives of a Function of N variables
     Second Derivatives of a Function of N variables

 
 
 

1st & 2nd Derivatives of a Function of 1 variable
 

-"d12F"  calculates the 1st & 2nd derivatives of a function of 1 variable f(x)
 

Formulae:

       df/dx = (1/2520.h).[ 2100.( f1 - f-1 ) - 600.( f2 - f-2 ) + 150.( f3 - f-3 ) - 25.( f4 - f-4 ) + 2.( f5 - f-5 ) ] + O(h10)
     d2f/dx2 = (1/25200.h2).[ -73766 f0 + 42000.( f1 + f-1 ) - 6000.( f2 + f-2 ) + 1000.( f3 + f-3 ) - 125.( f4 + f-4 ) + 8.( f5 + f-5 ) ] + O(h10)

      (  f(x+k.h) is denoted fk to simplify these expressions )

-They are exact for any polynomial of degree < 11
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 3       << f >>             /
       Level 2             x          f ' (x)
       Level 1             h         f '' (x)

 
Example:     f(x) = exp(x) + ln(x)     x = 2

-With  h = 0.1

   << EXP LASTARG LN + >>   ENTER
                       2                           ENTER                     f '(2) = 7.88905609897
                      0.1                           d12F    >>>>          f "(2) = 7.13905610484

Note:

-The program in level 3 must take x in Level 1 and return f(x) in level 1
 

3rd & 4th Derivatives of a Function of 1 variable
 

-"d34F"  calculates the 3rd & 4th derivatives of a function of 1 variable f(x)
 

Formulae:
 

-We have:

    d3f/dx3 ~ [ -e f(x-5h) - d f(x-4h) - c f(x-3h) - b f(x-2h) - a f(x-h) + a f(x+h) + b f(x+2h) + c f(x+3h) + d f(x+4h) + e f(x+5h) ] / h3

       with   a = -1669/720 ,  b = 8738/5040 ,  c = -4869/10080 ,  d = 2522/30240 ,  e = -205/30240

   h4 f(4)(x) ~  ( 192654 F - 140196 G + 52428 H - 9738 I +1261 J - 82 K ) / 15120

       with   A = f(x+h) - f(x-h)  ,  B = f(x+2h) - f(x-2h)  ,  C = f(x+3h) - f(x-3h)  ,  D = f(x+4h) - f(x-4h)  , E = f(x+5h) - f(x-5h)

        G = f(x+h) + f(x-h)  ,  H = f(x+2h) + f(x-2h)  ,  I = f(x+3h) + f(x-3h)  ,  J = f(x+4h) + f(x-4h)  , K = f(x+5h) + f(x-5h)

  and   F = f(x)
 

-They are exact for any polynomial of degree < 11
 
 
      STACK        INPUTS      OUTPUTS
       Level 3       << f >>             /
       Level 2             x         f (3) (x)
       Level 1             h         f (4) (x)

 
Example:     f(x) = exp(x) + ln(x)     x = 2

-With  h = 0.1

   << EXP LASTARG LN + >>   ENTER
                       2                           ENTER                      f (3) (2) = 7.63905605159
                      0.1                           d34F    >>>>           f (4) (2) = 7.01405238095
 

5th & 6th Derivatives of a Function of 1 variable
 

-"d56F"  calculates the 5th & 6th derivatives of a function of 1 variable f(x)
 

Formulae:
 

-Let  A = f(x+h) - f(x-h)  ,  B = f(x+2h) - f(x-2h)  ,  C = f(x+3h) - f(x-3h)  ,  D = f(x+4h) - f(x-4h)  , E = f(x+5h) - f(x-5h)

        G = f(x+h) + f(x-h)  ,  H = f(x+2h) + f(x-2h)  ,  I = f(x+3h) + f(x-3h)  ,  J = f(x+4h) + f(x-4h)  , K = f(x+5h) + f(x-5h)

  and   F = f(x)

-We have:

   h5 f(5)(x) ~  ( 1938 A - 1872 B + 783 C - 152 D + 13 E ) / 288
   h6 f(6)(x) ~  ( -233244 F + 184110 G - 88920 H + 24795 I -3610 J + 247 K ) / 4560
 

-They are exact for any polynomial of degree < 11
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 3       << f >>             /
       Level 2             x         f (5) (x)
       Level 1             h         f (6) (x)

 
Example:     f(x) = exp(x) + ln(x)     x = 2

-With  h = 0.1

   << EXP LASTARG LN + >>   ENTER
                       2                           ENTER                      f (5) (2) = 8.13909027778
                      0.1                           d56F    >>>>           f (6) (2) = 5.51559210526

Note:

-The 4th derivatives are already difficult to evaluate with a great precision, but here, the exact values are:

  f (5) (2) = 8.13905609893...
  f (6) (2) = 5.51405609893...

-Thus, hardly 4 digits are significant for the 6th derivative !
 

Curvature & Torsion of a Parametric Curve ( 3 Dimensions )
 

-We assume that the curve is parametrized by 3 functions  x(t) , y(t) , z(t)

-The curvature is calculated by   khi = | r' x r'' | / | r' |3                                      where  the vector  r = [ x(t) , y(t) , z(t) ]
                   and the torsion by   tau = ( r' x r'' ) .r''' / | r' x r'' |2                        x = cross-product  and  . = dot-product
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 5      << x(t) >>            /
       Level 4      << y(t) >>            /
       Level 3      << z(t) >>            /
       Level 2             t         khi(t)
       Level 1             h         tau (t)

 
Example:     The curve defined by   x(t) = et cos t  ,  y(t) = et sin t  ,  z(t) = Ln(t)        ( t expressed in radians )

-Evaluate the curvature khi (t) and the torsion tau (t) for t = 1.3

-If you choose  h = 0.1

    RAD

    << EXP  LASTARG  COS  *  >>  ENTER
    << EXP  LASTARG  SIN   *  >>   ENTER
                  <<  LN  >>                       ENTER
                         1.3                             ENTER               k:  0.194807823431
                         0.1                               KHT      >>>>   t:  0.123665238776

-The exact values are   khi (1.3) = 0.194807823  &  tau (1.3) = 0.123665529  ( rounded to 9 decimals )
 

Curvature & Torsion of a Parametric Curve ( N Dimensions )
 

-The method follows the Gram-Schmidt process ( cf references [1] & [2] )
 
 
 
      STACK        INPUTS      OUTPUTS
       Level n+3      << x1(t) >>            /
       Level ...      .................            /
       Level 4      << xn(t) >>            /
       Level 3             t            /
       Level 2             h         khi (t)
       Level 1             n         tau (t)

 
Example:      The curve defined by

     x1(t) = t4       x3(t) = t3      at the point  t = 1
     x2(t) = t2       x4(t) = et

-If you choose  h = 0.1

    << 4 ^  >>   ENTER
    <<  SQ >>   ENTER
    << 3 ^  >>   ENTER
    << EXP >>  ENTER
            1           ENTER
           0.1         ENTER             k:  0.142277240599
            4           KHTN   >>>     t:   0.121469323539

Note:

-If n = 3 , the torsion given ny the Gram-Schmidt process is multiplied by SIGN ( DET ( r' , r'' , r''' ) )  to get the same sign as  KHT above.
 

Arc Length of a Curve defined by  y = f(x)
 

-The arc length of the curve  y = f(x)   ( a < x < b )  is given by   L = §ab  ( 1 + (y')2 )1/2 dx
  "LNG" doesn't use this formula and avoids the calculation of dy/dx . It simply applies Pythagoras' theorem.
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 3       << f >>             /
       Level 2             a             /
       Level 1             b            L

 
Example:    Calculate the arc length of the curve   y = ln x      1 < x < 3

-If you choose a tolerance of 10 -9  , store this value in the variable 'tol'  then:

     <<  LN  >>  ENTER
             1          ENTER
             3            LNG      >>>    2.30198753457

Note:

-The HP48 displays the successive approximations
 

Area of a Surface of Revolution
 

-The rotation of the curve  y = f(x)   ( a < x < b )  around x-axis generates a surface of revolution given by   S = 2.pi  §ab  y ( 1 + (y')2 )1/2 dx
  "SRV" avoids the calculation of dy/dx : the area of a truncated cone is used with Romberg method.
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 3       << f >>             /
       Level 2             a             /
       Level 1             b            S

 
Example:    Evaluate the area of the surface of revolution generated by the rotation of the curve   y = sin x  ( 0 < x < pi )  around the x-axis.

-If you choose the same tolerance of 10 -9  , store this value in the variable 'tol'  then:

     RAD

     << SIN >>  ENTER
             0          ENTER
            PI           SRV      >>>    14.4235994518

Note:

-The HP48 displays the successive approximations
 

Area of a Surface defined by z = f(x,y)
 

-"SKS" computes the area of a surface defined by:     z = f(x,y)       a < x < b  ,   c < y < d

-The result could be obtained by the double integral  §ab §cd   ( 1 + fx2 + fy2  )1/2 dx dy

   where  fx = f/x  and   fy = f/y  are the partial derivatives with respect to x and y respectively.

-But "SKS" avoids the calculus of the partial derivatives:
-The intervals [a,b] and [c,d] are divided into n parts, and the approximate area is the sum of the areas of triangles.
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 5       << f >>             /
       Level 4             a             /
       Level 3             b             /
       Level 2             c             /
       Level 1             d             S

 
Example:   Evaluate the area of the surface defined by z = ( 25 - x2 - y2 )1/2  ,  0 < x < 2 ,  0 < y < 3
 

-Let's choose 10 -6 for the tolerance ( store this positive value in 'tol' )

    <<  SQ  SWAP  SQ  +  25  SWAP  -  Ö   >>   ENTER                                 ( Ö  = SQRT )
                                         0                                   ENTER
                                         2                                   ENTER
                                         0                                   ENTER
                                         3                                     SKS        >>>   6.65439661003

-With  tol = 10 -8 , it yields  6.6543961212    ( more accurate, but slower )

Notes:

-The HP48 displays the successive approximations
-As usual with Romberg method, n is multiplied by 2 at each iteration but here,
  execution time is multiplied by 4: we approximate a double integral.
-You can stop the iterations: simply press any key. The program will stop at the next step.
 

Arc Length of a Parametric Curve ( 3-Dim )
 

 "CRVL" evaluates the integral  §ab  [ ( dX/dt )2 + ( dY/dt )2 + ( dZ/dt )2 ] 1/2  dt

-Romberg method is used with Pythagora's theorem.
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 5      << x(t) >>            /
       Level 4      << y(t) >>            /
       Level 3      << z(t) >>            /
       Level 2             a            /
       Level 1             b            L

 
Example:     X(t) = t4 ,  Y(t) = t2  ,  Z(t) = exp t   ;  a = 0 ,  b = 1

-If you choose a tolerance of 10 -9  , store this value in the variable 'tol'  then:

    <<  4  ^  >>  ENTER
    <<   SQ  >>  ENTER
    <<  EXP >>  ENTER
             0          ENTER
             1           CRVL   >>>>   L = 2.34211645877

Note:

-The HP48 displays the successive approximations
 

Arc Length of a Parametric Curve ( N-Dim ) N < 10
 

 "CRVN" evaluates the integral  §ab  [ ( dX1/dt )2 + ( dX2/dt )2 + ............ + ( dXN/dt )2 ] 1/2  dt
 
 
 
 
      STACK        INPUTS      OUTPUTS
       Level n+3      << x1(t) >>            /
       Level ...      .................            /
       Level 4      << xn(t) >>            /
       Level 3             a            /
       Level 2             b            /
       Level 1             n           L

 
Example:     X1(t) = t4 ,  X2(t) = t2  ,  X3(t) = t3  ,  X4(t) = exp t   ;  a = 0 ,  b = 1

-If you choose a tolerance of 10 -9  , store this value in the variable 'tol'  then:

    <<  4  ^  >>  ENTER
    <<  SQ   >>  ENTER
    <<  3  ^  >>  ENTER
    <<  EXP >>  ENTER
             0          ENTER
             1          ENTER
             4           CRVN  >>>>      L = 2.57907923132

Notes:

-The HP48 displays the successive approximations
-This program employs DOLIST ,  SLIST ... so it will not work with an HP48S/SX
 

Romberg Method
 

-Suppose that a sequence  In  tends to I  as  n tends to infinity  and  that the  "errors"  I - In  are "nearly" proportional to 1/n2

  If you want to use Romberg method to estimate the limit I
  ROM must be called by a program with the following structure:

  <<  1  'n'  STO
         DO
         .......  calculates  In

         UNTIL   ROM
         END   OVER  2  +  DROPN
  >>

-Please EDIT for instance LNG or another program of this subdirectory to get examples.
 

Mixed Derivative of a Function of 2 variables
 

  MDV calculates  2f / xy   with the formula:
 

     f "xy = 2f / xy = (1/50400.h2).[ 73766 f00 + 42000.( f11 + f -1-1 - f10 - f -10 - f01 - f0-1 ) + 6000.( - f 22 - f -2-2 + f20 + f -20 + f02 + f0-2 )
                                                         + 1000.( f33 + f -3-3 - f30 - f -30 - f03 - f0-3 ) + 125.( - f 44 - f -4-4 + f40 + f -40 + f04 + f0-4 )
                                                               + 8.( f55 + f -5-5 - f50 - f -50 - f05 - f0-5 ) ] + O(h10)

-This formula is exact for any polynomial of degree < 11               (   fkm =  f ( x + k.h , y + m.h )  )
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 4     << f(x,y) >>            /
       Level 3             x            /
       Level 2             y            /
       Level 1             h          f ''xy

   Where the program in level 4 takes x & y in level 2 & 1 respectively and returns f(x,y) in level 1

Example:     f(x) = exp(-x2).Ln(y)    x = 1 , y = 2

-If you choose h = 0.1

    <<  LN  SWAP  SQ  NEG  EXP  *  >>   ENTER
                                 1                                  ENTER
                                 2                                  ENTER
                                0.1                                 MDV      >>>>    f "xy  = 2f / xy = -0.367879442194

-The exact result is  - 1/e =  -0.367879441171...
 

Mixed Derivative d3F/dx2dy & d3F/dxdy2
 

 MD12 & MD21 employ a method of order 11 to estimate  f'''xxy = 3f / x2y  and  f'''xyy = 3f / y2x

    h3 f'''xxy ~  SUMk=1,2,...,5  Ak [ - 2 f0k + 2 f0-k  + ( fkk - f-k-k + f-kk - fk-k ) ]

 With    A1 = 5/6 ,  A2 = -5/84  ,  A3 = +5/756  ,  A4 = -5/8064  ,  A5 = +1/31500
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 4     << f(x,y) >>            /
       Level 3             x            /
       Level 2             y            /
       Level 1             h   f'''xxy or  f'''xyy

   Where the program in level 4 takes x & y in level 2 & 1 respectively and returns f(x,y) in level 1

Example:       f(x,y,z) = Ln ( 1 + x2 y )    x = 1  ,  y = 2
 

-Again with h = 0.1

    << SWAP  SQ  *  1  +  LN  >>   ENTER
                              1                         ENTER
                              2                         ENTER
                             0.1                       MD21      >>>>   f'''xxy = 3f / x2y  =  - 0.370370410386

-The exact value is  -10/27 =  - 0.370370370.....

-With the same inputs,  MD12  returns   f'''xyy = 3f / xy2  =  - 0.148148108438

-The exact result is  -4/27 =  - 0.148148148...
 

.Mixed Derivative d4F/dx2dy2
 

 "MDV4" evaluates   f'''xxyy = 4f / x2y2  with a formula of order 12

  h4 f'''xxyy ~  20881861 f00 / 3240000  + SUMk=1,....,5  Ak [ fkk + f-k-k + fk-k + f-kk - 2 ( fk0 + f-k0 + f0k + f0-k ) ]

  where   A1 = 5/3 ,  A2 = -5/84  ,  A3 = +5/1134  ,  A4 = -5/16128  ,  A5 = +1/78750
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 4     << f(x,y) >>            /
       Level 3             x            /
       Level 2             y            /
       Level 1             h         f'''xxyy

   Where the program in level 4 takes x & y in level 2 & 1 respectively and returns f(x,y) in level 1

Example:    f(x,y) = Ln ( x2 + y3 )     x = 2 , y = 1
 

-Again with h = 0.1

    << 3  ^  SWAP  SQ +  LN   >>   ENTER
                              2                         ENTER
                              1                         ENTER
                             0.1                       MDV4       >>>>  f(4)xxyy4f / x2y2 =  - 0.0383994555318

-Exact result = - 0.0384
 

Gaussian Curvature & Mean Curvature of a Surface
 

  KGM calculates the Gaussian curvature KG and the mean curvature Km of a surface defined by a function  z = z(x,y)

-The Gaussian Curvature KG is be computed by:

   KG = [ ( 2z / x2 ) ( 2z / y2 ) - ( 2z / xy )2 ] / [ 1 + ( z / x )2 + ( z / y )2 ]2

-The mean curvature Km is given by:

    Km = (1/2) [ t ( 1+p2 ) + r ( 1+q2 ) - 2 p q s ] / ( 1+p2+q2 )3/2

   where  p = z / x , q = z / y,  r = 2z / x2,  s = 2z / xy,  t = 2z / y2
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 4     << f(x,y) >>            /
       Level 3             x            /
       Level 2             y           KG
       Level 1             h           Km

   Where the program in level 4 takes x & y in level 2 & 1 respectively and returns f(x,y) in level 1

Example:    A surface is defined by  z(x,y) = Ln ( 1 + x2 y3 )    Calculate the Gaussian & mean curvatures at the point  (x,y) = (1,1)

-With h = 0.1

   <<  3  ^  SWAP  SQ  *  1  +  LN  >>     ENTER
                                  1                               ENTER
                                  1                               ENTER                KG :  -0.124572639507
                                 0.1                              KGM     >>>>    KM :  -0.171207007011
 

Notes:

-If  KG > 0  we have an elliptic point
-If  KG < 0  we have a hyperbolic point
-If  KG = 0  we have a parabolic point

-With a sphere, you'll get   K =  1 / R2  where  R = radius of the sphere.
 

Curl of a 3D-Vector Field - Rectangular Coordinates
 

Formula:                Given a 3dim-vector field:   E = ( f , g , h )
 

  Curl E = ( h/y - g/z , f/z - h/x , g/x - f/y )
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 7    << f(x,y,z) >>            /
       Level 6    << g(x,y,z) >>            /
       Level 5    << h(x,y,z) >>            /
       Level 4             x            /
       Level 3             y            /
       Level 2             z            /
       Level 1             h        Curl E

 
Example:     E = ( f , g , h )  = [ exp(-x2) Ln(y2+z) , x2y2z2 , exp(x) y2z ]     With  x = 1 , y = 2 , z = 3

-If you choose  h = 0.1

  <<  SWAP  SQ  +  LN  SWAP  SQ  NEG  EXP  *  >>  ENTER
                            <<  *  *  SQ  >>                                    ENTER
                 <<  SWAP  SQ  *  SWAP  EXP  *  >>            ENTER
                                         1                                                ENTER
                                         2                                                ENTER
                                         3                                                ENTER
                                       0.1                                                CuRL           >>>>   [   8.6193819414
                                                                                                                               -32.5668277359
                                                                                                                                 71.7897831765  ]
 

Divergence of a 3D-Vector Field - Rectangular Coordinates
 

Formula:                Given a 3dim-vector field:   E = ( f , g , h )
 

  Div E  =  f/x + g/y + h/z
 
 
      STACK        INPUTS      OUTPUTS
       Level 7    << f(x,y,z) >>            /
       Level 6    << g(x,y,z) >>            /
       Level 5    << h(x,y,z) >>            /
       Level 4             x            /
       Level 3             y            /
       Level 2             z            /
       Level 1             h        Div E

 
Example:     E = ( f , g , h )  = [ exp(-x2) Ln(y2+z) , x2y2z2 , exp(x) y2z ]     With  x = 1 , y = 2 , z = 3

-If you choose  h = 0.1

  <<  SWAP  SQ  +  LN  SWAP  SQ  NEG  EXP  *  >>  ENTER
                           <<  *  *  SQ  >>                                    ENTER
                 <<  SWAP  SQ  *  SWAP  EXP  *  >>            ENTER
                                         1                                                ENTER
                                         2                                                ENTER
                                         3                                                ENTER
                                       0.1                                                 DVG           >>>>    Div E = 45.4414066323
 

Gradient - Rectangular Coordinates
 

Formula:                Given a function of 3 variables f(x,y,z)
 

  Grad f = ( f/x , f/y , f/z )
 
 
      STACK        INPUTS      OUTPUTS
       Level 5    << f(x,y,z) >>            /
       Level 4             x            /
       Level 3             y            /
       Level 2             z            /
       Level 1             h       Grad f

 
Example:     f(x,y,z) = exp(-x2) Ln(y2+z)      With  x = 1 , y = 2 , z = 3

-If you choose  h = 0.1

  <<  SWAP  SQ  +  LN  SWAP  SQ  NEG  EXP  *  >>   ENTER
                                         1                                                ENTER
                                         2                                                ENTER
                                         3                                                ENTER
                                       0.1                                                GRaD           >>>>  [ -1.43172068193
                                                                                                                               0.210216823546
                                                                                                                               5.25542059036 E-2 ]
 

Laplacian - Rectangular Coordinates
 

Formula:                Given a function of 3 variables f(x,y,z)
 

  Lapl f  = 2f / x2 + 2f / y2 + 2f / z2
 
 
      STACK        INPUTS      OUTPUTS
       Level 5    << f(x,y,z) >>            /
       Level 4             x            /
       Level 3             y            /
       Level 2             z            /
       Level 1             h       Lapl f

 
Example:     f(x,y,z) = exp(-x2) Ln(y2+z)      With  x = 1 , y = 2 , z = 3

-If you choose  h = 0.1

  <<  SWAP  SQ  +  LN  SWAP  SQ  NEG  EXP  *  >>   ENTER
                                         1                                                ENTER
                                         2                                                ENTER
                                         3                                                ENTER
                                       0.1                                                LaPL           >>>>  Lapl f = 1.40919744606

Note:

-The exact result is     1.40919744532.....
 

3D-Vector Laplacian - Rectangular Coordinates
 

-With rectangular coordinates, the coordinates of the vector Lplacian are simply the Laplacian of the coordinates.
-It's not so easy with cylindrical or spherical coordinates.
 
 
      STACK        INPUTS      OUTPUTS
       Level 7    << f(x,y,z) >>            /
       Level 6    << g(x,y,z) >>            /
       Level 5    << h(x,y,z) >>            /
       Level 4             x            /
       Level 3             y            /
       Level 2             z            /
       Level 1             h        Lapl E

 
Example:     E = ( f , g , h )  = [ exp(-x2) Ln(y2+z) , x2y2z2 , exp(x) y2z ]     With  x = 1 , y = 2 , z = 3

-If you choose  h = 0.1

  <<  SWAP  SQ  +  LN  SWAP  SQ  NEG  EXP  *  >>  ENTER
                            <<  *  *  SQ  >>                                    ENTER
                 <<  SWAP  SQ  *  SWAP  EXP  *  >>            ENTER
                                         1                                                ENTER
                                         2                                                ENTER
                                         3                                                ENTER
                                       0.1                                               VLaP           >>>>   [   1.40919744606
                                                                                                                               98
                                                                                                                               48.9290729151  ]
 

Curl of a 3D-Vector Field - Cylindrical Coordinates
 

Formula:                Given a 3dim-vector field:   E = ( f , g , h )
 

  Curl E = [ (1/r) h/¶f - g/z , f/z - h/r , (1/r) ( g + r g/r - f/¶f ) ]
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 7    << f(r,u,z) >>            /
       Level 6    << g(r,u,z) >>            /
       Level 5    << h(r,u,z) >>            /
       Level 4             r            /
       Level 3             u            /
       Level 2             z            /
       Level 1             h        Curl E

 
Example:         E = ( f , g , h )  = (  r z2 sin2f , r2 z , r3 z cos f )                   r = 2 , f = PI/5 , z = 1

-If you choose  h = 0.1

        <<  SWAP  SIN  *  SQ  *  >>           ENTER
  <<  SWAP  DROP  SWAP  SQ  *  >>    ENTER
 <<  SWAP  COS  *  SWAP  3  ^  *  >>   ENTER
                              2                                   ENTER
                          PI  5  /
                              1                                   ENTER
                            0.1                                   CuRL    >>>>   [ -6.35114100918
                                                                                                -8.32623792129
                                                                                                 5.04894348373 ]

Note:

 RAD mode is automatically set by this program
 

Divergence of a 3D-Vector Field - Cylindrical Coordinates
 

Formula:                Given a 3dim-vector field:   E = ( f , g , h )
 

  Div E  =  f/r + (1/r) f + (1/r) g/¶f + h/z
 
 
      STACK        INPUTS      OUTPUTS
       Level 7    << f(r,u,z) >>            /
       Level 6    << g(r,u,z) >>            /
       Level 5    << h(r,u,z) >>            /
       Level 4             r            /
       Level 3             u            /
       Level 2             z            /
       Level 1             h        Div E

 
Example:         E = ( f , g , h )  = (  r z2 sin2f , r2 z , r3 z cos f )                   r = 2 , f = PI/5 , z = 1

-If you choose  h = 0.1

        <<  SWAP  SIN  *  SQ  *  >>           ENTER
  <<  SWAP  DROP  SWAP  SQ  *  >>    ENTER
 <<  SWAP  COS  *  SWAP  3  ^  *  >>   ENTER
                              2                                   ENTER
                          PI  5  /
                              1                                   ENTER
                            0.1                                    DVG    >>>>   7.16311896062

Note:

 RAD mode is automatically set by this program
 

Gradient - Cylindrical Coordinates
 

Formula:                Given a function of 3 variables f(r,f,z)

 Grad f = ( f/r , (1/r) f/¶f , f/z )
 
 
      STACK        INPUTS      OUTPUTS
       Level 5    << f(r,u,z) >>            /
       Level 4             r            /
       Level 3             u            /
       Level 2             z            /
       Level 1             h        Grad f

 
Example:             f(r,f,z) =  r3 z cos f                 r = 2 , f = PI/5 , z = 1

-If you choose  h = 0.1

 <<  SWAP  COS  *  SWAP  3  ^  *  >>   ENTER
                              2                                   ENTER
                          PI  5  /
                              1                                   ENTER
                            0.1                                   GRaD    >>>>   [ 9.70820393254
                                                                                               -2.35114100918
                                                                                                6.472135955 ]

Note:

 RAD mode is automatically set by this program
 

Laplacian - Cylindrical Coordinates
 

Formula:       Given a function of 3 variables f(r,f,z)

  Lapl f  = 2f / r2 + (1/r) f/r + (1/r2) 2f / ¶f2 + 2f / z2
 
 
      STACK        INPUTS      OUTPUTS
       Level 5    << f(r,u,z) >>            /
       Level 4             r            /
       Level 3             u            /
       Level 2             z            /
       Level 1             h        Lapl f

 
Example:             f(r,f,z) =  r3 z cos f                 r = 2 , f = PI/5 , z = 1

-If you choose  h = 0.1

 <<  SWAP  COS  *  SWAP  3  ^  *  >>   ENTER
                              2                                   ENTER
                          PI  5  /
                              1                                   ENTER
                            0.1                                   LaPL    >>>>   12.9442719039

Note:

 RAD mode is automatically set by this program
 

3D-Vector Laplacian - Cylindrical Coordinates
 

-The formula is given here
 
 
      STACK        INPUTS      OUTPUTS
       Level 7    << f(r,u,z) >>            /
       Level 6    << g(r,u,z) >>            /
       Level 5    << h(r,u,z) >>            /
       Level 4             r            /
       Level 3             u            /
       Level 2             z            /
       Level 1             h        Lapl E

 
Example:         E = ( f , g , h )  = (  r z2 sin2f , r2 z , r3 z cos f )                   r = 2 , f = PI/5 , z = 1

-If you choose  h = 0.1

        <<  SWAP  SIN  *  SQ  *  >>           ENTER
  <<  SWAP  DROP  SWAP  SQ  *  >>    ENTER
 <<  SWAP  COS  *  SWAP  3  ^  *  >>   ENTER
                              2                                   ENTER
                          PI  5  /
                              1                                   ENTER
                            0.1                                   VLaP    >>>>   [  1.69098300707
                                                                                                 3.95105651627
                                                                                                12.9442719039 ]

Note:

 RAD mode is automatically set by this program
 

Curl of a 3D-Vector Field - Spherical Coordinates
 

Formula:                Given a 3dim-vector field:   E = ( f , g , h )
 

  Curl E = [ (1/(r.sin q) ) ( h cos q + sin q h/¶q - g/¶f ) , (1/(r.sin q) ) f/¶f - h/r - h / r , (1/r) ( g + r g/r - f/¶q ) ]
 
 
      STACK        INPUTS      OUTPUTS
       Level 7    << f(r,u,v) >>            /
       Level 6    << g(r,u,v) >>            /
       Level 5    << h(r,u,v) >>            /
       Level 4             r            /
       Level 3             u            /
       Level 2             v            /
       Level 1             h        Curl E

 
Example:         E = ( f , g , h )  = (  r sin2 q cos2 f , r2sin f  , r3 cos q cos2 f )                   r = 2 , q = PI/3 , f = PI/5

-If you choose  h = 0.1

           <<  COS  SWAP  SIN  *  SQ  *  >>               ENTER
     <<  SIN  SWAP  DROP  SWAP  SQ  *  >>         ENTER
 <<  COS  SQ  SWAP  COS  *  SWAP  3  ^  *  >>   ENTER
                                   2                                                ENTER
                                PI  3  /
                                PI  5  /
                                  0.1                                                CuRL    >>>>   [ -3.37986734613
                                                                                                                  -6.05970708098
                                                                                                                    2.95989052817 ]

Note:

 RAD mode is automatically set by this program
 

Divergence of a 3D-Vector Field - Spherical Coordinates
 

Formula:                Given a 3dim-vector field:   E = ( f , g , h )
 

  Div E  = f/r + (2/r) f + g (cos q)/(r sin q)  + (1/r) g/¶q + (1/(r sin q)) h/¶f
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 7    << f(r,u,v) >>            /
       Level 6    << g(r,u,v) >>            /
       Level 5    << h(r,u,v) >>            /
       Level 4             r            /
       Level 3             u            /
       Level 2             v            /
       Level 1             h        Div E

 
Example:         E = ( f , g , h )  = (  r sin2 q cos2 f , r2sin f  , r3 cos q cos2 f )                   r = 2 , q = PI/3 , f = PI/5

-If you choose  h = 0.1

           <<  COS  SWAP  SIN  *  SQ  *  >>               ENTER
     <<  SIN  SWAP  DROP  SWAP  SQ  *  >>         ENTER
 <<  COS  SQ  SWAP  COS  *  SWAP  3  ^  *  >>   ENTER
                                   2                                                ENTER
                                PI  3  /
                                PI  5  /
                                  0.1                                                DVG    >>>>  -0.045010876787

Note:

 RAD mode is automatically set by this program
 

Gradient - Spherical Coordinates
 

Formula:                Given a function of 3 variables f(r,q,f)
 

 Grad f = ( f/r , (1/r) f/¶q , (1/(r sin q))  f/¶f )
 
 
      STACK        INPUTS      OUTPUTS
       Level 5    << f(r,u,v) >>            /
       Level 4             r            /
       Level 3             u            /
       Level 2             v            /
       Level 1             h        Grad f

 
Example:      f(r,q,f)   =  r3 cos q cos2f                    r = 2 , q = PI/3 , f= PI/5

-If you choose  h = 0.1

 <<  COS  SQ  SWAP  COS  *  SWAP  3  ^  *  >>   ENTER
                                   2                                                ENTER
                                PI  3  /
                                PI  5  /
                                  0.1                                                GRaD    >>>>   [ 3.92705098312
                                                                                                                  -2.26728394224
                                                                                                                  -2.19637094272 ]

Note:

 RAD mode is automatically set by this program
 

Laplacian - Spherical Coordinates
 

Formula:                Given a function of 3 variables f(r,q,f)
 

  Lapl f  = 2f / r2 + (2/r) f/r + (1/r2) 2f / ¶q2 + (1/(r2tan q)f / ¶q + (1/(r2sin2q)) 2f / ¶f2
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 5    << f(r,u,v) >>            /
       Level 4             r            /
       Level 3             u            /
       Level 2             v            /
       Level 1             h        Lapl f

 
Example:      f(r,q,f)   =  r3 cos q cos2f                    r = 2 , q = PI/3 , f = PI/5

-If you choose  h = 0.1

 <<  COS  SQ  SWAP  COS  *  SWAP  3  ^  *  >>   ENTER
                                   2                                                ENTER
                                PI  3  /
                                PI  5  /
                                  0.1                                                LaPL    >>>>   5.72103965058

Note:

 RAD mode is automatically set by this program
 

3D-Vector Laplacian - Spherical Coordinates
 

-The formula, even more complicated than the cylindrical case, is given here
 
 
      STACK        INPUTS      OUTPUTS
       Level 7    << f(r,u,v) >>            /
       Level 6    << g(r,u,v) >>            /
       Level 5    << h(r,u,v) >>            /
       Level 4             r            /
       Level 3             u            /
       Level 2             v            /
       Level 1             h        Lapl E

 
Example:         E = ( f , g , h )  = (  r sin2 q cos2 f , r2sin f  , r3 cos q cos2 f )                   r = 2 , q = PI/3 , f = PI/5

-If you choose  h = 0.1

           <<  COS  SWAP  SIN  *  SQ  *  >>               ENTER
     <<  SIN  SWAP  DROP  SWAP  SQ  *  >>         ENTER
 <<  COS  SQ  SWAP  COS  *  SWAP  3  ^  *  >>   ENTER
                                   2                                                ENTER
                                PI  3  /
                                PI  5  /
                                  0.1                                                VLaP    >>>>   [  1.04501087529
                                                                                                                   3.79418051536
                                                                                                                   5.10341187668 ]

Note:

 RAD mode is automatically set by this program
 

Mixed Derivative d3F/dxdydz
 

 "MDV3" employs a method of order 11 to estimate  f'''xyz = 3f / xyz

    h3 f'''xyz ~  SUMk=1,2,...,5  Ak [ fk00 - f-k00 + f0k0 - f0-k0 + f00k - f00-k + fkkk - f-k-k-k - ( fkk0 - f-k-k0 + fk0k - f-k0-k + f0kk - f0-k-k ) ]

 With    A1 = 5/6 ,  A2 = -5/84  ,  A3 = +5/756  ,  A4 = -5/8064  ,  A5 = +1/31500
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 5    << f(x,y,z) >>            /
       Level 4             x            /
       Level 3             y            /
       Level 2             z            /
       Level 1             h         f'''xyz

 
Example:     f(x,y,z) = exp(-x2) Ln(y2+z)      With  x = 1 , y = 2 , z = 3

-If you choose  h = 0.1

  <<  SWAP  SQ  +  LN  SWAP  SQ  NEG  EXP  *  >>   ENTER
                                         1                                                ENTER
                                         2                                                ENTER
                                         3                                                ENTER
                                       0.1                                               MDV3   >>>>   0.0600619522

-The exact result is   0.0600619495....
 

Biharmonic Operator ( 3-Dim )
 

-The Biharmonic Operator ( also called Bilaplacian ) is defined as

       D2 f = 4f / x4 + 4f / y4 + 4f / z4 + 2 ( 4f / x2y2 + 4f / x2z2 + 4f / y2z2 )
 

-"BHRM" uses the following approximation
 

   h4 D2 f  ~  A f000
               + B1 ( f100 + f-100 + f010 + f0-10 + f001 + f00-1 )  + C1 ( f110 + f-1-10 + f1-10 + f-110 + f101 + f-10-1 + f10-1 + f-101 + f011 + f0-1-1 + f01-1 + f0-11 )
               + B2 ( f200 + f-200 + f020 + f0-20 + f002 + f00-2 )  + C2 ( f220 + f-2-20 + f2-20 + f-220 + f202 + f-20-2 + f20-2 + f-202 + f022 + f0-2-2 + f02-2 + f0-22 )
               + B3 ( f300 + f-300 + f030 + f0-30 + f003 + f00-3 )  + C3 ( f330 + f-3-30 + f3-30 + f-330 + f303 + f-30-3 + f30-3 + f-303 + f033 + f0-3-3 + f03-3 + f0-33 )
               + B4 ( f400 + f-400 + f040 + f0-40 + f004 + f00-4 )  + C4 ( f440 + f-4-40 + f4-40 + f-440 + f404 + f-40-4 + f40-4 + f-404 + f044 + f0-4-4 + f04-4 + f0-44 )
               + B5 ( f500 + f-500 + f050 + f0-50 + f005 + f00-5 )  + C5 ( f550 + f-5-50 + f5-50 + f-550 + f505 + f-50-5 + f50-5 + f-505 + f055 + f0-5-5 + f05-5 + f0-55 )

     where  fijk = f ( x+i.h , y+j.h , z+k.h )    and

     A = 41523361 / 540000  ,   B1 =  -4069 / 180             C1 =  +10 / 3
                                                 B2 =  +4969 / 1260          C2 =  -10 / 84
                                                 B3 =  -2201 / 3240           C3 =  +10 / 1134
                                                 B4 =  +371 / 4320            C4 =  -10 / 16128
                                                 B5 =  -5221 / 945000       C5 =  +2 / 78750
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 5    << f(x,y,z) >>            /
       Level 4             x            /
       Level 3             y            /
       Level 2             z            /
       Level 1             h         f'''xyz

 
Example:     f(x,y,z) = exp(-x2) Ln(y2+z)      With  x = 1 , y = 2 , z = 3

-If you choose  h = 0.1

  <<  SWAP  SQ  +  LN  SWAP  SQ  NEG  EXP  *  >>   ENTER
                                         1                                                ENTER
                                         2                                                ENTER
                                         3                                                ENTER
                                       0.1                                               BHRM   >>>>   -14.3426429833

-The exact result is  -14.34264116....  ( relative error about  E-7 )

Notes:

-91 evaluations of the function are performed (!).
-The formula is of order 10 but - due to cancellation of leading digits - there are seldom more than 7 or 8 significant digits.
 

Triharmonic Operator ( 3-Dim )
 

-The triharmonic operator is the trilaplacian operator = the Laplacian of the Laplacian of the Laplacian of a function f

-"THRM" employs a method of order 10  to evaluate
 

   D3 f = 6f / x6 + 6f / y6 + 6f / z6 + 3 ( 6f / x4y2 + 6f / x4z2 + 6f / y4z2 + 6f / x2y4 + 6f / x2z4 + 6f / y2z4 ) + 6 6f / x2y2z2
 

   h6 D3 f  ~  SUMm=1....5  Am ( fm00 + f-m00 + f0m0 + f0-m0 + f00m + f00-m - 6 f000 )
                                     + Bm ( fmm0 + f-m-m0 + fm-m0 + f-mm0 + fm0m + f-m0-m + fm0-m + f-m0m + f0mm + f0-m-m + f0m-m + f0-mm - 12 f000 )
                                     + Cm ( fmmm + f-m-m-m + fmm-m + f-m-mm + fm-mm + f-mm-m + fm-m-m + f-mmm - 8 f000 )

     where  fijk = f ( x+i.h , y+j.h , z+k.h )    and
 

     A1 = +22997 / 120                  B1 = - 2869 / 60                C1 = + 10
     A2 = - 12709 / 420                  B2 = + 667 / 240               C2 = - 5 / 56
     A3 = + 858391 / 136080         B3 = - 15007 / 68040        C3 = + 5 / 1701
     A4 = - 137843 / 161280          B4 = + 5119 / 322560       C4 = - 5 / 43008
     A5 = + 894317 / 15750000     B5 = - 739 / 1125000        C5 = + 1 / 328125
 
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 5    << f(x,y,z) >>            /
       Level 4             x            /
       Level 3             y            /
       Level 2             z            /
       Level 1             h         f'''xyz

 
Example:     f(x,y,z) = exp(-x2) Ln(y2+z)      With  x = 1 , y = 2 , z = 3

-If you choose  h = 0.1

  <<  SWAP  SQ  +  LN  SWAP  SQ  NEG  EXP  *  >>   ENTER
                                         1                                                ENTER
                                         2                                                ENTER
                                         3                                                ENTER
                                       0.1                                               THRM   >>>>   133.533181
 

Notes:

-Fourth derivatives are already difficult to evaluate numerically but here,
  there will be seldom more than 5 or 6 significant digits, and sometimes only 3 or 4 !
-The function f is evaluated 131 times.
 

First Derivatives of a Function of N variables
 

  FD employs formulas of order 10,
  but in the subdirectories "Riemann" & "Manifolds",
   formulas of order 10 are used if Re(h) > 0
  and formulas of order 4 if Re(h) < 0  i-e

    df/dx   = (1/12h).[ f(x-2h) - 8.f(x-h) + 8.f(x+h) - f(x+2h) ]
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 2   << f(x1,....,xn) >>              /
       Level 1                i          f / xi

 
Example:      f(x) = exp(-x2).Ln(y2+z)    x = 1 , y = 1 , z = 1    with  h = 0.1
 

1°)  Store  n = 3  into  'N'   and     0.1  into  'h'

2°)  Store 1   1   1    into   'X1'  'X2'  'X3'    respectively

3°)    <<  X1  SQ  NEG  EXP  X2  SQ  X3  +  LN  *  >>   ENTER
                                             1                                                 FD           >>>>    f 'x1 = f / x1 = -0.509989196833

-Likewise:

        <<  X1  SQ  NEG  EXP  X2  SQ  X3  +  LN  *  >>   ENTER
                                             2                                                 FD           >>>>    f 'x2 = f / x2 = 0.367879439374

-Likewise:

        <<  X1  SQ  NEG  EXP  X2  SQ  X3  +  LN  *  >>   ENTER
                                             3                                                 FD           >>>>    f 'x3 = f / x3 = 0.183939720617

Note:

-The contents of variables 'X1'  'X2'  ....  are temporarily modified during the calculations, but they are restored finally.
-So, if you interrupt the program before the end, check these variables before performing another calculation
 

Second Derivatives of a Function of N variables
 

  SD employs formulas of order 10,
  but in the subdirectories "Riemann" & "Manifolds",
  formulas of order 10 are used if Re(h) > 0
  and formulas of order 4 if Re(h) < 0  i-e

          d2f/dx2 = (1/12h2).[ - f(x-2h) + 16.f(x-h) - 30.f(x) +16.f(x+h) - f(x+2h) ]

 and, for the crossed derivative

           f "xy = 2f / xy = (1/24.h2).[ 30 f00 + 16.( f11 + f -1-1 - f10 - f -10 - f01 - f0-1 ) + ( - f 22 - f -2-2 + f20 + f -20 + f02 + f0-2 ) ]

  where   fkm denotes  f ( x + k.h , y + m.h )
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 3   << f(x1,....,xn) >>              /
       Level 2                i              /
       Level 1                j       2f / xixj

 
Example:       f(x) = exp(-x2).Ln(y2+z)    x = 1 , y = 1 , z = 1    with  h = 0.1
 

1°)  Store  n = 3  into  'N'   and     0.1  into  'h'

2°)  Store 1   1   1    into   'X1'  'X2'  'X3'    respectively

3°)    <<  X1  SQ  NEG  EXP  X2  SQ  X3  +  LN  *  >>   ENTER
                                             1                                             ENTER
                                             1                                                 SD           >>>>    f "xx = 2f / x2 = 0.509989195329

-Likewise:

        <<  X1  SQ  NEG  EXP  X2  SQ  X3  +  LN  *  >>   ENTER
                                             1                                             ENTER
                                             2                                                 SD           >>>>    f "xy = 2f / xy = -0.735758876115

Note:

-The contents of variables 'X1'  'X2'  ....  are temporarily modified during the calculations, but they are restored finally.
-So, if you interrupt the program before the end, check these variables before performing another calculation
 

Third Derivatives of a Function of N variables
 

   TD employs the same formulas as d34F , MDV3 , MD12 ,
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 4   << f(x1,....,xn) >>              /
       Level 3                i              /
       Level 2                j              /
       Level 1                k     3f / xixjxk

 
Example:           f(x,y,z,t) = exp(-x2) Ln( y2 + z + t3 )     x = 1 , y = 2 , z = 3 , t = 1       h = 0.1
 

1°)  Store  n = 4  into  'N'   and     0.1  into  'h'

2°)  Store 1   2   3   1    into   'X1'  'X2'  'X3'   'X4'    respectively then, for instance:

  •  f'''xyz = 3f / xyz  = ?

        <<  X1  SQ  NEG  EXP  X2  SQ  X3  +  X4  3  ^  +  LN  *  >>   ENTER
                                                      1                                                       ENTER
                                                      2                                                       ENTER
                                                      3                                                          TD           >>>>     f'''xyz = 3f / xyz  = 0.045984928498

  •  f'''xtt = 3f / xt2  = ?

        <<  X1  SQ  NEG  EXP  X2  SQ  X3  +  X4  3  ^  +  LN  *  >>   ENTER
                                                      1                                                       ENTER
                                                      4                                                       ENTER
                                                      4                                                          TD           >>>>    f'''xtt = 3f / xt2  = - 0.448353075973

  •  f'''yyy = 3f / y3  = ?

        <<  X1  SQ  NEG  EXP  X2  SQ  X3  +  X4  3  ^  +  LN  *  >>   ENTER
                                                      2                                                       ENTER
                                                      2                                                       ENTER
                                                      2                                                          TD           >>>>     f'''yyy = 3f / y3  = - 0.0459849295635
 

Note:

-The contents of variables 'X1'  'X2'  ....  are temporarily modified during the calculations, but they are restored finally.
-So, if you interrupt the program before the end, check these variables before performing another calculation
 

Curl of an NDim-Vector Field - Rectangular Coordinates
 

-If E = ( f1 , ......... , fn ) ,  Curl E  is an antisymmetric tensor defined as  cij = f i/ xj  - f j/ xi   ( some authors use the opposite sign )

 CuRL  returns the antisymmetric matrix  [ cij ]
 
 
 
             STACK             INPUTS            OUTPUTS
              Level n   << f1( x1 , ..... , xn ) >>                    /
              Level ...      .................                    /
              Level 2 << fn-1( x1 , ..... , xn ) >>                    /
              Level 1   << fn( x1 , ..... , xn ) >>                Curl  E

 
Example1:     E = ( f , g , h )  = [ exp(-x2) Ln(y2+z) , x2y2z2 , exp(x) y2z ]     With  x = 1 , y = 2 , z = 3   and   h = 0.1

  Store  3  into  'N'   and  0.1  into  'h'
  Store  1  2  3  into  'X1'  'X2'  'X3'  respectively

  <<  X1  SQ  NEG  EXP  X2  SQ  X3  +  LN  *  >>   ENTER
               <<  X1  X2  X3  *  *  SQ  >>                        ENTER
         <<  X1  EXP  X2  SQ  X3  *  *  >>                     CuRL     gives the following matrix:

   [ [            0               71.7897831765   32.5668277359  ]
     [ -71.7897831765             0                8.6193819414   ]
     [ -32.5668277359  -8.6193819414              0              ] ]

-And the 3 independant components  [ c23  c31  c12 ] =  [   8.6193819414     -32.5668277359      71.7897831765  ]
  form the usual Curl that we've found above - which is actually a pseudo-vector.

Example2:     E = ( u , v , w , p ) = ( x2y2z2t2 ,  x y z3 t ,  x2y z t3 , xy + zt )     x = t = 1 , y = 2 , z = 3    with  h = 0.1

  Store 4 into 'N'  and  0.1  into  'h'
  Store 1 into  'X1'  &  'X4'  and  2  into 'X2'  &  3  into  'X3'

     <<  X1  X2  X3  X4  *  *  *  SQ  >>     ENTER
     <<  X1  X2  X3  3  ^  X4  *  *  *  >>     ENTER
  <<  X1  SQ  X2  X3  X4  3  ^ *  *  *  >>  ENTER
        << X1  X2  *  X3  X4  *  +  >>             CuRL    returns the matrix:

     [ [    0   18  -12  -70 ]
       [  -18   0   -51  -53 ]
       [    12  51    0   -17 ]
       [    70  53   17    0  ] ]
 

Divergence of an NDim-Vector Field - Rectangular Coordinates
 

-If E = ( f1 , ......... , fn ) ,  Div E = f 1/ x1  + ................. + f n/ xn
 
 
             STACK             INPUTS            OUTPUTS
              Level n   << f1( x1 , ..... , xn ) >>                    /
              Level ...      .................                    /
              Level 2 << fn-1( x1 , ..... , xn ) >>                    /
              Level 1   << fn( x1 , ..... , xn ) >>                Div  E

 
Example:     E = ( u , v , w , p ) = ( x2y2z2t2 ,  x y z3 t ,  x2y z t3 , xy + zt )     x = t = 1 , y = 2 , z = 3    with  h = 0.1

  Store 4 into 'N'  and  0.1  into  'h'
  Store 1 into  'X1'  &  'X4'  and  2  into 'X2'  &  3  into  'X3'

     <<  X1  X2  X3  X4  *  *  *  SQ  >>     ENTER
     <<  X1  X2  X3  3  ^  X4  *  *  *  >>     ENTER
  <<  X1  SQ  X2  X3  X4  3  ^ *  *  *  >>  ENTER
        << X1  X2  *  X3  X4  *  +  >>             DVG    >>>>   Div E = 104
 

Gradient of a Function of N Variables
 

    Grad f = ( f 1/ x1 , .............. , f n/ xn )
 
 
      STACK        INPUTS      OUTPUTS
       Level 1   << f(x1,....,xn) >>        Grad f

 
Example:       exp(-x2) [ Ln(y2+z) + 1/t ]     x = t = 1 , y = 2 , z = 3    with  h = 0.1

  Store 4 into 'N'  and  0.1  into  'h'
  Store 1 into  'X1'  &  'X4'  and  2  into 'X2'  &  3  into  'X3'

  << X1  SQ  NEG  EXP  X2  SQ  X3  +  LN  X4  INV  +  *  >>    GRad   gives the 4-vector:

     [ -2.16747956713  0.210216823496  0.0525542059107  -0.367880413465 ]
 

Hessian Matrix
 

  HeSS calculates the coefficients of the Hessian matrix H defined by    H = [ hi,j ]   with  hi,j = 2f / xixj
  where f is a function of n variables
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 1   << f(x1,....,xn) >>        Hess f

 
Example:       exp(-x2) [ Ln(y2+z) + 1/t ]     x = t = 1 , y = 2 , z = 3    with  h = 0.1

  Store 4 into 'N'  and  0.1  into  'h'
  Store 1 into  'X1'  &  'X4'  and  2  into 'X2'  &  3  into  'X3'

  << X1  SQ  NEG  EXP  X2  SQ  X3  +  LN  X4  INV  +  *  >>    HeSS  returns in 25 seconds the 4x4 symmetric matrix:

                      [ [  2.16747956102    -0.420433648869    -0.105108411936    0.73576055319   ]
                        [ -0.420433648869  -0.0150154894179  -0.0300309737861     7.566.. E-10     ]
                        [ -0.105108411936  -0.0300309737861  -0.00750774532488   8.316...E-10     ]
                       [   0.73576055319       7.566.. E-10               8.316...E-10       0.735760824916 ] ]

-The small coefficients of the order of E-10 should be 0, but due to roundoff-errors...
 

Laplacian of a Function of N variables
 

 "LAPL" may be used to evaluate the Laplacian of a function of n variables.
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 1   << f(x1,....,xn) >>        Lapl f

 
Example:       exp(-x2) [ Ln(y2+z) + 1/t ]     x = t = 1 , y = 2 , z = 3    with  h = 0.1

  Store 4 into 'N'  and  0.1  into  'h'
  Store 1 into  'X1'  &  'X4'  and  2  into 'X2'  &  3  into  'X3'

  << X1  SQ  NEG  EXP  X2  SQ  X3  +  LN  X4  INV  +  *  >>    LaPL  >>>>  2.8807171512

 Exact result = 2.88071520999
 

Biharmonic Operator ( N-Dim )
 

-Formulas of order 10 are now used to estimate the n-dimensional biharmonic operator
 

         D2 f = SUMk=1,....,n  4f / xk4 + 2  SUMj<k  4f / xj2yk2
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 1   << f(x1,....,xn) >>           D2

 
Example:     f(x,y,z,t) = exp(-x2) Ln( y2 + z + t3 )     x = 1 , y = 2 , z = 3 , t = 1         with  h = 0.1

  Store 4 into 'N'  and  0.1  into  'h'
  Store 1 into  'X1'  &  'X4'  and  2  into 'X2'  &  3  into  'X3'

  << X1  SQ  NEG  EXP  X2  SQ  X3  +  X4  3  ^  +  LN  *  >>  BHRM  >>>   D2 f (1,2,3,1) = -14.93970202      ( in 19 seconds )

-The exact result is  -14.9397000647...
 

Note:

-The function f is evaluated  10 n2  + 1  times
 
 
      N   EVAL
      1     11
      2     41
      3     91
      4    161
      5    251
      6    361
      7    491
      8    641
      9    811

 
Example2:    9 variables,     f (x,y,z,t,u,v,w,r,s)  = [ exp(-x y z) + t u v w ] / Ln ( 1 + w r s )    x = y = ....... = s = 1    again with  h = 0.1

  Store 9 into 'N'  and  0.1  into  'h'
  Store 1 into  'X1'  'X2'   .......   'X9'

  << X1  X2  X3  *  *  NEG  EXP  X4  X5  X6  X7  *  *  *  +  X7  X8  X9  *  *  1  +  LN  /  >>  BHRM   returns in 1mn51s

            D2 f (1,......,1) = 103.210626858

Notes:

-The exact value is  103.2389124...
-We only have 5 significant digits;
 

Gaussian Curvature & Mean Curvature of a HyperSurface
 

 -Here, we assume that the hypersurface is defined implicitly by   f( x1 , ........... , xn ) = 0

Formulae:

   KG = - ( det W ) / ( - | Grad f | )n+1      where  W is defined in paragraph 1°) c)

   Km = [ Grad f x H x TGrad f  -  | Grad f |2 Trace (H) ] / (n-1) / | Grad f |3     where  H = Hessian matrix
 
 
      STACK        INPUTS      OUTPUTS
       Level 2              /            KG
       Level 1   << f(x1,....,xn) >>            Km

 
Example:    The surface ( n = 3 )   x4 y3 z2 - 1 = 0   with  x = y = z = 1

  Store 3 into 'N'  and  0.1  into  'h'   ( if you choose h = 0.1 )
  Store 1 into  'X1'  'X2'  'X3'

                                                                                                                KG  =  0.256837098693
  <<  X1  4  ^  X2  3  ^  X3  SQ  *  *  1  -  >>   ENTER  KGM  >>>    Km  =  0.518666289391                   ( in 16 seconds )
 

Warning:

-This program does not check that  f(x1, ..... ,xn) = 0
 

Initialization - Metric Tensor & Christoffel Symbols
 

-Always execute "INIGC" before calculating the components of the tensors below
 

-You have to store the functions gij in the variables 'G11'  'G22'  .......  'G12'  'G13'  .....
-Since the metric tensor is symmetric, 'G21' ...  are unuseful.

 INIGC  stores  the coefficients gij under the form of a symmetric matrix into 'GIJ',  the inverse matrix into 'G^IJ'
 and the Christoffel symbols  Gkij = (1/2) gkmi gmj + j gimm gij )   are then stored in the variable 'CIJK' under the form of a list,
 only  Gkij with  i <= j  because they are symmetric  Gkji = Gkij
 
 
 
      STACK         INPUT        OUTPUT
       Level 1              /         "DONE"

 
Example:   A 3D-Riemannian manifold, with a metric defined by

    g11 = 1 + x2 y2 z2                            g12 = x y
    g22 = 1 + x2 + y2 + z2                     g13 = x z
    g33 = 1 + x2 y2 + x2 z2 + y2 z2         g23 = y z

-Load for instance these 6 routines into 'G11'  'G22'  'G33'  'G12'  'G13'  'G23'  respectively

    <<  X1  X2  X3  *  *  SQ  1  +  >>
    <<  X1  SQ  X2  SQ  X3  SQ  +  +  1  +  >>
    <<  X1  X2  *  SQ  X1  X3  *  SQ  X2  X3  *  SQ  +  +  1  +  >>
    <<  X1  X2  *  >>
    <<  X1  X3  *  >>
    <<  X2  X3  *  >>

 [ If , say g12 = 0 , you can store 0 in 'G12' instead of  << 0 >> ]

-If we want to calculate the metric tensor, the Christoffel symbols and other tensors at the point  x = y = z = 1  with  h = -0.01

   Store  -0.01  into  'h'  and  3  into  'N'
   Store  1  into  'X1'  'X2'  'X3'

-Then press   INIGC   the program places  "DONE"  in level 1   after 95 seconds and you get

                                             [ [ 2  1  1 ]                                       [ [  5/8  -1/8   -1/8   ]
   The metric tensor  in  GIJ  =  [ 1  4  1 ]       its inverse in  G^IJ      [ -1/8  7/24  -1/24 ]
                                                [ 1  1  4 ] ]                                      [ -1/8 -1/24   7/24 ] ]

   The list of the Christoffel symbols  Gkij   in CIJK = { 0.625  0.5  0.375  ....................  0.75 }

   G111 = 5/8     G112 =  1/2     G113 =  3/8
                      G122 = -1/8   G123 = -3/8
                                             G133 = -3/4

   G211 = -1/8     G212 = 1/6       G213 = -5/24
                        G222 = 7/24   G223 = 5/24
                                               G233 = -1/4

   G311 = -1/8     G312 = -1/6     G313 =  11/24
                        G322 = -1/24  G323 =  13/24
                                               G333 =   3/4
 

-Use  GETCIJK  below to recall these coefficients
 

Recalling Cijk
 

-After executing INIGC
 
 
      STACK        INPUTS      OUTPUTS
       Level 3              i             /
       Level 2              j             /
       Level 1              k           Gkij

 
Example:

   1  ENTER
   2  ENTER
   3  GETCIJK  gives  G312 = -1/6
 

Curvature Tensor ( 0-4 )
 

-The curvature tensor    Rijkl  ( 4 times covariant ) may be computed by the formula:

     Rijkl = (1/2) ( jk gil + il gjk - jl gik - ik gjl ) + gmp ( GmjkGpil - GmjlGpik )
 
 
      STACK        INPUTS      OUTPUTS
       Level 4              i             /
       Level 3              j             /
       Level 2              k             /
       Level 1              l          Rijkl

 
Examples:

 The same metric and with x = y = z = 1

  1  ENTER
  2  ENTER
  1  ENTER
  2  RIJKL  >>>>  R1212 = -5/24

-Likewise

  2  ENTER
  3  ENTER
  1  ENTER
  3   RIJKL    >>>>  R2313 = -7/24                             ---Execution time = 7s---

Notes:

-The curvature tensor has many components but it has also many symmetries
-So there are in fact N =  n2 ( n2 - 1 ) / 12  independant components i-e

   N = 1  if  n = 2
   N = 6  if  n = 3
   N =20 if  n = 4
 

Curvature Tensor ( 1-3 )
 

-The 1-time contravariant 3-times covariant curvature tensor is given by:

      Rlijk = glm Rmijk

-"RIJK^L" calculates these components
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 4              i            /
       Level 3              j             /
       Level 2              k             /
       Level 1              l           Rlijk

 
Examples:

  2  ENTER
  1  ENTER
  2  ENTER
  1  RIJK^L    >>>>  R1212 = -13/96

-Likewise

  3  ENTER
  1  ENTER
  3  ENTER
  2  RIJK^L  >>>>  R2313 = -26/288                                      ---Execution time = 22s---
 

Ricci Tensor
 

-If we contract 2 indices of the curvature tensor ( the 2nd and the 4th ), we get the Ricci tensor which is symmetric

    Rij = gkm  Rikjm

-We can also contract other indices, but it would yield  -Rij
 
 
      STACK        INPUTS      OUTPUTS
       Level 2              i             /
       Level 1              j            Rij

 
Examples:

  1  ENTER
  1    RIJ     >>>>  R11 = 7/96                                        ---Execution time = 60s---                  ( 86 seconds with  h > 0 )

-Likewise

  2  ENTER
  3    RIJ      >>>>  R23 = -277/288                                      ---Execution time = 64s---

-All the components - with i <= j - are

   R11 = +7/96       R22 =  -79/288        R33 = -5/144
   R12 = -28/96      R23 = -277/288
   R13 = -17/96
 

Scalar Riemannian Curvature
 

-Contracting the Ricci tensor, we get the scalar curvature    R = gij  Rij
-RSC calculates and stores R in the variable 'R'
 
 
      STACK        INPUT      OUTPUT
       Level 1             /           R

 
Example:

   RSC  >>>>   R = +11/72                                             ---Execution time = 6m51s---        It would be much slower with h > 0
 

Notes:

-This program is probably the slowest one.
-With a 2D-surface, the scalar curvature is twice the Gaussian curvature given by KGM
 

>>> Always execute RSC before computing Einstein tensor or Weyl tensor. 'R' must contain R
 

Einstein Tensor
 

-Einstein tensor is a symmetric tensor defined as

   Eij = Rij - (1/2) R gij

-Only after executing RSC - which stores R into 'R' - execute EIJ to get the components of Einstein tensor
 
 
 
      STACK        INPUTS       OUTPUTS
       Level 2              i               /
       Level 1              j              Eij

 
Examples:

  1  ENTER
  1     EIJ      >>>>  the HP48 displays  "XEQ RSC FIRST"  and finally     E11 = -23/288                       ---Execution time = 61s---

-Likewise

  2  ENTER
  3     EIJ      >>>>  E23 = -299/288                                                                                            ---Execution time = 65s---

-All the components - with i <= j - are

   E11 = -23/288         E22 = -167/288      E33 = -49/144
   E12 = -53/144         E23 = -299/288
   E13 = -73/288

Notes:

-When you XEQ "EIJ" the HP48 displays "XEQ RSC FIRST" to remind that the variable 'R' must contain the scalar curvature R before executing "EIJ"

-The cosmolical constant  L  is omitted here: the complete tensor is     Eij = Rij - (1/2) R gij + L gij

-Elie Cartan proved that this tensor is the unique tensor T of order 2 involving derivatives of order < 3
 and linear with respect to the 2nd derivatives that satisfies the conservative equations

    Di Tij = 0  for all j    where    Di is the covariant differentiation.

-From  Eij come the equations of General Relativity !
 

Weyl Tensor
 

-Weyl tensor is the covariant tensor of order 4 defined as

   Wijkl = Rijkl + [ 1/(n-2) ] ( Ril gjk - Rik gjl + Rjk gil - Rjl gik ) + [ R/(n-1)/(n-2) ] ( gik gjl - gil gjk )

-Like Einstein tensor, execute "RSC" first before executing "WIJKL"
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 4              i             /
       Level 3              j             /
       Level 2              k             /
       Level 1              l           Wijkl

 
Example:    If n < 4 , Weyl tensor is always equal to 0.

  1  ENTER^
  2  ENTER^
  1  ENTER^
  2  WIJKL  >>>>      W1212 = 0
 

-The number of independent components is n(n-3)(n+1)(n+2)/12

Notes:
 

-When you XEQ "WIJKL" ( if n > 4 ) the HP48 displays "XEQ RSC FIRST"  to remind that 'R' must contain the scalar curvature R before executing WIJKL

>>>>  If you press LASTARG just after executing WIJKL, you'll get Rijkl in level 1 and another partial sum in level 2

-The number of independent components is n(n-3)(n+1)(n+2)/12

-With the same gij  if  i & j < 4 ,  and  g44 = x y z t   ,  g14 = g24 = g34 = 0  ,  t = 1

  after storing 4 in 'N'  1  in  'X4'  exetuting INIGC  and  SRC ,  you will find   W1232 =   35 / 576
 

Curl of a CovariantVector Field
 

-The partial derivatives of a vector is not a tensor   and  Curlij V is defined as   Di Vj - Dj Vi
-But if we apply the formulae given in one of the paragraph below, the Christoffel symbols vanish and finally it yields

     Curlij V = i Vj - j Vi

 CuRL  returns the antisymmetric matrix  [ cij ]
 
 
             STACK             INPUTS            OUTPUTS
              Level n   << f1( x1 , ..... , xn ) >>                    /
              Level ...      .................                    /
              Level 2 << fn-1( x1 , ..... , xn ) >>                    /
              Level 1   << fn( x1 , ..... , xn ) >>                Curl  V

 
Example:      V = ( u , v , w ) = ( x2y2z2 ,  x y z3  ,  x2y z )     x = y = z = 1   with  h = 0.1

  Store   0.1  into  'h'

     <<  X1  X2  X3   *  *   SQ  >>     ENTER
     <<  X1  X2  X3  3  ^  *  *  >>      ENTER
     <<  X1  SQ  X2  X3  *  *  >>       CuRL    returns the matrix:

              [ [ 0  -1   0  ]
                [ 1   0   -2 ]
                [ 0   2    0 ] ]
 

Divergence of a Contravariant Vector Field
 

-The divergence of a vector field V is given by

    Div V =     Di Vi=    i Vi + Giik Vk

-It is a scalar
 
 
             STACK             INPUTS            OUTPUTS
              Level n   << f1( x1 , ..... , xn ) >>                    /
              Level ...      .................                    /
              Level 2 << fn-1( x1 , ..... , xn ) >>                    /
              Level 1   << fn( x1 , ..... , xn ) >>                Div V

 
Example:    Again the same metric at the same point and the following contravariant vector field:

    X = x2 + y z3
    Y = x2 y z2
    Z = x + y z

   << X1  SQ  X2  X3  3  ^  *  +  >>   ENTER
      <<  X1  X3  *  SQ  X2  * >>         ENTER
          << X1  X2  X3  *  + >>             DVG       >>>>    Div V = 10.5
 

Gradient of a Scalar Field
 

-The gradient of a scalar field f is defined as  Gradk f  =  k f    i-e  simply the usual partial derivatives: it is a covariant vector
 
 
      STACK        INPUTS      OUTPUTS
       Level 1   << f(x1,....,xn) >>        Grad f

 
Example:      Again the same metric at the same point ( 1 , 1 , 1 ) and the following scalar field:    f(x,y,z) = x2 + y2 z3
 

    << X1 SQ  X2  SQ  X3  3  ^  *  +  >>   GRaD   >>>   Grad f =  [ 2  2  3 ]
 

Laplacian of a Scalar Field
 

-The Laplacian of the same scalar field f  is a scalar defined by

    Lapl(f) = gjk ( jk f  -  Gijk i f  )
 
 
      STACK        INPUTS      OUTPUTS
       Level 1   << f(x1,....,xn) >>        Lapl f

 
Example:      Again the same metric at the same point ( 1 , 1 , 1 ) and the following scalar field:    f(x,y,z) = x2 + y2 z3
 

    << X1 SQ  X2  SQ  X3  3  ^  *  +  >>   LaPL   >>>   317/96
 

Covariant Derivative of a Contravariant Vector Field
 

-The usual partial derivative of a vector or a tensor is not a tensor, but the covariant derivatives are.
-They involve the partial derivatives and the Christoffel symbols.
-The formulae to get a tensor are not the same if the vector or the tensor is covariant or contravariant:
 

    Di Vj =    i Vj + Gjim Vm

 COV^   returns the matrix whose elements are defined by this formula
 
 
             STACK             INPUTS            OUTPUTS
              Level n   << f1( x1 , ..... , xn ) >>                    /
              Level ...      .................                    /
              Level 2 << fn-1( x1 , ..... , xn ) >>                    /
              Level 1   << fn( x1 , ..... , xn ) >>             [ Di Vj ]

 
Example:    Again the same metric at the same point and the following contravariant vector field:

    X = x2 + y z3
    Y = x2 y z2
    Z = x + y z

   << X1  SQ  X2  X3  3  ^  *  +  >>   ENTER
      <<  X1  X3  *  SQ  X2  * >>         ENTER
          << X1  X2  X3  *  + >>             COV^     gives

    [ [   4.5     1.5     1.5    ]
      [   9/8   49/24  41/24 ]               for instance   D2 V3  = 41 / 24
      [ 15/8   31/24  95/24 ] ]
 

Covariant Derivative of a Covariant Vector Field
 

-The usual partial derivative of a vector or a tensor is not a tensor, but the covariant derivatives are.
-They involve the partial derivatives and the Christoffel symbols.
-The formulae to get a tensor are not the same if the vector or the tensor is covariant or contravariant:
 

    Di Vj =    i Vj - Gmij Vm
 

 COV¯   returns the matrix whose elements are defined by this formula
 
 
             STACK             INPUTS            OUTPUTS
              Level n   << f1( x1 , ..... , xn ) >>                    /
              Level ...      .................                    /
              Level 2 << fn-1( x1 , ..... , xn ) >>                    /
              Level 1   << fn( x1 , ..... , xn ) >>              [ Di Vj ]

 
Example:   Again the same metric at the same point and the following covariant vector field:

    X = x2 + y z3
    Y = x2 y z2
    Z = x + y z

   << X1  SQ  X2  X3  3  ^  *  +  >>   ENTER
      <<  X1  X3  *  SQ  X2  * >>         ENTER
          << X1  X2  X3  *  + >>             COV¯     gives

    [ [   9/8      7/6   -11/24 ]
      [   1/6    25/24   11/24 ]               for instance   D3 V1  = 37 / 24
      [ 37/24  35/24    5/4   ] ]
 

Differential Manifolds with Non-Symmetric Connexions
 

-In Riemannian manifolds, the metric tensor determines the connexion by the Christoffel symbols.
-In more general differential manifolds, the linear connexions Gkij are independant functions and may be non-symmetric.

>>>  So, you have to store  n3  functions in the variables 'C111'   'C112'  'C121'   and so on...
         and the n(n+1) /2  functions gij in 'G11'  'G22'  'G12'  ......
 

-The variables 'h'  &  'N'  are also to be initialized before executing the programs below:
-And of course,  'X1'  'X2'  .......
 

>>>  If the tensor depends on the metric tensor, execute  'INIG' first to calculate and store the coefficients of [ gij ]  and its inverse.
 

Initialization
 

 INIG simply calculates the metric tensor and its inverse
 
 
 
      STACK         INPUT        OUTPUT
       Level 1              /         "DONE"

 
Example:   A 3-dimensional manifold, with the same metric as above and the same coordinates:  x = y = z = 1

    g11 = 1 + x2 y2 z2                            g12 = x y
    g22 = 1 + x2 + y2 + z2                     g13 = x z
    g33 = 1 + x2 y2 + x2 z2 + y2 z2         g23 = y z

-Store the same programs in the variables 'G11'  'G22'  .....   3 in 'N'  and  -0.01  in  'h'

  INIG  stores the same matrix as above

                                             [ [ 2  1  1 ]                                       [ [  5/8  -1/8   -1/8   ]
   The metric tensor  in  GIJ  =  [ 1  4  1 ]       its inverse in  G^IJ      [ -1/8  7/24  -1/24 ]
                                                [ 1  1  4 ] ]                                      [ -1/8 -1/24   7/24 ] ]
 

-Now, suppose the connexion is defined by ( I don't know if it is realistic ):

   G111 = x y2 z2                 G122 = 0
   G112 = x2 y z2   = - G121 G123 = - G132 = 1
   G113 = x2 y2 z   = - G131  G133 = 0

   G211 =  x2 y z                   G222 =  1
   G212 =  x y2 z   = - G221   G223 = G232 = 0
   G213 =  x y z2   = - G231   G233 = 1

   G311 =  x y                        G322 =  0
   G312 =  x z  =  - G321        G323 = - G332 = 1
   G313 =  y z  =  - G331        G333 =  2

-Store  <<  X1  X2  X3  *  SQ  *  >>  in  'C111'  ..................................  and  2  in  'C333'   ( 27 functions )
 

Curvature Tensor (1-3)
 

  RIJK^L calculates the curvature tensor defined as

    Rlijk = jGlik - kGlij + GlmjGmik - GlmkGmij
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 4              i             /
       Level 3              j             /
       Level 2              k             /
       Level 1              l           Rlijk

 
Examples:

  2  ENTER
  1  ENTER
  2  ENTER
  1  RIJK^L    >>>>  R1212 = 0

-Likewise

  3  ENTER
  1  ENTER
  3  ENTER
  2  RIJK^L  >>>>  R2313 = 1
 

Ricci Tensor
 

-Ricci tensor is still  Rij = Rmimj
 
 
 
      STACK        INPUTS      OUTPUTS
       Level 2              i             /
       Level 1              j            Rij

 
Examples:

  1  ENTER
  1    RIJ     >>>>  R11 = 8

-Likewise

  2  ENTER
  3    RIJ      >>>>  R23 =  5
 

Segmental Curvature
 

-There is also a segmental curvature tensor  Qij = Rmmij   which equals zero in Riemannian manifolds.

      Qij = iGmmj - jGmmi  is actually a curl.
 
 
      STACK        INPUTS      OUTPUTS
       Level 2              i             /
       Level 1              j            Qij

 
Examples:

  1  ENTER
  2    QIJ     >>>>  Q12 = 3

-Likewise

  1  ENTER
  3    QIJ      >>>>  Q13 =  2
 

Scalar Curvatures
 

-The contracted tensors  R = gij Rij  and  Q = gij Qij  gives 2 scalars.

>>> To obtain correct results, "INIG" must be executed before RRR & QQQ  to store  gij  in the proper registers.
 
 
      STACK        INPUT      OUTPUT
       Level 1             /        R or Q

 
Examples:   With the same metric & connexion and at the same point, we get:

   RRR  >>>   R = 181/24

   QQQ >>>  Q = 0
 

Torsion Tensor
 

-Since the Christoffel symbols are symmetric in Riemannian manifolds, GkijGkji = 0
-In the general case, we get a tensor of order 3 that is called the torsion tensor

     Skij = GkijGkji                ( some authors define  Skij = (1/2) ( GkijGkji )    others by   Skij = ( GkjiGkij )  )

-Though Gkij is not a tensor, Skij is a tensor !
 
 
      STACK        INPUTS      OUTPUTS
       Level 3              i             /
       Level 2              j             /
       Level 1              k           Skij

 
Examples:

   1  ENTER
   2  ENTER
   3   SIJK    >>>>   S312 = +2

   3  ENTER
   2  ENTER
   1   SIJK      >>>>  S132 = -2
 

Torsion Vector
 

-Contracting  Skij  we get a covariant vector  Sj = Skjk
 
 
      STACK        INPUTS      OUTPUTS
       Level 1              i            Si

 
Examples:

   1   SI    >>>>    S1 =  4
   2   SI    >>>>    S2 =  0
   3   SI    >>>>    S3 = -2
 
 

References:

 [1]  https://en.wikipedia.org/w/index.php?title=Differential_geometry_of_curves&oldid=740874421
 [2]  https://en.wikipedia.org/w/index.php?title=Frenet%E2%80%93Serret_formulas&oldid=731811089
 [3]  Ron Goldman - "Curvature formulas for implicit curves and surfaces"
 [4]  Elie Cartan - "Leçons sur la géométrie des espaces de Riemann" - Gauthier-Villars, Paris   ( in French )
 [5]  Denis-Papin & Kaufmann - "Cours de calcul Tensoriel Appliqué" - Albin Michel    ( in French )
 [6]  List of Formulas in Riemannian Geometry
 [7]  Nikodem J. Poplawski - "Spacetime and fields"- Department of Physics, Indiana University, Bloomington, IN 47405, USA
 [8]  Marie-Antoinette Tonnelat - Theorie unitaire affine du champ physique. J. Phys. Radium, 1951, 12 (2),
        pp.81-88. <10.1051/jphysrad:0195100120208100>. <jpa-00234360>
 [9]  Gerald Kaiser - "Quantum Physics, Relativity, and Complex Spacetime: Towards a New Synthesis"
[10] Giampiero Esposito - "From Spinor Geometry to Complex General Relativity"
[11] Jean E. Charon - "Complex General Relativity"

-The last reference is controversial, but there are many interesting ideas in Charon's theory...