Dealing with related mathematical functions in c++
- 2020-04-01 21:36:21
- OfStack
Math library function declaration in math.h, the main are:
1. Abs (x) to find the absolute value of the integer x
2, cosine of x, cosine of x radians
3. Fabs (x) to find the absolute value of floating point number x
4. Ceil of x is the smallest integer not less than x
5. Floor (x) shall find the smallest integer not greater than x
6, log of x, take the natural log of x
7. Log base 10 of x
8, pow of x, y, x to the y
Function description:
Pow () is used to calculate the value of base x to the y, or xy, and return the result.
The return value:
Return x to the y.
9, sine of x, sine of x radians
Function description:
Sin () is used to calculate the positive value of the parameter x, and then returns the result.
The return value:
Returns a calculation between -1 and 1.
10, SQRT of x, square root of x
11, acos of x, find the arc cosine
Function description:
Acos () is used to calculate the arccosine of the parameter x, and then returns the result. Parameter x ranges from -1 to 1, beyond which it fails.
The return value:
Returns the calculation between 0 and PI in radians, and the degrees in the library are expressed in radians.
12. Asin (s) for arcsine
Function description:
Asin () is used to calculate the arcsine of the parameter x and return the result. Parameter x ranges from -1 to 1, beyond which it fails.
The return value:
Returns the calculation between PI/2 and PI/2 of -pi /2.
13. Atan (x)
Function description:
Atan () is used to calculate the inverse tangent of the parameter x and return the result.
The return value:
Returns a calculation between -pi /2 and PI/2.
14. Atan2 (x)
Function description:
Atan2 () is used to calculate the inverse tangent of the parameter y/x and return the result.
The return value:
Returns a calculation between -pi /2 and PI/2.
15. Exp (calculate the index)
Function description:
Exp () is used to calculate e to the x, or ex, and return the result.
The return value:
Return e to the x.
16. Frexp (divide floating point Numbers into bases and exponents)
Function description:
Frexp () is used to cut the floating point number of parameter x into bases and exponents. The base part is returned directly, and the exponent part is returned by the exp pointer, which multiplies the value of x by 2 to the exp.
The return value:
Returns the base part of the parameter x, and the exponent part is stored at the address indicated by the exp pointer.
# include < Stdio. H> # include < Math. H>
main()
{
int exp;
double fraction,i;
fraction = frexp (1024,&exp);
i=ldexp(fraction,exp);
printf("exp = %dn",exp);
printf("fraction = %fn", fraction);
printf("i=%f",i);
}
17. Ldexp (calculate 2 to the power)
Function description:
Ldexp () is used to multiply the parameter x by the value of 2 to the exp, x*2exp.
The return value:
Returns the calculated result.
# include < Stdio. H>
# include< Math. H>
main()
{
int exp;
double x,answer;
answer = ldexp(3,2);
printf("3*2^(2) = %fn",answer);
}
18. Log (to calculate the logarithm base e)
Function description:
Log () is used to calculate the x-base e, and return the result.
The return value:
Returns the natural logarithm of the parameter x.
# include < Stdio. H> # include < Math. H>
main()
{
double answer;
answer = log (100);
printf("log(100) = %fn",answer);
}
19. Log10 (to calculate the logarithm base 10)
20. Sinh (take the value of the normal xuan function of the hyperbola)
Function description:
Sinh () is used to calculate the positive value of the hyperbola for the parameter x, and then returns the result. The mathematical definition is :(e to the p(x)-e to the p(-x))/2.
The return value:
Returns the positive value of the hyperbola for the parameter x.
# include < Stdio. H> # include < Math. H>
main()
{
double answer = sinh (0.5);
printf("sinh(0.5) = %fn",answer);
}