三角関数と類似の関数。

双曲線正弦(ハイパーボリックサイン)、双曲線余弦(ハイパーボリックコサイン)、双曲線正接(ハイパーボリックタンジェント)を総称して双曲線関数と呼ぶ。

実際の定義式は指数関数を用いて定義されているが、定義式通り計算すると0近傍で桁落ちが生じる。そのため0近傍のsinh(x)、tanh(x)では級数展開を用いて計算する。

#N88BASIC

Const EPS5 = 0.001' DBL_EPSILON の 1/5 乗程度

Function my_sinh(x As Double) As Double' sinh(x)
Dim t As Double

If Abs(x) > EPS5 Then
t = Exp(x)
my_sinh = (t - 1 / t) / 2
Else
my_sinh = x * (1 + x * x / 6)
End If
End Function

Function my_cosh(x As Double) As Double' cosh(x)
Dim t As Double

t = Exp(x)
my_cosh = (t + 1 / t) / 2
End Function

Function my_tanh(x As Double) As Double' tanh(x)
If x > EPS5 Then
my_tanh = 2 / (1 + Exp(-2 * x)) - 1
ElseIf x < -EPS5 Then
my_tanh = 1 - 2 / (Exp(2 * x) + 1)
Else
my_tanh = x * (1 - x * x / 3)
End If
End Function

Function arcsinh(x AS Double) As Double' sinh-1(x)
If x > EPS5 Then
arcsinh = Log(Sqr(x * x + 1) + x)
ElseIf x < -EPS5 Then
arcsinh = -Log(Sqr(x * x + 1) - x)
Else
arcsinh = x * (1 - x * x / 6)
End If
End Function

Function arccosh(x As Double) As Double'cosh-1(x)
arccosh = Log(x + Sqr(x * x - 1))
End Function

Function arctanh(x As Double) As Double' tanh-1(x)
If Abs(x) > EPS5 Then
arctanh = 0.5 * Log((1 + x) / (1 - x))
Else
arctanh = x * (1 + x * x / 3.0)
End If
End Function

'
Dim i As Integer
Dim x As Double
Print "双曲線関数とその逆の整合性"
For i = -10 To 10
Print i, arcsinh(my_sinh(i)) - i, arccosh(my_cosh(i)) - Abs(i), arctanh(my_tanh(i)) - i
Next i
For i = -10 To 10
x = 0.0002 * i
Print x, arcsinh(my_sinh(x)) - x, arccosh(my_cosh(x)) - Abs(x), arctanh(my_tanh(x)) - x
Next i

タグ:

+ タグ編集
  • タグ:

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

最終更新:2010年01月25日 19:07