📄 atanh.c
字号:
#ifndef lintstatic char *sccsid = "@(#)atanh.c 4.1 ULTRIX 7/17/90";#endif lint/************************************************************************ * * * Copyright (c) 1986 by * * Digital Equipment Corporation, Maynard, MA * * All rights reserved. * * * * This software is furnished under a license and may be used and * * copied only in accordance with the terms of such license and * * with the inclusion of the above copyright notice. This * * software or any other copies thereof may not be provided or * * otherwise made available to any other person. No title to and * * ownership of the software is hereby transferred. * * * * This software is derived from software received from the * * University of California, Berkeley, and from Bell * * Laboratories. Use, duplication, or disclosure is subject to * * restrictions under license agreements with University of * * California and with AT&T. * * * * The information in this software is subject to change without * * notice and should not be construed as a commitment by Digital * * Equipment Corporation. * * * * Digital assumes no responsibility for the use or reliability * * of its software on equipment which is not supplied by Digital. * * * ************************************************************************//************************************************************************** Modification History** David Metsky 13-Jan-86** 001 Added from BSD 4.3 version as part of upgrade** Based on: atanh.c 1.2 8/21/85**************************************************************************//* ATANH(X) * RETURN THE HYPERBOLIC ARC TANGENT OF X * DOUBLE PRECISION (VAX D format 56 bits, IEEE DOUBLE 53 BITS) * CODED IN C BY K.C. NG, 1/8/85; * REVISED BY K.C. NG on 2/7/85, 3/7/85, 8/18/85. * * Required kernel function: * log1p(x) ...return log(1+x) * * Method : * Return * 1 2x x * atanh(x) = --- * log(1 + -------) = 0.5 * log1p(2 * --------) * 2 1 - x 1 - x * * Special cases: * atanh(x) is NaN if |x| > 1 with signal; * atanh(NaN) is that NaN with no signal; * atanh(+-1) is +-INF with signal. * * Accuracy: * atanh(x) returns the exact hyperbolic arc tangent of x nearly rounded. * In a test run with 512,000 random arguments on a VAX, the maximum * observed error was 1.87 ulps (units in the last place) at * x= -3.8962076028810414000e-03. */#include <math.h>#include <errno.h>double atanh(x)double x;{ double copysign(),log1p(),z; z = copysign(0.5,x); x = copysign(x,1.0); if (x >= 1.0) { errno = ERANGE; return(copysign(1.0,z)*(HUGE_VAL)); /* sign(x)*HUGE */ } x = x/(1.0-x); return( z*log1p(x+x) );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -