ฟังก์ชัน atanh() ส่งคืนค่า arctangent ไฮเปอร์โบลิก (arc hyperbolic tangent) หรือ inverse hyperbolic tangent ของมุมที่กำหนดเป็นเรเดียน เป็นฟังก์ชันในตัว (inbuilt) ของ C++ STL
ไวยากรณ์ของฟังก์ชัน atanh() มีดังนี้:
atanh(var)
จากไวยากรณ์ ฟังก์ชัน atanh() รับพารามิเตอร์ var ที่มีชนิดข้อมูล float, double หรือ long double ค่าของพารามิเตอร์นี้ควรอยู่ระหว่าง -1 ถึง 1 ฟังก์ชันจะส่งคืน arctangent ไฮเปอร์โบลิกของ var
โปรแกรมที่สาธิตการใช้งาน atanh() ใน C++ มีดังนี้:
ตัวอย่าง
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double d = 0.5, ans;
ans = atanh(d);
cout << "atanh("<< d <<") = " << ans << endl;
return 0;
}ผลลัพธ์
atanh(0.5) = 0.549306
ในโปรแกรมนี้ เริ่มต้นด้วยการกำหนดค่าตัวแปร d จากนั้นหา arctangent ไฮเปอร์โบลิกของ d โดยใช้ atanh() และเก็บใน ans สุดท้ายแสดงค่าของ ans โค้ดส่วนนี้มีดังนี้:
double d = 0.5, ans;
ans = atanh(d);
cout << "atanh("<< d <<") = " << ans << endl;ผลลัพธ์ที่ได้จากฟังก์ชัน atanh() สามารถแปลงเป็นองศาและแสดงได้ โปรแกรมสาธิตมีดังนี้:
ตัวอย่าง
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double d = 0.5, ans;
ans = atanh(d);
ans = ans*180/3.14159;
cout << "atanh("<<d <<") = " << ans << endl;
return 0;
}ผลลัพธ์
atanh(0.5) = 31.473
ในโปรแกรมนี้ ได้รับ arctangent ไฮเปอร์โบลิกโดยใช้ atanh() จากนั้นแปลงค่าเป็นองศา สุดท้ายแสดงผลลัพธ์ โค้ดส่วนนี้มีดังนี้:
double d = 0.5, ans;
ans = atanh(d);
ans = ans*180/3.14159;
cout << "atanh("<< d <<") = " << ans << endl;