X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/55de90f00fe552ff0ed990b569b5463cfc7c1a6e..875ee27b06ff5e1e3b5ecdbe2bf239fb07fcd2d8:/usr/src/lib/libm/README diff --git a/usr/src/lib/libm/README b/usr/src/lib/libm/README index 97feec00fe..b3e4cb9d63 100644 --- a/usr/src/lib/libm/README +++ b/usr/src/lib/libm/README @@ -1,22 +1,38 @@ -# @(#)README 1.2 (ELEFUNT) %G% --1. The machine-independent Version 7 math library found in 4.2BSD - is now "/usr/lib/libom.a". To compile with those routines use -lom. +*************************************************************************** +* * +* Copyright (c) 1985 Regents of the University of California. * +* * +* Use and reproduction of this software are granted in accordance with * +* the terms and conditions specified in the Berkeley Software License * +* Agreement (in particular, this entails acknowledgement of the programs' * +* source, and inclusion of this notice) with the additional understanding * +* that all recipients should regard themselves as participants in an * +* ongoing research project and hence should feel obligated to report * +* their experiences (good or bad) with these elementary function codes, * +* using "sendbug 4bsd-bugs@BERKELEY", to the authors. * +* * +* K.C. Ng, with Z-S. Alex Liu, S. McDonald, P. Tang, W. Kahan. * +* Revised on 5/10/85, 5/13/85, 6/14/85, 8/20/85, 8/27/85, 9/11/85. * +* * +*************************************************************************** -K.C. Ng, March 7, 1985, with Z-S. Alex Liu, S. McDonald, P. Tang, W. Kahan. -Revised on 5/10/85, 5/13/85, 6/14/85, 8/20/85, 8/27/85. +/* @(#)README 1.6 (Berkeley) 9/12/85; 1.3 (ucb.elefunt) %G% */ + +NB. The machine-independent Version 7 math library found in 4.2BSD + is now /usr/lib/libom.a. To compile with those routines use -lom. ****************************************************************************** * This is a description of the upgraded elementary functions (listed in 1). * * Bessel functions (j0, j1, jn, y0, y1, yn), floor, and fabs passed over * * from 4.2BSD without change except perhaps for the way floating point * -* exception is signaled on a VAX. Three lines that contain "errno in erf.c * -* (error function erf, erfc) have been deleted to prevent overriding the * +* exception is signaled on a VAX. Three lines that contain "errno" in erf.c* +* (error functions erf, erfc) have been deleted to prevent overriding the * * system "errno". * ****************************************************************************** 0. Total number of files: 40 - IEEE/Makefile VAX/Makefile VAX/support.s erf.c lgama.c + IEEE/Makefile VAX/Makefile VAX/support.s erf.c lgamma.c IEEE/atan2.c VAX/argred.s VAX/tan.s exp.c log.c IEEE/cabs.c VAX/atan2.s acosh.c exp__E.c log10.c IEEE/cbrt.c VAX/cabs.s asincos.c expm1.c log1p.c @@ -25,47 +41,44 @@ Revised on 5/10/85, 5/13/85, 6/14/85, 8/20/85, 8/27/85. Makefile VAX/sincos.s atanh.c j1.c sinh.c README VAX/sqrt.s cosh.c jn.c tanh.c -1. Functions implemented: - (A). Standard elementary functions (total 22): - acos(x) ... in file "asincos.c" - asin(x) ... in file "asincos.c" - atan(x) ... in file "atan.c" - atan2(x,y) ... in files "IEEE/atan2.c", "VAX/atan2.s" - sin(x) ... in files "IEEE/trig.c", "VAX/sincos.s" - cos(x) ... in files "IEEE/trig.c", "VAX/sincos.s" - tan(x) ... in files "IEEE/trig.c", "VAX/tan.s" - cabs(x,y) ... in files "IEEE/cabs.c", "VAX/cabs.s" - hypot(x,y) ... in files "IEEE/cabs.c", "VAX/cabs.s" - cbrt(x) ... in files "IEEE/cbrt.c", "VAX/cbrt.s" - exp(x) ... in file "exp.c" - expm1(x):=exp(x)-1 ... in file "expm1.c" - log(x) ... in file "log.c" - log10(x) ... in file "log10.c" - log1p(x):=log(1+x) ... in file "log1p.c" - pow(x,y) ... in file "pow.c" - sinh(x) ... in file "sinh.c" - cosh(x) ... in file "cosh.c" - tanh(x) ... in file "tanh.c" - asinh(x) ... in file "asinh.c" - acosh(x) ... in file "acosh.c" - atanh(x) ... in file "atanh.c" - +1. Functions implemented : + (A). Standard elementary functions (total 22) : + acos(x) ...in file asincos.c + asin(x) ...in file asincos.c + atan(x) ...in file atan.c + atan2(x,y) ...in files IEEE/atan2.c, VAX/atan2.s + sin(x) ...in files IEEE/trig.c, VAX/sincos.s + cos(x) ...in files IEEE/trig.c, VAX/sincos.s + tan(x) ...in files IEEE/trig.c, VAX/tan.s + cabs(x,y) ...in files IEEE/cabs.c, VAX/cabs.s + hypot(x,y) ...in files IEEE/cabs.c, VAX/cabs.s + cbrt(x) ...in files IEEE/cbrt.c, VAX/cbrt.s + exp(x) ...in file exp.c + expm1(x):=exp(x)-1 ...in file expm1.c + log(x) ...in file log.c + log10(x) ...in file log10.c + log1p(x):=log(1+x) ...in file log1p.c + pow(x,y) ...in file pow.c + sinh(x) ...in file sinh.c + cosh(x) ...in file cosh.c + tanh(x) ...in file tanh.c + asinh(x) ...in file asinh.c + acosh(x) ...in file acosh.c + atanh(x) ...in file atanh.c + (B). Kernel functions : - exp__E(x,c) ... in file "exp__E.c", used by - expm1(), exp(), pow() and cosh() - log__L(s) ... in file "log__L.c", used by - log1p(), log() and pow() - libm$argred ... in file "VAX/argred.s", used by VAX version of - sin(), cos() and tan() + exp__E(x,c) ...in file exp__E.c, used by expm1/exp/pow/cosh + log__L(s) ...in file log__L.c, used by log1p/log/pow + libm$argred ...in file VAX/argred.s, used by VAX version of sin/cos/tan (C). System supported functions : - sqrt() ... in files "IEEE/support.c", "VAX/sqrt.s" - drem() ... in files "IEEE/support.c", "VAX/support.s" - finite() ... in files "IEEE/support.c", "VAX/support.s" - logb() ... in files "IEEE/support.c", "VAX/support.s" - scalb() ... in files "IEEE/support.c", "VAX/support.s" - copysign() ... in files "IEEE/support.c", "VAX/support.s" - rint() ... in file "floor.c" + sqrt() ...in files IEEE/support.c, VAX/sqrt.s + drem() ...in files IEEE/support.c, VAX/support.s + finite() ...in files IEEE/support.c, VAX/support.s + logb() ...in files IEEE/support.c, VAX/support.s + scalb() ...in files IEEE/support.c, VAX/support.s + copysign() ...in files IEEE/support.c, VAX/support.s + rint() ...in file floor.c Notes: @@ -77,33 +90,33 @@ Revised on 5/10/85, 5/13/85, 6/14/85, 8/20/85, 8/27/85. standard 754 for double precision floating-point arithmetic. ii. On other than VAX or IEEE machines, run the original math - library, formerly "/usr/lib/libm.a", now "/usr/lib/libom.a", - if nothing better is available. + library, formerly "/usr/lib/libm.a", now "/usr/lib/libom.a", if + nothing better is available. - iii. The trigonometric functions sin(), cos(), tan() and atan2() in files - "VAX/sincos.s", "VAX/tan.s" and "VAX/atan2.s" are different from - those in "IEEE/trig.c" and "IEEE/atan2.c". The VAX assembler code - uses the true value of pi to perform argument reduction, while the - C code uses the machine's value of PI rounded (see "IEEE/trig.c"). + iii. The trigonometric functions sin/cos/tan/atan2 in files "VAX/sincos.s", + "VAX/tan.s" and "VAX/atan2.s" are different from those in + "IEEE/trig.c" and "IEEE/atan2.c". The VAX assembler code uses the + true value of pi to perform argument reduction, while the C code uses + a machine value of PI (see "IEEE/trig.c"). 2. A computer system that conforms to IEEE standard 754 should provide - sqrt(x), - drem(x,p), (double precision remainder function) - copysign(x,y), - finite(x), - scalb(x,N), - logb(x) and - rint(x). + sqrt(x), + drem(x,p), (double precision remainder function) + copysign(x,y), + finite(x), + scalb(x,N), + logb(x) and + rint(x). These functions are either required or recommended by the standard. For convenience, a (slow) C implementation of these functions is provided in the file "IEEE/support.c". - Warning: The functions in "IEEE/support.c" are somewhat machine dependent. + Warning: The functions in IEEE/support.c are somewhat machine dependent. Some modifications may be necessary to run them on a different machine. - Currently, if compiled with a suitable flag, "IEEE/support.c" will work on a - National 32000, a Zilog 8000, a VAX, and a SUN (cf. the "Makefile" in - this directory). Invoke the C compiler thus: + Currently, if compiled with a suitable flag, "IEEE/support.c" will work + on a National 32000, a Zilog 8000, a VAX, and a SUN (cf. the "Makefile" + in this directory). Invoke the C compiler thus: cc -c -DVAX IEEE/support.c ... on a VAX, D-format cc -c -DNATIONAL IEEE/support.c ... on a National 32000 @@ -125,8 +138,8 @@ Revised on 5/10/85, 5/13/85, 6/14/85, 8/20/85, 8/27/85. the VAX D-format (56-bit precision), and the IEEE double format (53-bit precision). The cbrt() in "IEEE/cbrt.c" is for IEEE machines only. The functions in files that end with ".s" are for VAX computers - only. The functions in files that end with ".c" (except "IEEE/cbrt.c") are - for VAX and IEEE machines. To use the VAX D-format, compile the code + only. The functions in files that end with ".c" (except "IEEE/cbrt.c") + are for VAX and IEEE machines. To use the VAX D-format, compile the code with -DVAX; to use IEEE double format on various IEEE machines, see "Makefile" in this directory). @@ -140,7 +153,7 @@ Revised on 5/10/85, 5/13/85, 6/14/85, 8/20/85, 8/27/85. enough to produce the hexadecimal values shown. If the conversion is inaccurate, then one must know the exact machine representation of the constants and alter the assembly - language output from the compiler, or play tricks like + language output from the compiler, or play tricks like the following in a C program. Example: to store the floating-point constant @@ -151,11 +164,11 @@ Revised on 5/10/85, 5/13/85, 6/14/85, 8/20/85, 8/27/85. machine value and define p1 to be the double constant at the location of these two longwords: - static long p1x[] = {0x3abe3d78, 0x066a67e1}; + static long p1x[] = { 0x3abe3d78, 0x066a67e1}; #define p1 (*(double*)p1x) Note: On a VAX, some functions have two codes. For example, cabs() has - one implementation in "IEEE/cabs.c", and another in "VAX/cabs.s". + one implementation in "IEEE/cabs.c", and another in "VAX/cabs.s". In this case, the assembly language version is preferred. @@ -169,15 +182,15 @@ Revised on 5/10/85, 5/13/85, 6/14/85, 8/20/85, 8/27/85. on all tested machines (VAX, SUN, NATIONAL, ZILOG), provided that x to the power of y is representable exactly. - cosh(), sinh(), acosh(), asinh(), tanh(), atanh() and log10() have - errors below about 3 ULPs. + cosh, sinh, acosh, asinh, tanh, atanh and log10 have errors below + about 3 ULPs. - For trigonometric and inverse trigonometric functions, let - [trig(x)] denote the value actually computed for trig(x). + For trigonometric and inverse trigonometric functions: + + Let [trig(x)] denote the value actually computed for trig(x), 1) Those codes using the machine's value PI (true pi rounded): - (in files "IEEE/trig.c", "IEEE/atan2.c", "asincos.c" and - "atan.c".) + (source codes: IEEE/{trig.c,atan2.c}, asincos.c and atan.c) The errors in [sin(x)], [cos(x)], and [atan(x)] are below 1 ULP compared with sin(x*pi/PI), cos(x*pi/PI), and @@ -187,14 +200,16 @@ Revised on 5/10/85, 5/13/85, 6/14/85, 8/20/85, 8/27/85. return acos(x)*PI/pi, asin(x)*PI/pi, and atan2(y,x)*PI/pi respectively to similar accuracy. + 2) Those using true pi (for VAX D-format only): - (in files "VAX/sincos.s", "VAX/tan.s", "VAX/atan2.s", - "asincos.c" and "atan.c".) + (source codes: VAX/{sincos.s,tan.s,atan2.s}, asincos.c and + atan.c) The errors in [sin(x)], [cos(x)], and [atan(x)] are below - 1 ULP. [tan(x)], [atan2(y,x)], [acos(x)], and [asin(x)] + 1 ULP. [tan(x)], [atan2(y,x)], [acos(x)], and [asin(x)] have errors below about 2 ULPs. + Here are the results of some test runs to find worst errors on the VAX : @@ -243,25 +258,7 @@ Revised on 5/10/85, 5/13/85, 6/14/85, 8/20/85, 8/27/85. be called via short subroutine calls. -6. j0,j1,jn. +6. j0, j1, jn. The modifications to these routines were only in how an invalid - floating point operation is signaled on a VAX. - - -7. Copyright notice, and Disclaimer: - -*************************************************************************** -* * -* Copyright (c) 1985 Regents of the University of California. * -* * -* Use and reproduction of this software are granted in accordance with * -* the terms and conditions specified in the Berkeley Software License * -* Agreement (in particular, this entails acknowledgement of the programs' * -* source, and inclusion of this notice) with the additional understanding * -* that all recipients should regard themselves as participants in an * -* ongoing research project and hence should feel obligated to report * -* their experiences (good or bad) with these elementary function codes, * -* using "sendbug 4bsd-bugs@BERKELEY", to the authors. * -* * -*************************************************************************** + floating point operations is signaled.