::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:
class Math.Real.Public  public Gilda:  Real number arithmetic

  type Complex  is                  &Double precision complex value
       Real    double,              &Real part
       I       double               :Imaginary part

  type Scomplex is                  &Single precision complex value
       Real    single,              &Real part
       I       single               :Imaginary part

  type Point  is                    &Double precision Cartesian coordinate
       X       double,              &Horiontal
       Y       double               :Vertical

  type Spoint is                    &Single precision Cartesian coordinate
       X       single,              &Horiontal
       Y       single               :Vertical

  type Polar  is                    &Double precision polar coordinate
       Radius   double,             &Distance from the origin
       Angle    double              :Direction in radians

  type Spolar is                    &Single precision polar coordinate
       Radius   single,             &Distance from the origin
       Angle    single              :Direction in radians

global Pi     |=  3.14159_26535_89793_23846_26433,    &Archimedes
       Tau    |=  6.28318_53071_79586_47692_52867,    &2 * Pi
       E      |=  2.71828_18284_59045_23536_02874,    &Euler-Napier
       Ln2    |=  0.69314_71805_59945_30941_72321,    &Napier
       Gamma  |=  0.57721_56649_01532_86060_65120,    &Euler-Mascheroni
       Radian |=  0.01745_32925_19943_29576_92369,    &Radains per degree
       Degree |= 57.29577_95130_82320_87679_81548,    &Degrees per radian
                                                      &
       To.Radian( .Degree ) => .Degree * Radian,      &Degrees to Radains
       To.Degree( .Radian ) => .Radian * Degree       :Radains to Degrees
:
:...............................................................................



:::::::::::::::::::::::::: Math.Complex..Complex  ::::::::::::::::::::::::::::::
:
method COMPLEX..Complex:  Set the parts of a Complex number.

  exit Complex                :Complex result

 entry Real = 0  Complex,     &Real part
       I    = 0  Complex      :Imaginary part
:
:...............................................................................
:
function FORM..Complex:  Format a complex number as:  Real+Imginary*i

 entry Complex,                &Complex value
       Format = ""  string     :Real number format

  exit Form   string           :String containing the formatted complex value
:
:...............................................................................
:
function PLUS..Complex:  Complex addition

 entry Complex,                &Complex value
       Addend  Complex         :Complex value to add

  exit Plus    Complex         :Complex + Addend
:
:...............................................................................
:
function MINUS..Complex:  Complex subtraction

 entry Complex,                &Complex value
       Delta   Complex         :Complex value to subtract

  exit Minus   Complex         :Complex - Delta
:
:...............................................................................
:
function TIMES..Complex:  Complex multiplication

 entry Complex,                &Complex value
       Multiplier   Complex    :Complex value

  exit Times  Complex          :Complex * Multiplier
:
:...............................................................................
:
function DIVIDE..Complex:  Complex division

 entry Complex,                &Numerator
       Divisor      Complex    :Divisor

  exit Quotient     Complex    :Complex / Divisor
:
:...............................................................................
:
function SCALE..Complex:  A complex number times a real number.

 entry Complex,                &Complex value
       Real    double          :Real Value

  exit Scale   Complex         :Complex * Real
:
:...............................................................................
:
function SQUARE..Complex:  Square of a complex number

 entry Complex                 :Complex value

  exit Square   Complex        :Complex * Complex
:
:...............................................................................
:
function PRINCIPLE.ROOT..Complex:  Complex square root

 entry Complex                 :Complex value

  exit Root      Complex       :root( Complex )
:
:...............................................................................
:
function RECIPROCAL..Complex:  Complex reciprocal

 entry Complex                 :Complex value

  exit Reciprocal   Complex    :1 / Complex
:
:...............................................................................
:
function CONJUGATE..Complex:  Reflection about the real axis.

 entry Complex                :Complex value

  exit Conjugate  Complex     :Complex value with negated imaginary part
:
:...............................................................................
:
function MODULUS..Complex:  Length of a vector from the origin to a complex value.

 entry Complex                 :Complex value

  exit Modulus  double         :Complex length
:
:...............................................................................
:
function PHASE..Complex:  Angle to the real axis of a line drawn from origin
                       :  to the point represented by the complex number.

 entry Complex                 :Complex value

  exit Phase   double          :Complex phase
:
:...............................................................................



:::::::::::::::::::::::::: Math.Complex..Scomplex  :::::::::::::::::::::::::::::
:
method COMPLEX..Scomplex:  Set the parts of a Complex number.

  exit Scomplex                :Complex result

 entry Real = 0  Scomplex,     &Real part
       I    = 0  Scomplex      :Imaginary part
:
:...............................................................................
:
function FORM..Scomplex:  Format a complex number as:  Real+Imginary*i

 entry Scomplex,               &Complex value
       Format = ""  string     :Real number format

  exit Form   string           :String containing the formatted complex value
:
:...............................................................................
:
function PLUS..Scomplex:  Complex addition

 entry Scomplex,                &Complex value
       Addend  Scomplex         :Complex value to add

  exit Plus    Scomplex         :Complex + Addend
:
:...............................................................................
:
function MINUS..Scomplex:  Complex subtraction

 entry Scomplex,                &Complex value
       Delta   Scomplex         :Complex value to subtract

  exit Minus   Scomplex         :Complex - Delta
:
:...............................................................................
:
function TIMES..Scomplex:  Complex multiplication

 entry Scomplex,                &Complex value
       Multiplier   Scomplex    :Complex value

  exit Times  Scomplex          :Complex * Multiplier
:
:...............................................................................
:
function DIVIDE..Scomplex:  Complex division

 entry Scomplex,                &Numerator
       Divisor      Scomplex    :Divisor

  exit Quotient     Scomplex    :Complex / Divisor
