Log Function


Log Function

Class

System.Math

Syntax

     Dim result As Double = Math.Log  (d) 

or:

     Dim result As Double = Math.Log(a, newBase) 


d, a (required; Double)

A numeric expression greater than zero


newBase (required; Double)

The base of the logarithm

Description

The Log function returns the natural (base e) logarithm of a given number (the first syntax), or the logarithm of a given number in a specified base (the second syntax).

Usage at a Glance

  • The Log function is the inverse of the Exp function.

  • This is a shared member of the System.Math class, so it can be used without an instance.

  • You can calculate base-n logarithms for any number, x, by dividing the natural logarithm of x by the natural logarithm of n:

         Logn(x) = Log(x) / Log(n) 

    For example, you can replicate the Log10 function using this method:

         Static Function Log10(ByVal x As Double) As Double        Return Log(x) / Log(10#)     End Function 

  • The inverse trigonometric functions, which are not intrinsic to VB, can be computed using the value returned by the Log function. The functions and their formulas are:


    Inverse hyperbolic sine

    HArcsin(x) = Log(x + Sqrt(x * (x + 1)))


    Inverse hyperbolic cosine

    HArccos(x) = Log(x + Sqrt(x * (x - 1)))


    Inverse hyperbolic tangent

    HArctan(x) = Log((1 + x) / (1 - x)) / 2


    Inverse hyperbolic secant

    HArcsec(x) = Log((Sqrt(-x * (x + 1)) + 1) / x)


    Inverse hyperbolic cosecant

    HArccosec(x) = Log((Sign(x) * _

         Sqrt(x * x + 1) + 1) / x) 


    Inverse hyperbolic cotangent

    HArccotan(x) = Log((x + 1) / (x - 1)) / 2

See Also

Exp Function, Log10 Function




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net