<Math. h> is an important library in the C function library. I collect some frequently-used libraries and attach examples or descriptions to some obscure functions. Here, I divide <math. h> into six categories:
Triangle function library;
Anti-triangle function library;
Hyperbolic function library;
Exponential function library and logarithm function library;
Power function database;
The absolute value function library and the remainder function library.
Here we will explain these six categories separately. I believe you will be able to master them well.
I. triangle function library:
Double sin (Double X );
Double cos (Double X );
Double Tan (Double X );
There is no ready-made cot trigonometric function, which can be implemented using Tan (PI/2-x.
Ii. Anti-triangle function library:
Double asin (Double X); value range: [-PI/2, PI/2]
Double ACOs (Double X); value range: [0, Pi]
Double atan (Double X); value range: (-PI/2, PI/2)
Double atan2 (Double Y, double); value range: (-Pi, Pi); this is an uncommon function, mainly used to return the arc tangent value of Y/X. # Define PI 3.14159265
Iii. hyperbolic function library:
Double sinh (Double X); returns the hyperbolic sine.
Double cosh (Double X); returns the hyperbolic cosine.
Double Tanh (Double X); returns the hyperbolic tangent.
If you want to ask me what I do in hyperbolic mode, I can't tell you. I can only tell you that I have a special description in the sixth edition of Tongji University. Again, the above three types of parameter passing are all values expressed in radians and non-angular values.
Iv. exponential function library and logarithm function library:
Double frexp (double value, int * exp); this is an exp that splits the value into the decimal part F and (base on 2) exponent part exp, and returns the fractional part F, that is, f * 2exp. The value of F is between 0.5 and ~ The value range is 1.0 or 0.
For example, frexp (24, & exp) ;=> exp = 5, and the returned value F is 0.75. Double ldexp (Double X, int exp); this function is just opposite to the frexp function above, and its return value is x * 2exp.
Double MODF (double value, double * iptr); splits the value and returns its decimal part. iptr points to the integer part.
Double Log (Double X); returns the natural logarithm Based on E.
Double log10 (Double X); returns the common logarithm.
V. Power function database:
Double POW (Double X, Double Y); returns the value of XY.
Double exp (Double X); returns the value of the ey.
Double SQRT (Double X); return value.
Vi. Absolute value function library and remainder function library:
Double Ceil (Double X); returns the smallest integer greater than X.
Double floor (doulbe X); returns the largest integer smaller than X
These two functions are easy to confuse. Here I will introduce you to a method where the first letter of Ceil and floor is C and F, and the values are between C and F, therefore, the ceil function obtains the smallest integer and the floor function obtains the largest integer.
Double FABS (Double X );
Int ABS (int x); these two functions take absolute values for real and integer data respectively. In fact, ABS functions are also defined in the <stdlib. h> library.
Double fmod (Double Y, double X); Considering that % is only applicable to integer data, here we propose a function dedicated to the remainder operation for real data.
Appendix: atan2 returns the arc tangent of the given X and Y coordinate values.
The angle value of the arc tangent is equal to the angle between the X axis and the straight line through the origin and the given coordinate point (Y, X.
The result is in radians and is between-Pi and PI (excluding-Pi ).
Syntax
Atan2 (Y coordinate, X coordinate)
The X coordinate of the X coordinate point.
Y coordinate.
Description
If the result is positive, it indicates the angle from which the X axis rotates counterclockwise. If the result is negative, it indicates the angle from which the X axis rotates clockwise.
1. atan2 (A, B) is slightly different from atan (A/B). The value range of atan2 (A, B) is between-Pi and PI (excluding-Pi ),
The value range of atan (A/B) is between-PI/2 and PI/2 (excluding ± PI/2 ).
2. If the X and Y coordinates are both zero, atan2 returns an error value # DIV/0 !.
3. If you want the cost to represent an arc tangent value, multiply the result by 180/3. 14159.
If the example is copied to a blank worksheet, the example may be easier to understand.