Multics Technical Bulletin                                MTB-695
  ALM Math Routines

  To:       Distribution

  From:     Betty Wong

  Date:     12 November 1984

  Subject:  Rewrite the System Math Routines

  1.  Abstract

  This  MTB presents  a brief  discussion on  rewriting several ALM
  coded  math routines  presently in  bound_library_wired_.  A more
  detailed  discussion  of  the  numerical  analysis  involved will
  follow in a revised MTB.

  Comments on this MTB should be sent to the author -

       via Multics mail to:

          BWong.Multics on System M

       via posted mail to:

          Betty Wong
          Advanced Computing Technology Centre
          Foothills Professional Building
          Room #301, 1620 - 29th Street N.W.
          Calgary, Alberta T2N-4L7
          CANADA

       via telephone to:

          (403)-270-5400
          (403)-270-5408

  ________________________________________

  Multics project  internal documentation; not to  be reproduced or
  distributed outside the Multics project.


  MTB-695                                Multics Technical Bulletin
                                                  ALM Math Routines

                          TABLE OF CONTENTS

  Section    Page  Subject
  =======    ====  =======

  1             i  Abstract
  2             1  Introduction
  3             2  Proposed Changes
  4             3  Other Work to be Done
  5             4  Expected Effects


  Multics Technical Bulletin                                MTB-695
  ALM Math Routines

  2.  Introduction

  The  existing Multics  math routines were  created by translating
  versions  of the  corresponding GCOS math  routines.  Since then,
  the  GCOS  math  routines  have  been  improved  considerably and
  support added for Hexadecimal  Floating Point (HFP).  On Multics,
  support  for HFP  mode was added  to the math  routines using the
  simplest approach  possible without concern for  making them fast
  (see MTB-687  and MCRs 7066,  7067, and 7069).  Thus  most of the
  current Multics math routines are not  as fast or not as accurate
  as they should be in  either Binary or Hexadecimal Floating Point
  mode.   To rectify  this, we propose  to rewrite some  of the ALM
  coded  math  routines  on  Multics using  the  algorithms  of the
  current  GCOS  versions.   In   addition,  we  will  prevent  the
  underflow and  overflow conditions that may  occur in the current
  routines.

  The changes will affect programs written in PL/1 or Fortran which
  call these routines.


  MTB-695                                Multics Technical Bulletin
                                                  ALM Math Routines

  3.  Proposed Changes

  At  this  time  we  will  deal  with  only  the  'primitive' math
  functions  that are  presently coded  in ALM  and are  bound into
  'bound_library_wired_'.

  The following  routines will be  created using the  algorithms of
  the corresponding GCOS routines:

            arc_sine_           double_arc_sine_
            arc_tangent_        double_arc_tangent_
            exponential_        double_exponential_
            logarithm_          double_logarithm_
            sine_               double_sine_
            square_root_        double_square_root_
            tangent_            double_tangent_

  The    primitive    functions    power_,    power_integer_,   and
  integer_power_integer_  in  'bound_library_wired_'  will  not  be
  rewritten  as  there  is  little difference  between  the current
  algorithms and the current GCOS versions.

  In  addition,  there  are  several primitive  functions  that are
  currently  implemented in  PL/1 and are  bound into 'bound_math_'
  (e.g.   'sinh').   Although we  do not  propose to  rewrite these
  functions  at this  time, it  would be  beneficial to  derive ALM
  versions  from  the  current  GCOS routines  which  are  coded in
  assembly language.


  Multics Technical Bulletin                                MTB-695
  ALM Math Routines

  4.  Other Work to be Done

  The translation  of the GCOS  routines to Multics  will require a
  good deal of numerical analysis.   The algorithms will be checked
  for  accuracy and  corrected if  required.  Each  routine will be
  analyzed to identify potential underflow and overflow conditions.
  Code will be added to  the routines to recognize these conditions
  and to take appropriate actions.

  Some  examples   of  potential  underflow   conditions  are  when
  evaluating the sine, cosine, or  tangent of values which are very
  close  to zero.   Overflows may occur  when evaluating arctangent
  (y,x), where y has a very large  magnitude and x has a very small
  magnitude.


  MTB-695                                Multics Technical Bulletin
                                                  ALM Math Routines

  5.  Expected Effects

  It  is  expected that  the  new routines  will execute  faster in
  Hexadecimal Floating Point (HFP) mode.  Currently the approach in
  HFP  mode  is to  use  mathematical properties  of a  function to
  derive  a formula  for evaluating  the function  in terms  of the
  Binary Floating Point (BFP) version  of the function (see MTB 687
  for more information).  This  involves converting between BFP and
  HFP representations of a number.  The new routines will eliminate
  the  need for  this conversion since  they will  support HFP mode
  directly.  Also, because conversions are not performed, we expect
  results to be more accurate in HFP mode.

  The   new    versions   of   double_tangent_,    arc_sine_,   and
  double_arc_sine_ are  expected to execute faster  in both BFP and
  HFP mode.  This is because  internal calls to other routines will
  be eliminated.  Currently, double_tangent_ calls double_sine_ and
  double_cosine_,     arc_sine_     calls     arc_tangent_,     and
  double_arc_sine_ calls double_arc_tangent_.