十年網(wǎng)站開發(fā)經(jīng)驗 + 多家企業(yè)客戶 + 靠譜的建站團隊
量身定制 + 運營維護+專業(yè)推廣+無憂售后,網(wǎng)站問題一站解決
一些數(shù)學(xué)計算的公式的具體實現(xiàn)是放在math.h里,具體有:
網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)!專注于網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、重慶小程序開發(fā)公司、集團企業(yè)網(wǎng)站建設(shè)等服務(wù)項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了岑溪免費建站歡迎大家使用!
double sin (double x); x的正弦值
double cos (double x); x的余弦值
double tan (double x); x的正切值
double asin (double x); 結(jié)果介于[-PI/2, PI/2],x值域為[-1,1]
double acos (double x); 結(jié)果介于[0, PI],x值域為[-1,1]
double atan (double x); 反正切(主值), 結(jié)果介于[-PI/2, PI/2]
double atan2 (double y, double x); 反正切(整圓值), 結(jié)果介于[-PI, PI]
double sinh (double x); x的雙曲正弦值
double cosh (double x); x的雙曲余弦值
double tanh (double x); x的雙曲正切值
double exp (double x); 冪函數(shù)e^x
double pow (double x, double y); x^y,如果x=0且y=0,或者x0且y不是整型數(shù),將產(chǎn)生定義域錯誤
double sqrt (double x); x的平方根,其中x=0
double log (double x); 以e為底的對數(shù),自然對數(shù),x0
double log10 (double x); 以10為底的對數(shù),x0
double ceil (double x); 取上整
double floor (double x); 取下整
double fabs (double x); x的絕對值
double frexp (double x, int *exp); 標(biāo)準(zhǔn)化浮點數(shù), x = f * 2^exp, 已知x求f, exp ( x介于[0.5, 1] )并返回f值
double ldexp (double x, int exp); 與frexp相反, 已知x, exp求x*2^exp
double modf (double x, double *ip); 將參數(shù)的整數(shù)部分通過指針回傳, 返回小數(shù)部分,整數(shù)部分保存在*ip中
double fmod (double x, double y); 返回兩參數(shù)相除x/y的余數(shù),符號與x相同。如果y為0,則結(jié)果與具體的額實現(xiàn)有關(guān)
包含頭文件math.h,寫成sin(x);的形式直接調(diào)用這個函數(shù)。其中x是double型弧度值。函數(shù)返回一個double值。如有double
x=3.1415926/180*30;,那么printf("sin30°
=
%f\n",sin(x));將輸出sin30°
=
0.500000。
修改建議
您的回答內(nèi)容不完整
知識型提問需要先直接對提問進行回復(fù),開門見山,再對相關(guān)知識點進行延伸,如:加油哦!
你拒絕認(rèn)證吧,這沒有完善的必要了,學(xué)過三角函數(shù)的人都能看懂,看了10頁C教科書的也都知道怎么寫了。還要怎樣“開門見山”,怎樣“延伸”?難道還得解釋sin是對邊比斜邊?
abs() 好像是stdlib.h的函數(shù)吧?
math.h
The math header defines several mathematic functions.
Macros:
HUGE_VAL
Functions:
acos();
asin();
atan();
atan2();
ceil();
cos();
cosh();
exp();
fabs();
floor();
fmod();
frexp();
ldexp();
log();
log10();
modf();
pow();
sin();
sinh();
sqrt();
tan();
tanh();
2.7.1 Error Conditions
All math.h functions handle errors similarly.
In the case that the argument passed to the function exceeds the range of that function, then the variable errno is set to EDOM. The value that the function returns is implementation specific.
In the case that the value being returned is too large to be represented in a double, then the function returns the macro HUGE_VAL, and sets the variable errno to ERANGE to represent an overflow. If the value is too small to be represented in a double, then the function returns zero. In this case whether or not errno is set to ERANGE is implementation specific.
errno, EDOM, and ERANGE are defined in the errno.h header.
Note that in all cases when it is stated that there is no range limit, it is implied that the value is limited by the minimum and maximum values of type double.
2.7.2 Trigonometric Functions
2.7.2.1 acos
Declaration:
double acos(double x);
Returns the arc cosine of x in radians.
Range:
The value x must be within the range of -1 to +1 (inclusive). The returned value is in the range of 0 to pi (inclusive).
2.7.2.2 asin
Declaration:
double asin(double x);
Returns the arc sine of x in radians.
Range:
The value of x must be within the range of -1 to +1 (inclusive). The returned value is in the range of -p/2 to +p/2 (inclusive).
2.7.2.3 atan
Declaration:
double atan(double x);
Returns the arc tangent of x in radians.
Range:
The value of x has no range. The returned value is in the range of -p/2 to +p/2 (inclusive).
2.7.2.4 atan2
Declaration:
double atan2(doubly y, double x);
Returns the arc tangent in radians of y/x based on the signs of both values to determine the correct quadrant.
Range:
Both y and x cannot be zero. The returned value is in the range of -p/2 to +p/2 (inclusive).
2.7.2.5 cos
Declaration:
double cos(double x);
Returns the cosine of a radian angle x.
Range:
The value of x has no range. The returned value is in the range of -1 to +1 (inclusive).
2.7.2.6 cosh
Declaration:
double cosh(double x);
Returns the hyperbolic cosine of x.
Range:
There is no range limit on the argument or return value.
2.7.2.7 sin
Declaration:
double sin(double x);
Returns the sine of a radian angle x.
Range:
The value of x has no range. The returned value is in the range of -1 to +1 (inclusive).
2.7.2.8 sinh
Declaration:
double sinh(double x);
Returns the hyperbolic sine of x.
Range:
There is no range limit on the argument or return value.
2.7.2.9 tan
Declaration:
double tan(double x);
Returns the tangent of a radian angle x.
Range:
There is no range limit on the argument or return value.
2.7.2.10 tanh
Declaration:
double tanh(double x);
Returns the hyperbolic tangent of x.
Range:
The value of x has no range. The returned value is in the range of -1 to +1 (inclusive).
2.7.3 Exponential, Logarithmic, and Power Functions
2.7.3.1 exp
Declaration:
double exp(double x);
Returns the value of e raised to the xth power.
Range:
There is no range limit on the argument or return value.
2.7.3.2 frexp
Declaration:
double frexp(double x, int *exponent);
The floating-point number x is broken up into a mantissa and exponent.
The returned value is the mantissa and the integer pointed to by exponent is the exponent. The resultant value is x=mantissa * 2^exponent.
Range:
The mantissa is in the range of .5 (inclusive) to 1 (exclusive).
2.7.3.3 ldexp
Declaration:
double ldexp(double x, int exponent);
Returns x multiplied by 2 raised to the power of exponent.
x*2^exponent
Range:
There is no range limit on the argument or return value.
2.7.3.4 log
Declaration:
double log(double x);
Returns the natural logarithm (base-e logarithm) of x.
Range:
There is no range limit on the argument or return value.
2.7.3.5 log10
Declaration:
double log10(double x);
Returns the common logarithm (base-10 logarithm) of x.
Range:
There is no range limit on the argument or return value.
2.7.3.6 modf
Declaration:
double modf(double x, double *integer);
Breaks the floating-point number x into integer and fraction components.
The returned value is the fraction component (part after the decimal), and sets integer to the integer component.
Range:
There is no range limit on the argument or return value.
2.7.3.7 pow
Declaration:
double pow(double x, double y);
Returns x raised to the power of y.
Range:
x cannot be negative if y is a fractional value. x cannot be zero if y is less than or equal to zero.
2.7.3.8 sqrt
Declaration:
double sqrt(double x);
Returns the square root of x.
Range:
The argument cannot be negative. The returned value is always positive.
2.7.4 Other Math Functions
2.7.4.1 ceil
Declaration:
double ceil(double x);
Returns the smallest integer value greater than or equal to x.
Range:
There is no range limit on the argument or return value.
2.7.4.2 fabs
Declaration:
double fabs(double x);
Returns the absolute value of x (a negative value becomes positive, positive value is unchanged).
Range:
There is no range limit on the argument. The return value is always positive.
2.7.4.3 floor
Declaration:
double floor(double x);
Returns the largest integer value less than or equal to x.
Range:
There is no range limit on the argument or return value.
2.7.4.4 fmod
Declaration:
double fmod(double x, double y);
Returns the remainder of x divided by y.
Range:
There is no range limit on the return value. If y is zero, then either a range error will occur or the function will return zero (implementation-defined).