#if !defined(lint) && defined(SCCSIDS)
static char sccsid[] = "@(#)asin.c 1.1 92/07/30 SMI"; /* from S5R3 1.14 */
#endif
/* Copyright (c) 1984 AT&T */
/* All Rights Reserved */
/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */
/* The copyright notice above does not evidence any */
/* actual or intended publication of such source code. */
/*LINTLIBRARY*/
/*
* C program for double-precision asin/acos.
* Returns EDOM error and value 0 if |argument| > 1.
* Algorithm and coefficients from Cody and Waite (1980).
* Calls sqrt if |argument| > 0.5.
*/
#include <math.h>
#include <values.h>
#include <errno.h>
double
asin(x)
double x;
{
extern double asin_acos();
return (asin_acos(x, 0));
}
static double
asin_acos(x, acosflag)
register double x;
int acosflag;
{
register double y;
register int neg = 0, large = 0;
struct exception exc;
exc.arg1 = x;
if (x < 0) {
x = -x;
neg++;
}
if (x > 1) {
exc.type = DOMAIN;
exc.name = acosflag ? "acos" : "asin";
exc.retval = 0.0;
if (!matherr(&exc)) {
(void) write(2, exc.name, 4);
(void) write(2, ": DOMAIN error\n", 15);
errno = EDOM;
}
return (exc.retval);
}
if (x > X_EPS) { /* skip for efficiency and to prevent underflow */
static double p[] = {
-0.69674573447350646411e0,
0.10152522233806463645e2,
-0.39688862997504877339e2,
0.57208227877891731407e2,
-0.27368494524164255994e2,
}, q[] = {
1.0,
-0.23823859153670238830e2,
0.15095270841030604719e3,
-0.38186303361750149284e3,
0.41714430248260412556e3,
-0.16421096714498560795e3,
};
if (x <= 0.5)
y = x * x;
else {
large++;
y = 0.5 - 0.5 * x;
x = -sqrt(y);
x += x;
}
x += x * y * _POLY4(y, p)/_POLY5(y, q);
}
if (acosflag) {
if (!neg)
x = -x;
return (!large ? M_PI_2 + x : neg ? M_PI + x : x);
}
if (large)
x += M_PI_2;
return (neg ? -x : x);
}
double
acos(x)
double x;
{
return (asin_acos(x, 1));
}
![avatar](https://profile-avatar.csdnimg.cn/271c0f59ce4e427783f4849fb0aeba2e_weixin_42662171.jpg!1)
林当时
- 粉丝: 103
- 资源: 1万+
最新资源
- 打包和分发Rust工具.pdf
- SQL中的CREATE LOGFILE GROUP 语句.pdf
- C语言-leetcode题解之第172题阶乘后的零.zip
- C语言-leetcode题解之第171题Excel列表序号.zip
- C语言-leetcode题解之第169题多数元素.zip
- ocr-图像识别资源ocr-图像识别资源
- 图像识别:基于Resnet50 + VGG16模型融合的人体细胞癌症分类模型实现-图像识别资源
- C语言-leetcode题解之第168题Excel列表名称.zip
- C语言-leetcode题解之第167题两数之和II-输入有序数组.zip
- C语言-leetcode题解之第166题分数到小数.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)