Important Math functions in Visual Basic

Visual Basic Topics
Post Reply
Cyclops
Lieutenant
Lieutenant
Posts: 71
Joined: Wed Jul 15, 2009 1:48 pm
Location: London

Important Math functions in Visual Basic

Post by Cyclops » Mon Oct 05, 2009 1:53 pm

Secant

Code: Select all

Public Function Sec(X As Double) As Double
   Sec = 1 / Cos(X)
End Function
Cosecant

Code: Select all

Public Function CoSec(X As Double) As Double
   CoSec = 1 / Sin(X)
End Function
Cotangent

Code: Select all

Public Function CoTan(X As Double) As Double
   CoTan = 1 / Tan(X)
End Function
Inverse Sine

Code: Select all

Public Function ArcSin(X As Double) As Double
   ArcSin = Atn(X / Sqr(-X * X + 1))
End Function
Inverse Cosine

Code: Select all

Public Function ArcCos(X As Double) As Double
   ArcCos = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
End Function
Inverse Secant

Code: Select all

Public Function ArcSec(X As Double) As Double
   ArcSec = Atn(X / Sqr(X * X - 1)) + Sgn(X - 1) * (2 * Atn(1))
End Function
Inverse Cosecant

Code: Select all

Public Function ArcCoSec(X As Double) As Double
   ArcCoSec = Atn(X / Sqr(X * X - 1)) + (Sgn(X) - 1) * (2 * Atn(1))
End Function
Inverse Cotangent

Code: Select all

Public Function ArcCoTan(X As Double) As Double
   ArcCoTan = Atn(X) + 2 * Atn(1)
End Function
Hyperbolic Sine

Code: Select all

Public Function HSin(X As Double) As Double
   HSin = (Exp(X) - Exp(-X)) / 2
End Function
Hyperbolic Cosine

Code: Select all

Public Function HCos(X As Double) As Double
   HCos = (Exp(X) + Exp(-X)) / 2
End Function
Hyperbolic Tangent

Code: Select all

Function HTan(X As Double) As Double
   HTan = (Exp(X) - Exp(-X)) / (Exp(X) + Exp(-X))
End Function
Hyperbolic Secant

Code: Select all

Public Function HSec(X As Double) As Double
   HSec = 2 / (Exp(X) + Exp(-X))
End Function
Hyperbolic Cosecant

Code: Select all

Public Function HCoSec(X As Double) As Double
   HCoSec = 2 / (Exp(X) - Exp(-X))
End Function
Hyperbolic Cotangent

Code: Select all

Public Function HCotan(X As Double) As Double
   HCotan = (Exp(X) + Exp(-X)) / (Exp(X) - Exp(-X))
End Function
Inverse Hyperbolic Sine

Code: Select all

Public Function HArcSin(X As Double) As Double
   HArcSin = Log(X + Sqr(X * X + 1))
End Function
Inverse Hyperbolic Cosine

Code: Select all

Public Function HArcCos(X As Double) As Double
   HArcCos = Log(X + Sqr(X * X - 1))
End Function
Inverse Hyperbolic Tangent

Code: Select all

Function HArcTan(X As Double) As Double
   HArcTan = Log((1 + X) / (1 - X)) / 2
End Function
Inverse Hyperbolic Secant

Code: Select all

Public Function HArcSec(X As Double) As Double
   HArcSec = Log((Sqr(-X * X + 1) + 1) / X)
End Function
Inverse Hyperbolic Cosecant

Code: Select all

Public Function HArcCoSec(X As Double) As Double
   HArcCoSec = Log((Sgn(X) * Sqr(X * X + 1) + 1) / X)
End Function
Inverse Hyperbolic Cotangent

Code: Select all

Public Function HArcCoTan(X As Double) As Double
   HArcCoTan = Log((X + 1) / (X - 1)) / 2
End Function
Logarithm to base N

Code: Select all

Public Function LogN(X As Double, n As Double) As Double
   LogN = Log(X) / Log(n)
End Function
Post Reply

Return to “Visual Basic Programming”