Annotation of 43BSDTahoe/usr.lib/libm/atanh.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1985 Regents of the University of California.
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * Redistribution and use in source and binary forms are permitted
        !             6:  * provided that the above copyright notice and this paragraph are
        !             7:  * duplicated in all such forms and that any documentation,
        !             8:  * advertising materials, and other materials related to such
        !             9:  * distribution and use acknowledge that the software was developed
        !            10:  * by the University of California, Berkeley.  The name of the
        !            11:  * University may not be used to endorse or promote products derived
        !            12:  * from this software without specific prior written permission.
        !            13:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
        !            14:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
        !            15:  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            16:  *
        !            17:  * All recipients should regard themselves as participants in an ongoing
        !            18:  * research project and hence should feel obligated to report their
        !            19:  * experiences (good or bad) with these elementary function codes, using
        !            20:  * the sendbug(8) program, to the authors.
        !            21:  */
        !            22: 
        !            23: #ifndef lint
        !            24: static char sccsid[] = "@(#)atanh.c    5.3 (Berkeley) 6/30/88";
        !            25: #endif /* not lint */
        !            26: 
        !            27: /* ATANH(X)
        !            28:  * RETURN THE HYPERBOLIC ARC TANGENT OF X
        !            29:  * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS)
        !            30:  * CODED IN C BY K.C. NG, 1/8/85; 
        !            31:  * REVISED BY K.C. NG on 2/7/85, 3/7/85, 8/18/85.
        !            32:  *
        !            33:  * Required kernel function:
        !            34:  *     log1p(x)        ...return log(1+x)
        !            35:  *
        !            36:  * Method :
        !            37:  *     Return 
        !            38:  *                          1              2x                          x
        !            39:  *             atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------)
        !            40:  *                          2             1 - x                      1 - x
        !            41:  *
        !            42:  * Special cases:
        !            43:  *     atanh(x) is NaN if |x| > 1 with signal;
        !            44:  *     atanh(NaN) is that NaN with no signal;
        !            45:  *     atanh(+-1) is +-INF with signal.
        !            46:  *
        !            47:  * Accuracy:
        !            48:  *     atanh(x) returns the exact hyperbolic arc tangent of x nearly rounded.
        !            49:  *     In a test run with 512,000 random arguments on a VAX, the maximum
        !            50:  *     observed error was 1.87 ulps (units in the last place) at
        !            51:  *     x= -3.8962076028810414000e-03.
        !            52:  */
        !            53: #if defined(vax)||defined(tahoe)
        !            54: #include <errno.h>
        !            55: #endif /* defined(vax)||defined(tahoe) */
        !            56: 
        !            57: double atanh(x)
        !            58: double x;
        !            59: {
        !            60:        double copysign(),log1p(),z;
        !            61:        z = copysign(0.5,x);
        !            62:        x = copysign(x,1.0);
        !            63: #if defined(vax)||defined(tahoe)
        !            64:        if (x == 1.0) {
        !            65:            extern double infnan();
        !            66:            return(copysign(1.0,z)*infnan(ERANGE));     /* sign(x)*INF */
        !            67:        }
        !            68: #endif /* defined(vax)||defined(tahoe) */
        !            69:        x = x/(1.0-x);
        !            70:        return( z*log1p(x+x) );
        !            71: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.