1、三角函数 Trigonometric functions
1.1、 cos() 余弦函数
#include <math.h>
double result = cos ( 60 * 3.14159265 / 180.0 );
1.2 sin() 正弦函数
#include <math.h>
double result = sin ( 60 * 3.14159265 / 180.0 );
1.3、 tan() 正切函数
#include <math.h>
double result = tan ( 45 * 3.14159265 / 180.0 );
1.4、 acos() 反余弦函数
#include <math.h>
double result = acos (0.5) * 180.0 / 3.14159265;
1.5、asin() 反正弦函数
#include <math.h>
#define PI 3.14159265
double result =asin (0.5) * 180.0 / PI;
1.6、atan() 反正切函数
#include <math.h>
#define PI 3.14159265
double result =atan (1.0) * 180 / PI;
1.7、atan2() 带两个参数的反正切函数
#include <math.h>
#define PI 3.14159265
double x, y, result;
x = -10.0;
y = 10.0;
result = atan2 (y,x) * 180 / PI;
2、双曲函数 Hyperbolic functions
2.1、双曲余弦函数
#include <math.h>
#define PI 3.14159265
double param, result;
param = log(2.0);
result = cosh (param);
2.2、双曲正弦函数
#include <math.h>
#define PI 3.14159265
double param, result;
param = log(2.0);
result = sinh (param);
2.3、双曲正切函数
#include <math.h>
#define PI 3.14159265
double param, result;
param = log(2.0);
result = tanh (param);
3、指数函数与对数函数 Exponential and logarithmic functions
3.1、exp () 指数函数,以 e 为底数
#include <math.h>
#define PI 3.14159265
double param, result;
param = 5.0;
result = exp (param);
3.2、frexp(param,n) 二进制浮点数表示方法 x=param*2^n
#include <math.h>
#define PI 3.14159265
double param, result;
int n;
param = 8.0;
result = frexp (param , &n);
3.3、log(x) x的自然对数 (Natural logarithm of x)
#include <math.h>
#define PI 3.14159265
double param, result;
param = 5.5;
result = log (param);
3.4、log10() 常用对数,以10为底 ( Common logarithm of x )
#include <math.h>
double param, result;
param = 1000.0;
result = log10 (param);
3.5、modf() 返回x的小数部分,其符号与x相同 ,但是参数中可以添加整数部分的变量( The fractional part of x, with the same sign)
#include <math.h>
double param, fractpart, intpart;
param = 3.14159265;
fractpart = modf (param , &intpart);
3.6、exp2() 返回2的x次方,2 raised to the power of x.
#include <math.h>
double param, result;
param = 8.0;
result = exp2 (param);
3.7、log2() x的二进制对数( The binary logarithm of x)
#include <math.h>
double param, result;
param = 1024.0;
result = log2 (param);
4、幂函数 Power functions
4.1、pow(base, power) 幂函数 The result of raising base to the power exponent
#include <math.h>
double result=pow (7.0, 3.0) ;
4.2、sqrt(x) 计算x的平方根
#include <math.h>
double param, result;
param = 1024.0;
result = sqrt (param);
4.3、cbrt(x) 计算x的立方根
#include <math.h>
double param, result;
param = 27.0;
result = cbrt (param);
4.4、hypot(x,y) 计算直角三角形的斜边 ( The square root of (x2+y2) )
#include <math.h>
double leg_x, leg_y, result;
leg_x = 3;
leg_y = 4;
result = hypot (leg_x, leg_y);
5.1、误差函数erf(x)
#include <math.h>
double param, result;
param = 1.0;
result = erf (param);
5.2、余差函数erfc(x) erfc(x) = 1-erf(x) 误差函数的补函数
#include <math.h>
double param, result;
param = 1.0;
result = erfc (param);
5.3、tgamma(x) 伽马函数 ( the gamma function )
include <math.h>
double param, result;
param = 0.5;
result = tgamma (param);
5.4、lgamma(x) log伽马函数 ( log-gamma function )
#include <math.h>
double param, result;
param = 0.5;
result = lgamma (param);
6、四舍五入与余数函数Rounding and remainder functions
6.1、ceil(x) x上取整函数
#include <math.h> /* ceil */
int res=ceil(2.3) ;
6.2、floor(x) x的下取整函数
#include <math.h> /* ceil */
int res=floor(2.3) ;
6.3、fmod(y, x) y/x的余数
#include <math.h> /* ceil */
int res=fmod (5.3,2);
6.4、round(x) x的四舍五入值
#include <math.h> /* ceil */
int res=round(2.3);
7、绝对值、最小、最大 Absolute、Minimum, maximum
7.1、fabs(x) x的绝对值函数
#include <math.h> /* ceil */
float res= fabs (3.1416) ;
7.2、abs(x) x的绝对值
#include <math.h> /* ceil */
float res= abs (3.1416) ;
7.3、fmax(x, y) 两个参数中的最大值 (The maximum numeric value of its arguments. Values among which the function selects a maximum )
#include <math.h> /* ceil */
float res= fmax(100.0,1.0) ;
7.4、fmin(x, y) 两个参数中的最小值
#include <math.h> /* ceil */
float res= fmin(100.0,1.0);