Hàm atan() cho số phức tính arc tangent (tan nghịch đảo) của số phức. Định nghĩa trong header <complex>.
Code ví dụ
#include <iostream>
#include <complex>
using namespace std;
int main() {
complex<double> c1(5, 2); // 5 + 2i
cout << "atan(" << c1 << ") = " << atan(c1) << endl;
return 0;
}
Kết quả
atan((5,2)) = (1.39928,0.067066)
Giải thích
Kết quả là số phức: phần thực ≈ 1.39928, phần ảo ≈ 0.067066 (radian).
Các hàm lượng giác nghịch đảo cho số phức
| Hàm | Ý nghĩa | Header |
|---|---|---|
| asin(z) | Arc sine | <complex> |
| acos(z) | Arc cosine | <complex> |
| atan(z) | Arc tangent | <complex> |
| asinh(z) | Arc hyperbolic sine | <complex> |
| acosh(z) | Arc hyperbolic cosine | <complex> |
| atanh(z) | Arc hyperbolic tangent | <complex> |
Ví dụ mở rộng
#include <iostream>
#include <complex>
#include <iomanip>
using namespace std;
int main() {
complex<double> z(1, 1); // 1 + i
cout << fixed << setprecision(6);
cout << "z = " << z << endl;
cout << "asin(z) = " << asin(z) << endl;
cout << "acos(z) = " << acos(z) << endl;
cout << "atan(z) = " << atan(z) << endl;
cout << "asinh(z) = " << asinh(z) << endl;
cout << "acosh(z) = " << acosh(z) << endl;
cout << "atanh(z) = " << atanh(z) << endl;
return 0;
}