📄 module1.bas
字号:
Attribute VB_Name = "Module1"
Option Explicit
Public Const PI = 3.14159265358979
'Exponential Function base of e
Public Function e(ByVal x As Double) As Double
e = Exp(x)
End Function
'自然对数 (natural logarithms)以 e 为底
Public Function ln(ByVal x As Double) As Double
ln = Log(x)
End Function
'以 10 为底的对数 (common logarithms)
Public Function log10(ByVal x As Double) As Double
log10 = Log(x) / Log(10)
End Function
'以 n 为底的对数
Public Function logn(ByVal x As Double, ByVal n As Double) As Double
logn = Log(x) / Log(n)
End Function
'反正弦 (Inverse Sine)
Public Function asin(ByVal x As Double) As Double
If x = 1 Or x = -1 Then
asin = Sgn(x) * PI / 2
Else
asin = Atn(x / Sqr(-x * x + 1))
End If
End Function
'超正弦 (Hyperbolic Sine)
Public Function sinh(ByVal x As Double) As Double
sinh = (Exp(x) - Exp(-x)) / 2
End Function
'反超正弦 (Inverse Hyperbolic Sine)
Public Function asinh(ByVal x As Double) As Double
asinh = Log(x + Sqr(x * x + 1))
End Function
'反余弦 (Inverse Cosine)
Public Function acos(ByVal x As Double) As Double
If x = 1 Then
acos = 0
ElseIf x = -1 Then
acos = PI
Else
acos = Atn(-x / Sqr(-x * x + 1)) + 2 * Atn(1)
End If
End Function
'超余弦 (Hyperbolic Cosine)
Public Function cosh(ByVal x As Double) As Double
cosh = (Exp(x) + Exp(-x)) / 2
End Function
'反超余弦 (Inverse Hyperbolic Cosine)
Public Function acosh(ByVal x As Double) As Double
acosh = Log(x + Sqr(x * x - 1))
End Function
'反正切 (Inverse Tangent)
Public Function atan(ByVal x As Double) As Double
atan = Atn(x)
End Function
'超正切 (Hyperbolic Tangent)
Public Function tanh(ByVal x As Double) As Double
tanh = (Exp(x) - Exp(-x)) / (Exp(x) + Exp(-x))
End Function
'反超正切 (Inverse Hyperbolic Tangent)
Public Function atanh(ByVal x As Double) As Double
atanh = Log((1 + x) / (1 - x)) / 2
End Function
'余切 (Cotangent)
Public Function cot(ByVal x As Double) As Double
cot = 1 / Tan(x)
End Function
'反余切 (Inverse Cotangent)
Public Function acot(ByVal x As Double) As Double
acot = Atn(1 / x)
End Function
'超余切 (Hyperbolic Cotangent)
Public Function coth(ByVal x As Double) As Double
coth = (Exp(x) + Exp(-x)) / (Exp(x) - Exp(-x))
End Function
'反超余切 (Inverse Hyperbolic Cotangent)
Public Function acoth(ByVal x As Double) As Double
acoth = Log((x + 1) / (x - 1)) / 2
End Function
'正割 (Secant)
Public Function sec(ByVal x As Double) As Double
sec = 1 / Cos(x)
End Function
'反正割 (Inverse Secant)
Public Function asec(ByVal x As Double) As Double
asec = acos(1 / x)
End Function
'超正割 (Hyperbolic Secant)
Public Function sech(ByVal x As Double) As Double
sech = 2 / (Exp(x) + Exp(-x))
End Function
'反超正割 (Inverse Hyperbolic Secant)
Public Function asech(ByVal x As Double) As Double
asech = Log((Sqr(-x * x + 1) + 1) / x)
End Function
'余割 (Cosecant)
Public Function csc(ByVal x As Double) As Double
csc = 1 / Sin(x)
End Function
'反余割 (Inverse Cosecant)
Public Function acsc(ByVal x As Double) As Double
acsc = asin(1 / x)
End Function
'超余割 (Hyperbolic Cosecant)
Public Function csch(ByVal x As Double) As Double
csch = 2 / (Exp(x) - Exp(-x))
End Function
'反超余割 (Inverse Hyperbolic Cosecant)
Public Function acsch(ByVal x As Double) As Double
acsch = Log((Sgn(x) * Sqr(x * x + 1) + 1) / x)
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -