📅  最后修改于: 2020-09-25 07:21:11             🧑  作者: Mango
此函数在
[Mathematics] sin-1x = asin(x) [In C++ Programming];
double asin(double x);
float asin(float x);
long double asin(long double x);
double asin (T x);
asin() 函数采用[-1,1]范围内的单个必需参数。
这是因为正弦值在1到-1的范围内。
假设参数在[-1,1]范围内,则asin() 函数返回在[-π/ 2,π/ 2]范围内的值。
如果参数大于1或小于-1,则asin()返回NaN
即不是数字。
Parameter (x) | Return Value |
---|---|
x = [-1, 1] | [-π/, π/2] in radians |
-1 > x or x > 1 | NaN (Not a Number) |
#include
#include
using namespace std;
int main()
{
double x = 0.25, result;
result = asin(x);
cout << "asin(x) = " << result << " radians" << endl;
// result in degrees
cout << "asin(x) = " << result*180/3.1415 << " degrees" << endl;
return 0;
}
运行该程序时,输出为:
asin(x) = 0.25268 radians
asin(x) = 14.4779 degrees
#include
#include
#define PI 3.141592654
using namespace std;
int main()
{
int x = 1;
double result;
result = asin(x);
cout << "asin(x) = " << result << " radians" << endl;
// Converting result to degrees
cout << "asin(x) = " << result*180/PI << " degrees";
return 0;
}
运行该程序时,输出为:
asin(x) = 1.5708 radians
asin(x) = 90 degrees