該函數計算以弧度給出的數字的反正切。
atan(x) = tan-1x
用法
假設一個數字是 '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
在本例中,atan() 函數計算當 x 的值等於 0 時數字的反正切。
例子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
在此示例中,atan() 函數計算 x 值為負時數字的反正切。
例子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() 函數計算一個數的反正切。
相關用法
- C++ Math atan2()用法及代碼示例
- C++ Math atanh()用法及代碼示例
- C++ Math acosh()用法及代碼示例
- C++ Math asinh()用法及代碼示例
- C++ Math asin()用法及代碼示例
- C++ Math abs()用法及代碼示例
- C++ Math acos()用法及代碼示例
- C++ Math scalbn()用法及代碼示例
- C++ Math isgreater()用法及代碼示例
- C++ Math fabs()用法及代碼示例
- C++ Math islessgreater()用法及代碼示例
- C++ Math log2()用法及代碼示例
- C++ Math nearbyint()用法及代碼示例
- C++ Math tan()用法及代碼示例
- C++ Math log()用法及代碼示例
- C++ Math nextafter()用法及代碼示例
- C++ Math fdim()用法及代碼示例
- C++ Math isfinite()用法及代碼示例
- C++ Math erfc()用法及代碼示例
- C++ Math sinh()用法及代碼示例
注:本文由純淨天空篩選整理自 C++ Math atan()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。