:
:...............................................................................
:
function SCALE..Scomplex:  A complex number times a real number.

 entry Scomplex,                &Complex value
       Real    double           :Real Value

  exit Scale   Scomplex         :Complex * Real
:
:...............................................................................
:
function SQUARE..Scomplex:  Square of a complex number

 entry Scomplex                 :Complex value

  exit Square   Scomplex        :Complex * Complex
:
:...............................................................................
:
function PRINCIPLE.ROOT..Scomplex:  Complex square root

 entry Scomplex                 :Complex value

  exit Root      Scomplex       :root( Complex )
:
:...............................................................................
:
function RECIPROCAL..Scomplex:  Complex reciprocal

 entry Scomplex                 :Complex value

  exit Reciprocal   Scomplex    :1 / Complex
:
:...............................................................................
:
function CONJUGATE..Scomplex:  Reflection about the real axis.

 entry Scomplex                :Complex value

  exit Conjugate  Scomplex     :Complex value with negated imaginary part
:
:...............................................................................
:
function MODULUS..Scomplex:  Length of a vector from the origin to a complex value.

 entry Scomplex                 :Complex value

  exit Modulus  single          :Complex length
:
:...............................................................................
:
function PHASE..Scomplex:  Angle to the real axis of a line drawn from origin
                        :  to the point represented by the complex number.

 entry Scomplex                :Complex value

  exit Phase   single          :Complex phase
:
:...............................................................................



:::::::::::::::::::::::::::: Math.Point..point  ::::::::::::::::::::::::::::::::
:
method POINT..Point  pure:  Initialize a Cartesian coordinate.

  exit Point                :Coordinate to set

 entry X = 0   double,      &Horizontal
       Y = 0   double       :Vertical
:
:...............................................................................
:
function FORM..Point:  Format a point as:  [x, y]

 entry Point,                    &Cartesian coordinate to format
       Format = "("  string      :Braces - "(", "[", "{", "<"

  exit Form          string      :Formatted Cartesian coordinate
:
:...............................................................................
:
function DISTANCE..Point:  Distance between two cartesian coordinates

 entry Point,               &Cartesian coordinate
       To    Point          :Another point

  exit Distance   double    :Distance between them
:
:...............................................................................
:
function TO.POLAR..Point:  Convert Cartesian coordinates to polar.

 entry Point              :Cartesian point to convert

  exit Polar              :Polar result
:
:...............................................................................



::::::::::::::::::::::::::::  Math.Point..spoint  ::::::::::::::::::::::::::::::
:
function FORM..Spoint:  Format a point as:  [x, y]

 entry Point   Spoint,           &Cartesian coordinate to format
       Format = "("  string      :Braces - "(", "[", "{", "<"

  exit Form          string      :Formatted Cartesian coordinate
:
:...............................................................................
:
method POINT..Spoint  pure:  Initialize a Cartesian coordinate.

  exit Point   Spoint            :Coordinate to set

 entry X = 0   single,           &Horizontal
       Y = 0   single            :Vertical
:
:...............................................................................
:
function DISTANCE..Spoint:  Distance between two cartesian coordinates

 entry Spoint,                   &Cartesian coordinate
       To    Spoint              :Another point

  exit Distance   single         :Distance between them
:
:...............................................................................
:
function TO.POLAR..Spoint:  Convert Cartesian coordinates to polar.

 entry Spoint                    :Cartesian point to convert

  exit Spolar                    :Polar result
:
:...............................................................................



:::::::::::::::::::::::::::: Math.Polar..polar  ::::::::::::::::::::::::::::::::
:
method POLAR..Polar  pure:  Initialize a Polar coordinate.

  exit Polar                  :Coordinate to set

 entry Radius = 0  double,    &Real radius
       Angle  = 0  double     :Real angle in radians
:
:...............................................................................
:
function FORM..Polar:  Format a Polar point as:  [radius, angle]

 entry Polar,                  &Polar coordinate to format
       Format = "("  string    :Braces - "(", "[", "{", "<"

  exit Form          string    :Formatted Polar coordinate
:
:...............................................................................
:
function DISTANCE..Polar:  Distance between two polar coordinates

 entry Polar,              &Polar coordinate
       To   Polar          :Another polar coordinate

  exit Distance  double    :Distance between them
:
:...............................................................................
:
function TO.POINT..Polar:  Convert polar coordinates to Cartesian.

 entry Polar              :Polar coordinate to convert

  exit Point              :Cartesian point
:
:...............................................................................



:::::::::::::::::::::::::::: Math.Polar..spolar  :::::::::::::::::::::::::::::::
:
method POLAR..Spolar  pure:  Initialize a Polar coordinate.


 entry Radius = 0  single,    &Real radius
       Angle  = 0  single     :Real angle in radians

  exit Polar   Spolar         :Coordinate to set

:
:...............................................................................
:
function FORM..Spolar:  Format a Polar point as:  [radius, angle]

 entry Polar         Spolar,     &Polar coordinate to format
       Format = "("  string      :Braces - "(", "[", "{", "<"

  exit Form          string      :Formatted Polar coordinate
:
:...............................................................................
:
function DISTANCE..Spolar:  Distance between two polar coordinates

 entry Spolar,             &Polar coordinate
       To   Spolar         :Another polar coordinate

  exit Distance  single    :Distance between them
:
:...............................................................................
:
function TO.POINT..Spolar:  Convert polar coordinates to Cartesian.

 entry Spolar              :Polar coordinate to convert

  exit Spoint              :Cartesian point
:
:...............................................................................


end