C++ Math atan()
 
 
 C++ Math atan()
 
 该函数计算以弧度表示的数字的反正切值。
 
 
语法
 
 假设数字为" x"。语法为: 
 
 
 
  float atan(float x);
double atan(double x);
long double atan(long double x);
double atan(integral x);
 
   
  
 
 注意: 如果传递的值是整数类型,则将其强制转换为double。 
 
参数
 
  x : 要计算其反切线的值。
 
返回值
 
 它返回范围为[-∏/2,∏/2]的值。
 
示例1 
 
 让我们看一个简单的示例,当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()函数计算数字的反正切。
 
示例2 
 
 让我们看一个简单的示例,当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()函数计算数字的反正切。
 
示例3 
 
 让我们看看一个简单的示例,当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()函数计算数字的反正切值。