atan(x)函数详解

首页 / C++入门教程 / atan(x)函数详解

该函数计算以弧度表示的数字的反正切。

atan(x) = tan-1x

atan - 语法

假设数字是“ x”。语法为:

无涯教程网

float atan(float x);
double atan(double x);
long double atan(long double x);
double atan(integral x);

Note: 如果传递的值是整数类型,则将其强制转换为double。

atan - 参数

x :要计算其反切线的值。

atan - 返回值

它返回范围为[-∏/2,∏/2]的值。

atan - 例子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()函数计算数字的反正切。

链接:https://www.learnfk.comhttps://www.learnfk.com/c++/cpp-math-atan-function.html

来源:LearnFk无涯教程网

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()函数计算数字的反正切。

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()函数计算数字的反正切。

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

深入浅出gRPC -〔李林锋〕

JavaScript核心原理解析 -〔周爱民〕

跟月影学可视化 -〔月影〕

重学线性代数 -〔朱维刚〕

基于人因的用户体验设计课 -〔刘石〕

说透数字化转型 -〔付晓岩〕

攻克视频技术 -〔李江〕

Spring Cloud 微服务项目实战 -〔姚秋辰(姚半仙)〕

中间件核心技术与实战 -〔丁威〕

好记忆不如烂笔头。留下您的足迹吧 :)