asinh(x) หรือ Inverse Hyperbolic Sine (Arc Hyperbolic Sine) คืนค่า y ที่ทำให้ sinh(y) = x
คุณสมบัติทางคณิตศาสตร์
- Domain: ทุกจำนวนจริง (-∞, +∞)
- Range: ทุกจำนวนจริง (-∞, +∞)
- Function: Odd Function:
asinh(-x) = -asinh(x) - สูตร: asinh(x) = ln(x + √(x² + 1))
- Derivative: d/dx asinh(x) = 1/√(x² + 1)
Syntax
#include <cmath>
double asinh(double x);
float asinhf(float x);
long double asinhl(long double x);
โค้ดตัวอย่างพื้นฐาน
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double values[] = {-10, -5, -1, 0, 1, 5, 10};
cout << "x\t\tasinh(x) (rad)\tasinh(x) (deg)" << endl;
cout << "------------------------------------------" << endl;
for (double x : values) {
double rad = asinh(x);
double deg = rad * 180 / M_PI;
cout << x << "\t\t" << rad << "\t\t" << deg << endl;
}
return 0;
}
ผลลัพธ์
x asinh(x) (rad) asinh(x) (deg) ------------------------------------------ -10 -2.99822 -171.79 -5 -2.31244 -132.49 -1 -0.881374 -50.49 0 0 0 1 0.881374 50.49 5 2.31244 132.49 10 2.99822 171.79
พฤติกรรมเมื่อ x ใหญ่ (Asymptotic)
asinh(x) ≈ ln(2|x|) สำหรับ |x| >> 1 x = 1000: asinh(1000) ≈ ln(2000) ≈ 7.6 x = 1e6: asinh(1e6) ≈ ln(2e6) ≈ 14.5
การประยุกต์ใช้
1. การแปลงพิกัด (Coordinate Transformation)
// Map ระยะทางไปเป็นมุม (ใช้ในบาง Projection)
double distanceToAngle(double d) {
return asinh(d / scale); // Compress large distances
}
2. Signal Processing
// Soft Clipping / Compression
double compress(double x, double threshold = 1.0) {
return threshold * asinh(x / threshold);
}
// คล้าย Tanh แต่ไม่ Saturate ที่ ±1
3. Physics / Relativity
// Rapidity ใน Special Relativity
// v = c * tanh(rapidity) → rapidity = atanh(v/c)
// แต่ asinh ใช้ในการคำนวณ Energy-Momentum
double rapidityFromMomentum(double p, double m, double c = 1.0) {
return asinh(p / (m * c));
}
4. Machine Learning: Activation Function
// asinh ใช้เป็น Activation Function บางครั้ง
// เนื่องจาก Derivative = 1/√(x²+1) ไม่มี Vanishing Gradient ปัญหา
double asinhActivation(double x) {
return asinh(x);
}
double asinhDerivative(double x) {
return 1.0 / sqrt(x * x + 1.0);
}
ฟังก์ชัน Hyperbolic ใน C++ ทั้งหมด
| Function | Name | Domain | Range | Inverse |
|---|---|---|---|---|
| sinh(x) | Hyperbolic Sine | ℝ | ℝ | asinh(x) |
| cosh(x) | Hyperbolic Cosine | ℝ | [1, ∞) | acosh(x) (x≥1) |
| tanh(x) | Hyperbolic Tangent | ℝ | (-1, 1) | atanh(x) (|x|<1) |
| asinh(x) | Inverse Hyperbolic Sine | ℝ | ℝ | sinh(x) |
| acosh(x) | Inverse Hyperbolic Cosine | [1, ∞) | [0, ∞) | cosh(x) |
| atanh(x) | Inverse Hyperbolic Tangent | (-1, 1) | ℝ | tanh(x) |
ความสัมพันธ์กับ Logarithm
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double x = 5.0;
// Definition: asinh(x) = ln(x + √(x² + 1))
double byAsinh = asinh(x);
double byLog = log(x + sqrt(x*x + 1));
cout << "asinh(" << x << ") = " << byAsinh << endl;
cout << "ln(x + √(x²+1)) = " << byLog << endl;
cout << "Difference: " << abs(byAsinh - byLog) << endl;
return 0;
}
ผลลัพธ์
asinh(5) = 2.31244 ln(x + √(x²+1)) = 2.31244 Difference: 4.44e-16
Precision และ Special Values
asinh(±0)= ±0 (Signed Zero Preserved)asinh(±∞)= ±∞asinh(NaN)= NaN- No Domain Error (Domain = ℝ)
- No Range Error
Complex Version (C++11)
#include <complex>
#include <iostream>
using namespace std;
int main() {
complex<double> z(3, 4); // 3 + 4i
complex<double> result = asinh(z);
cout << "asinh(3+4i) = " << result << endl; // (2.29991, 0.917617)
return 0;
}