该函数计算以弧度表示的数字的反正切。
假设数字是“ x”。语法为:
float atan(float x); double atan(double x); long double atan(long double x); double atan(integral x);
x :要计算其反切线的值。
它返回范围为[-∏/2,∏/2]的值。
让我们看一个简单的例子,当x的值为零时。
#include <iostream> #include<math.h> using namespace std; int main() { float degree=0; float x=degree*3.14/180; std::cout << "Value of tangent is :" <<tan(x)<< std::endl; cout<<"Inverse of tangent is :"<<atan(x); return 0; }
输出:
Value of tangent is :0 Inverse of tangent is :0
在此示例中,当x的值等于零时,atan()函数计算数字的反正切。
链接:https://www.learnfk.comhttps://www.learnfk.com/c++/cpp-math-atan-function.html
来源:LearnFk无涯教程网
让我们看一个简单的例子,当x的值为负数时。
#include <iostream> #include<math.h> using namespace std; int main() { float degree= -67; float x=degree*3.14/180; std::cout << "Value of tangent is : " <<tan(x)<< std::endl; cout<<"Inverse of tangent is : "<<atan(x); return 0; }
输出:
Value of tangent is : -2.35197 Inverse of tangent is : -0.863063
在此示例中,当x的值为负时,atan()函数计算数字的反正切。
让我们看一个简单的例子,当x的值为正时。
#include <iostream> #include<math.h> using namespace std; int main() { float degree=30; float x=degree*3.14/180; std::cout << "Value of tangent is : " <<tan(x)<< std::endl; cout<<"Inverse of tangent is : "<<atan(x); return 0; }
输出:
Value of tangent is : 0.576996 Inverse of tangent is : 0.48214
在此示例中,当x的值为正时,atan()函数计算数字的反正切。
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)
Spring Cloud 微服务项目实战 -〔姚秋辰(姚半仙)〕