C ++数学函数

可以使用数学或cmath库中包含的数学函数,以C ++编程语言完成数学计算。定义这些数学函数以执行复杂的数学计算。让我们逐一学习它们-

正弦

sin方法用于计算以度数为参数给出的角度的sin。此函数接受一个双精度整数作为参数,并返回一个双精度整数,即sin(x°)的值。

双罪(双)

调用语法

double x = sin(23.4);

#include <iostream>
#include <math.h>
using namespace std;
int main(){
   double x = 45.3;
   cout << "sin ( "<<x<<" ) = " << sin(x) << endl;
}

输出结果

sin( 45.3 ) = 0.968142

余弦

cosin或cos方法用于计算以度数为参数给出的角度的cos。此函数接受一个双精度整数作为参数,并返回一个双精度整数,即cos(x°)的值。

双cos(双)

调用语法

double x = cos(23.4);

#include <iostream>
#include <math.h>
using namespace std;
int main(){
   double x = 45.3;
   cout << "cos ( "<<x<<" ) = " << cos(x) << endl;
}

输出结果

cos( 45.3 ) = 0.2504

切线

切线或tan方法用于计算角度(以度为单位)的tan。此函数接受一个双精度整数作为参数,并返回一个双精度整数,即tan(xo)= sin(x°)∕ cos(x°)的值。

双棕褐色(双)

调用语法

double x = tan(23.4);

#include <iostream>
#include <math.h>
using namespace std;
int main(){
   double x = 45.3;
   cout << "tan ( "<<x<<" ) = " << tan(x) << endl;
}

输出结果

tan( 45.3 ) = 3.86638

阿辛

asin函数用于查找给定参数的反正弦。它返回给定输入集的asin值,该值可以是-1到1范围内的任何双整数,否则会产生错误。该函数接受-1和1之间的double整数,并作为asin()的结果返回double值。

双阿辛(双)

调用语法

double x = asin(0.3232);

#include <iostream>
#include <math.h>
using namespace std;
int main(){
   double x = 0.3232;
   cout << "asin ( "<<x<<" ) = " << asin(x) << endl;
}

输出结果

asin( 0.3232 ) = 0.3291

阿科斯

acos函数用于查找给定参数的反余弦。它返回给定输入集的acos值,该值可以是-1到1范围内的任何双整数,否则会产生错误。该函数接受-1和1之间的双精度整数,并由于acos()返回一个双精度值。

双acos(双)

调用语法

double x = acos(0.3232);

#include <iostream>
#include <math.h>
using namespace std;
int main(){
   double x = 0.3232;
   cout << "acos ( "<<x<<" ) = " << acos(x) << endl;
}

输出结果

acos( 0.3232 ) = 1.24169

晒黑

atan函数用于计算给定参数的反正切值。对于参数中的双精度输入值,它将返回atan的双精度值。

Double atan(double)

调用语法

double x = atan(0.3232);

#include <iostream>
#include <math.h>
using namespace std;
int main(){
   double x = 0.3232;
   cout << "atan ( "<<x<<" ) = " << atan(x) << endl;
}

输出结果

atan( 0.3232 ) = 0.312603

科什

cosh函数用于计算给定参数的双曲余弦值。它为参数中的双输入值返回cosh的双值。

双cosh(双)

调用语法

double x = cosh(0.342);

#include <iostream>
#include <math.h>
using namespace std;
int main(){
   double x = 0.342;
   cout << "cosh ( "<<x<<" ) = " << cosh(x) << endl;
}

输出结果

cosh( 0.342 ) = 1.05905

sinh函数用于计算给定参数的双曲正弦值。它为参数中的双精度输入值返回sinh的双精度值。

双sin(双)

调用语法

double x = sinh(0.342);

#include <iostream>
#include <math.h>
using namespace std;
int main(){
   double x = 0.342;
   cout << "sinh ( "<<x<<" ) = " << sinh(x) << endl;
}

输出结果

sinh( 0.342 ) = 0.348706

tanh函数用于计算给定参数的双曲正切值。它为参数中的双精度输入值返回sinh的双精度值。

双箱(双)

调用语法

double x = tanh(0.342);

#include <iostream>
#include <math.h>
using namespace std;
int main(){
   double x = 0.342;
   cout << "tanh ( "<<x<<" ) = " << tanh(x) << endl;
}

输出结果

tanh( 0.342 ) = 0.329262

pow函数用于计算基数的幂到指数幂。它接受两个双精度值作为基数和指数数的参数,并返回一个以指数幂为基数的单个双精度整数。

双战俘(双,双)

调用语法

double x = pow(2, 4)

#include <iostream>
#include <math.h>
using namespace std;
int main(){
   double base = 2 , power = 4;
   cout << "pow( "<<base<<" , "<<power<<" ) = " << pow(base, power) << endl;
}

输出结果

pow( 2 , 4 ) = 16

平方根

C ++中的sqrt函数返回参数列表内双精度整数的平方根。该方法接受双精度整数值作为输入查找平方根,并返回双精度整数作为输出。

双sqrt(双)

调用语法

double x = sqrt(25.00)

#include <iostream>
#include <math.h>
using namespace std;
int main(){
   double a =25 ;
   cout << "sqrt( "<<a<<" ) = " << sqrt(a) << endl;
}

输出结果

sqrt( 25 ) = 5.00

日志记录

锁定功能用于查找给定数字的自然对数。此方法接受单个双整数值,找到对数值,并返回log()的双整数结果。

双对数(双)

调用语法

double x = log(1.35)

#include <iostream>
#include <math.h>
using namespace std;
int main(){
   double a =1.35 ;
   cout << "sqrt( "<<a<<" ) = " << sqrt(a) << endl;
}

输出结果

sqrt( 1.35 ) = 0.300105

地板

下限函数用于返回给定双整数的下限值。底值是指四舍五入的值。该函数接受一个double值作为输入,并返回使用floor()计算得出的double整数值。

双人房

调用语法

double x = floor(5.24)

#include <iostream>
#include <math.h>
using namespace std;
int main(){
   double a =6.24 ;
   cout << "floor( "<<a<<" ) = " << floor(a) << endl;
}

输出结果

floor( 6.24 ) = 6

细胞

ceil函数用于返回给定双精度整数的ceil值。ceil值表示四舍五入值。该函数接受一个double值作为输入,并返回使用ceil()计算得出的double整数值。

双层天花板

调用语法

double x = ceil(5.24)

#include <iostream>
#include <math.h>
using namespace std;
int main(){
   double a =6.64 ;
   cout << "ceil( "<<a<<" ) = " << ceil(a) << endl;
}

输出结果

ceil( 6.64 ) = 7

腹肌

abs函数返回整数值的绝对值。该函数接受一个整数值,并返回一个具有相同大小但正号的整数值。

双ABS(双)

调用语法

double x = abs(-512)

#include <iostream>
#include <math.h>
using namespace std;
int main(){
   int a = -345 ;
   cout << "abs( "<<a<<" ) = " << abs(a) << endl;
}

输出结果

abs( -345 ) = 345