vb System.Math.Tanh类(方法)实例源码

下面列出了vb System.Math.Tanh 类(方法)源码代码实例,从而了解它的用法。

作者:VB.NET开发    项目:Syste   
' Example for the hyperbolic Math.Tanh( Double ) method.
Module DemoTanh
   
    Sub Main()
        Console.WriteLine( _
            "This example of hyperbolic Math.Tanh( Double )" & _
            vbCrLf & "generates the following output.")
        Console.WriteLine( _
            vbCrLf & "Evaluate these hyperbolic " & _
            "identities with selected values for X:")
        Console.WriteLine("   tanh(X) = sinh(X) / cosh(X)")
        Console.WriteLine("   tanh(2 * X) = 2 * tanh(X) / (1 + tanh^2(X))")
          
        UseTanh(0.1)
        UseTanh(1.2)
        UseTanh(4.9)
          
        Console.WriteLine( _
            vbCrLf & "Evaluate [tanh(X + Y) == (tanh(X) + " & _
            "tanh(Y)) / (1 + tanh(X) * tanh(Y))]" & _
            vbCrLf & "with selected values for X and Y:")

        UseTwoArgs(0.1, 1.2)
        UseTwoArgs(1.2, 4.9)
    End Sub
       
    ' Evaluate hyperbolic identities with a given argument.
    Sub UseTanh(arg As Double)
        Dim tanhArg As Double = Math.Tanh(arg)
          
        ' Evaluate tanh(X) = sinh(X) / cosh(X).
        Console.WriteLine( _
            vbCrLf & "                       Math.Tanh({0}) = {1:E16}" & _
            vbCrLf & "      Math.Sinh({0}) / Math.Cosh({0}) = {2:E16}", _
            arg, tanhArg, Math.Sinh(arg) / Math.Cosh(arg))
          
        ' Evaluate tanh(2 * X) = 2 * tanh(X) / (1 + tanh^2(X)).
        Console.WriteLine( _
            "                   2 * Math.Tanh({0}) /", _
            arg, 2.0 * tanhArg)
        Console.WriteLine( _
            "             (1 + (Math.Tanh({0}))^2) = {1:E16}", _
            arg, 2.0 * tanhArg /(1.0 + tanhArg * tanhArg))
        Console.WriteLine( _
            "                       Math.Tanh({0}) = {1:E16}", _
            2.0 * arg, Math.Tanh((2.0 * arg)))
    End Sub
       
    ' Evaluate a hyperbolic identity that is a function of two arguments.
    Sub UseTwoArgs(argX As Double, argY As Double)

        ' Evaluate tanh(X + Y) = (tanh(X) + tanh(Y)) / (1 + tanh(X) * tanh(Y)).
        Console.WriteLine( _
            vbCrLf & "    (Math.Tanh({0}) + Math.Tanh({1})) /" & _
            vbCrLf & "(1 + Math.Tanh({0}) * Math.Tanh({1})) = {2:E16}", _
            argX, argY, (Math.Tanh(argX) + Math.Tanh(argY)) / _
            (1.0 + Math.Tanh(argX) * Math.Tanh(argY)))
        Console.WriteLine( _
            "                       Math.Tanh({0}) = {1:E16}", _
            argX + argY, Math.Tanh(argX + argY))

    End Sub
End Module 'DemoTanh

' This example of hyperbolic Math.Tanh( Double )


问题


面经


文章

微信
公众号

扫码关注公众号