_c language for processing related mathematical functions in C + +

Source: Internet
Author: User
Tags acos asin mathematical functions natural logarithm pow sin square root

The mathematical library function declaration in the MATH.H, mainly includes:

1. ABS (x) to calculate the absolute value of integer number x

2, cos (x) x (radian) cosine

3, Fabs (x) to find the absolute value of the floating-point number X

4, Ceil (x) to find the smallest integer less than x

5, floor (x) to find the smallest integer greater than X

6, log (x) to find the natural logarithm of X

7, LOG10 (x) to find the logarithm of x (bottom 10)

8, pow (x, y) to find X's Y-second side

Function Description:

POW () is used to calculate Y-square values with x as the base, that is, XY values, and then return the results.

return value:

Returns the Y-second-side calculation of X.

9, sin (x) for the sine of X (radians)

Function Description:

Sin () is used to calculate the positive value of the parameter x, and then returns the result.

return value:

Returns the calculated results from 1 through 1.
10, sqrt (x) to find the square root of X

11, ACOs (x) to seek the reverse cosine

Function Description:

ACOs () is used to calculate the inverse cosine of the parameter x, and then returns the result. The parameter x range is between 1 and 1 and will fail if it exceeds this range.

return value:

Returns the calculated result between 0 and pi, in radians, in radians in the function library.

12, ASIN (s) to the anyway string

Function Description:

ASIN () is used to calculate the inverse chord value of the parameter x, and then returns the result. The parameter x range is between 1 and 1 and will fail if it exceeds this range.

return value:

Returns the result of the calculation between the PI/2 of the-PI/2.

13, Atan (x)

Function Description:

Atan () is used to calculate the tangent value of the parameter x, and then returns the result.

return value:

Returns the result of the calculation between-PI/2 and PI/2.

14, atan2 (x)

Function Description:

ATAN2 () is used to calculate the tangent value of the parameter y/x, and then returns the result.

return value:

Returns the result of the calculation between-PI/2 and PI/2.

15, exp (calculation index)

Function Description:

EXP () is used to calculate the X-square value, the ex value, at the base of E, and then return the result.

return value:

Returns the X-square calculation result of E.

16, Frexp (the number of floating-point types into the base and index)

Function Description:

Frexp () is used to cut the floating-point number of parameter x to base and exponent. The base part is returned directly, the exponent part is returned by the parameter exp pointer, and the return value is multiplied by the value of 2 for the exp secondary square.

return value:

Returns the base portion of the parameter x, and the exponent part is at the address indicated by the EXP pointer.

#include <stdio.h>
#include <math.h>

Copy Code code as follows:

Main ()
{
int exp;
Double fraction,i;
fraction = Frexp (1024,&EXP);
I=ldexp (FRACTION,EXP);
printf ("exp =%d\n", exp);
printf ("fraction =%f\n", fraction);
printf ("i=%f", I);
}

17, Ldexp (Calculate 2 of the second square value)

Function Description:

Ldexp () is used to multiply the parameter x by 2 of the exp quadratic value, that is, the x*2exp.

return value:

Returns the result of the calculation.

/* Compute 3* (2^2) =12 * *

#include <stdio.h>

#include <math.h>

Copy Code code as follows:

Main ()
{
int exp;
Double x,answer;
Answer = LDEXP (3,2);
printf ("3*2^ (2) =%f\n", answer);
}

18, log (to calculate the value of an e-base)

Function Description:

Log () is used to calculate an X pair value with an E, and then returns the result.

return value:

Returns the natural pair value of the parameter x.

#include <stdio.h>
#include <math.h>

Copy Code code as follows:

Main ()
{
Double answer;
Answer = log (100);
printf ("log (m) =%f\n", answer);
}

19, log10 (calculated with a value of 10)

20, Sinh (take the double curve positive and black function value)

Function Description:

Sinh () is used to calculate the hyperbolic positive values of the parameter x, and then returns the result. The mathematical definition is: (exp (x)-exp (-X))/2.

return value:

Returns the hyperbolic positive value of the parameter x.

#include <stdio.h>
#include <math.h>

Copy Code code as follows:

Main ()
{
Double answer = sinh (0.5);
printf ("sinh (0.5) =%f\n", answer);
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.