Math.Cosh Method
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Returns the hyperbolic cosine of the specified angle.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
<SecuritySafeCriticalAttribute> _
Public Shared Function Cosh ( _
value As Double _
) As Double
[SecuritySafeCriticalAttribute]
public static double Cosh(
double value
)
Parameters
- value
Type: System.Double
An angle, measured in radians.
Return Value
Type: System.Double
The hyperbolic cosine of value. If value is equal to NegativeInfinity or PositiveInfinity, PositiveInfinity is returned. If value is equal to NaN, NaN is returned.
Remarks
The angle, value, must be in radians. Multiply by Math.PI/180 to convert degrees to radians.
Examples
The following example uses Cosh to evaluate certain hyperbolic identities for selected values.
' Example for the hyperbolic Math.Sinh( Double ) and Math.Cosh( Double ) methods.
Module Example
Public Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
outputBlock.Text &= _
"This example of hyperbolic " & _
"Math.Sinh( Double ) and Math.Cosh( Double )" & vbCrLf & _
"generates the following output." & vbCrLf & vbCrLf
outputBlock.Text &= _
"Evaluate these hyperbolic identities " & _
"with selected values for X:" & vbCrLf
outputBlock.Text &= _
" cosh^2(X) - sinh^2(X) = 1" & vbCrLf & _
" sinh(2 * X) = 2 * sinh(X) * cosh(X)" & vbCrLf
outputBlock.Text &= " cosh(2 * X) = cosh^2(X) + sinh^2(X)" & vbCrLf
UseExample(outputBlock, 0.1)
UseExample(outputBlock, 1.2)
UseExample(outputBlock, 4.9)
outputBlock.Text &= _
vbCrLf & "Evaluate these hyperbolic " & _
"identities with selected values for X and Y:" & vbCrLf
outputBlock.Text &= _
" sinh(X + Y) = sinh(X) * cosh(Y) + cosh(X) * sinh(Y)" & vbCrLf
outputBlock.Text &= _
" cosh(X + Y) = cosh(X) * cosh(Y) + sinh(X) * sinh(Y)" & vbCrLf
UseTwoArgs(outputBlock, 0.1, 1.2)
UseTwoArgs(outputBlock, 1.2, 4.9)
End Sub 'Main
' Evaluate hyperbolic identities with a given argument.
Sub UseExample(ByVal outputBlock As System.Windows.Controls.TextBlock, ByVal arg As Double)
Dim sinhArg As Double = Math.Sinh(arg)
Dim coshArg As Double = Math.Cosh(arg)
' Evaluate cosh^2(X) - sinh^2(X) = 1.
outputBlock.Text &= String.Format( _
vbCrLf & " Math.Sinh({0}) = {1:E16}" + _
vbCrLf & " Math.Cosh({0}) = {2:E16}", _
arg, Math.Sinh(arg), Math.Cosh(arg)) & vbCrLf
outputBlock.Text &= String.Format( _
"(Math.Cosh({0}))^2 - (Math.Sinh({0}))^2 = {1:E16}", _
arg, coshArg * coshArg - sinhArg * sinhArg) & vbCrLf
' Evaluate sinh(2 * X) = 2 * sinh(X) * cosh(X).
outputBlock.Text &= String.Format( _
" Math.Sinh({0}) = {1:E16}", _
2.0 * arg, Math.Sinh((2.0 * arg))) & vbCrLf
outputBlock.Text &= String.Format( _
" 2 * Math.Sinh({0}) * Math.Cosh({0}) = {1:E16}", _
arg, 2.0 * sinhArg * coshArg) & vbCrLf
' Evaluate cosh(2 * X) = cosh^2(X) + sinh^2(X).
outputBlock.Text &= String.Format( _
" Math.Cosh({0}) = {1:E16}", _
2.0 * arg, Math.Cosh((2.0 * arg))) & vbCrLf
outputBlock.Text &= String.Format( _
"(Math.Cosh({0}))^2 + (Math.Sinh({0}))^2 = {1:E16}", _
arg, coshArg * coshArg + sinhArg * sinhArg) & vbCrLf
End Sub 'UseExample
' Evaluate hyperbolic identities that are functions of two arguments.
Sub UseTwoArgs(ByVal outputBlock As System.Windows.Controls.TextBlock, ByVal argX As Double, ByVal argY As Double)
' Evaluate sinh(X + Y) = sinh(X) * cosh(Y) + cosh(X) * sinh(Y).
outputBlock.Text &= String.Format( _
vbCrLf & " Math.Sinh({0}) * Math.Cosh({1}) +" + _
vbCrLf & " Math.Cosh({0}) * Math.Sinh({1}) = {2:E16}", _
argX, argY, Math.Sinh(argX) * Math.Cosh(argY) + _
Math.Cosh(argX) * Math.Sinh(argY)) & vbCrLf
outputBlock.Text &= String.Format( _
" Math.Sinh({0}) = {1:E16}", _
argX + argY, Math.Sinh((argX + argY))) & vbCrLf
' Evaluate cosh(X + Y) = cosh(X) * cosh(Y) + sinh(X) * sinh(Y).
outputBlock.Text &= String.Format( _
" Math.Cosh({0}) * Math.Cosh({1}) +" + _
vbCrLf & " Math.Sinh({0}) * Math.Sinh({1}) = {2:E16}", _
argX, argY, Math.Cosh(argX) * Math.Cosh(argY) + _
Math.Sinh(argX) * Math.Sinh(argY)) & vbCrLf
outputBlock.Text &= String.Format( _
" Math.Cosh({0}) = {1:E16}", _
argX + argY, Math.Cosh((argX + argY))) & vbCrLf
End Sub 'UseTwoArgs
End Module 'SinhCosh
' This example of hyperbolic Math.Sinh( Double ) and Math.Cosh( Double )
' generates the following output.
'
' Evaluate these hyperbolic identities with selected values for X:
' cosh^2(X) - sinh^2(X) = 1
' sinh(2 * X) = 2 * sinh(X) * cosh(X)
' cosh(2 * X) = cosh^2(X) + sinh^2(X)
'
' Math.Sinh(0.1) = 1.0016675001984403E-001
' Math.Cosh(0.1) = 1.0050041680558035E+000
' (Math.Cosh(0.1))^2 - (Math.Sinh(0.1))^2 = 9.9999999999999989E-001
' Math.Sinh(0.2) = 2.0133600254109399E-001
' 2 * Math.Sinh(0.1) * Math.Cosh(0.1) = 2.0133600254109396E-001
' Math.Cosh(0.2) = 1.0200667556190759E+000
' (Math.Cosh(0.1))^2 + (Math.Sinh(0.1))^2 = 1.0200667556190757E+000
'
' Math.Sinh(1.2) = 1.5094613554121725E+000
' Math.Cosh(1.2) = 1.8106555673243747E+000
' (Math.Cosh(1.2))^2 - (Math.Sinh(1.2))^2 = 1.0000000000000000E+000
' Math.Sinh(2.4) = 5.4662292136760939E+000
' 2 * Math.Sinh(1.2) * Math.Cosh(1.2) = 5.4662292136760939E+000
' Math.Cosh(2.4) = 5.5569471669655064E+000
' (Math.Cosh(1.2))^2 + (Math.Sinh(1.2))^2 = 5.5569471669655064E+000
'
' Math.Sinh(4.9) = 6.7141166550932297E+001
' Math.Cosh(4.9) = 6.7148613134003227E+001
' (Math.Cosh(4.9))^2 - (Math.Sinh(4.9))^2 = 1.0000000000000000E+000
' Math.Sinh(9.8) = 9.0168724361884615E+003
' 2 * Math.Sinh(4.9) * Math.Cosh(4.9) = 9.0168724361884615E+003
' Math.Cosh(9.8) = 9.0168724916400624E+003
' (Math.Cosh(4.9))^2 + (Math.Sinh(4.9))^2 = 9.0168724916400606E+003
'
' Evaluate these hyperbolic identities with selected values for X and Y:
' sinh(X + Y) = sinh(X) * cosh(Y) + cosh(X) * sinh(Y)
' cosh(X + Y) = cosh(X) * cosh(Y) + sinh(X) * sinh(Y)
'
' Math.Sinh(0.1) * Math.Cosh(1.2) +
' Math.Cosh(0.1) * Math.Sinh(1.2) = 1.6983824372926155E+000
' Math.Sinh(1.3) = 1.6983824372926160E+000
' Math.Cosh(0.1) * Math.Cosh(1.2) +
' Math.Sinh(0.1) * Math.Sinh(1.2) = 1.9709142303266281E+000
' Math.Cosh(1.3) = 1.9709142303266285E+000
'
' Math.Sinh(1.2) * Math.Cosh(4.9) +
' Math.Cosh(1.2) * Math.Sinh(4.9) = 2.2292776360739879E+002
' Math.Sinh(6.1) = 2.2292776360739885E+002
' Math.Cosh(1.2) * Math.Cosh(4.9) +
' Math.Sinh(1.2) * Math.Sinh(4.9) = 2.2293000647511826E+002
' Math.Cosh(6.1) = 2.2293000647511832E+002
// Example for the hyperbolic Math.Sinh( double )
// and Math.Cosh( double ) methods.
using System;
class Example
{
public static void Demo(System.Windows.Controls.TextBlock outputBlock)
{
outputBlock.Text +=
"This example of hyperbolic Math.Sinh( double ) " +
"and Math.Cosh( double )\n" +
"generates the following output.\n" + "\n";
outputBlock.Text +=
"Evaluate these hyperbolic identities " +
"with selected values for X:" + "\n";
outputBlock.Text +=
" cosh^2(X) - sinh^2(X) == 1\n" +
" sinh(2 * X) == 2 * sinh(X) * cosh(X)" + "\n";
outputBlock.Text += " cosh(2 * X) == cosh^2(X) + sinh^2(X)" + "\n";
UseExample(outputBlock, 0.1);
UseExample(outputBlock, 1.2);
UseExample(outputBlock, 4.9);
outputBlock.Text +=
"\nEvaluate these hyperbolic identities " +
"with selected values for X and Y:" + "\n";
outputBlock.Text +=
" sinh(X + Y) == sinh(X) * cosh(Y) + cosh(X) * sinh(Y)" + "\n";
outputBlock.Text +=
" cosh(X + Y) == cosh(X) * cosh(Y) + sinh(X) * sinh(Y)" + "\n";
UseTwoArgs(outputBlock, 0.1, 1.2);
UseTwoArgs(outputBlock, 1.2, 4.9);
}
// Evaluate hyperbolic identities with a given argument.
static void UseExample(System.Windows.Controls.TextBlock outputBlock, double arg)
{
double sinhArg = Math.Sinh(arg);
double coshArg = Math.Cosh(arg);
// Evaluate cosh^2(X) - sinh^2(X) == 1.
outputBlock.Text += String.Format(
"\n Math.Sinh({0}) == {1:E16}\n" +
" Math.Cosh({0}) == {2:E16}",
arg, Math.Sinh(arg), Math.Cosh(arg)) + "\n";
outputBlock.Text += String.Format(
"(Math.Cosh({0}))^2 - (Math.Sinh({0}))^2 == {1:E16}",
arg, coshArg * coshArg - sinhArg * sinhArg) + "\n";
// Evaluate sinh(2 * X) == 2 * sinh(X) * cosh(X).
outputBlock.Text += String.Format(
" Math.Sinh({0}) == {1:E16}",
2.0 * arg, Math.Sinh(2.0 * arg)) + "\n";
outputBlock.Text += String.Format(
" 2 * Math.Sinh({0}) * Math.Cosh({0}) == {1:E16}",
arg, 2.0 * sinhArg * coshArg) + "\n";
// Evaluate cosh(2 * X) == cosh^2(X) + sinh^2(X).
outputBlock.Text += String.Format(
" Math.Cosh({0}) == {1:E16}",
2.0 * arg, Math.Cosh(2.0 * arg)) + "\n";
outputBlock.Text += String.Format(
"(Math.Cosh({0}))^2 + (Math.Sinh({0}))^2 == {1:E16}",
arg, coshArg * coshArg + sinhArg * sinhArg) + "\n";
}
// Evaluate hyperbolic identities that are functions of two arguments.
static void UseTwoArgs(System.Windows.Controls.TextBlock outputBlock, double argX, double argY)
{
// Evaluate sinh(X + Y) == sinh(X) * cosh(Y) + cosh(X) * sinh(Y).
outputBlock.Text += String.Format(
"\n Math.Sinh({0}) * Math.Cosh({1}) +\n" +
" Math.Cosh({0}) * Math.Sinh({1}) == {2:E16}",
argX, argY, Math.Sinh(argX) * Math.Cosh(argY) +
Math.Cosh(argX) * Math.Sinh(argY)) + "\n";
outputBlock.Text += String.Format(
" Math.Sinh({0}) == {1:E16}",
argX + argY, Math.Sinh(argX + argY)) + "\n";
// Evaluate cosh(X + Y) == cosh(X) * cosh(Y) + sinh(X) * sinh(Y).
outputBlock.Text += String.Format(
" Math.Cosh({0}) * Math.Cosh({1}) +\n" +
" Math.Sinh({0}) * Math.Sinh({1}) == {2:E16}",
argX, argY, Math.Cosh(argX) * Math.Cosh(argY) +
Math.Sinh(argX) * Math.Sinh(argY)) + "\n";
outputBlock.Text += String.Format(
" Math.Cosh({0}) == {1:E16}",
argX + argY, Math.Cosh(argX + argY)) + "\n";
}
}
/*
This example of hyperbolic Math.Sinh( double ) and Math.Cosh( double )
generates the following output.
Evaluate these hyperbolic identities with selected values for X:
cosh^2(X) - sinh^2(X) == 1
sinh(2 * X) == 2 * sinh(X) * cosh(X)
cosh(2 * X) == cosh^2(X) + sinh^2(X)
Math.Sinh(0.1) == 1.0016675001984403E-001
Math.Cosh(0.1) == 1.0050041680558035E+000
(Math.Cosh(0.1))^2 - (Math.Sinh(0.1))^2 == 9.9999999999999989E-001
Math.Sinh(0.2) == 2.0133600254109399E-001
2 * Math.Sinh(0.1) * Math.Cosh(0.1) == 2.0133600254109396E-001
Math.Cosh(0.2) == 1.0200667556190759E+000
(Math.Cosh(0.1))^2 + (Math.Sinh(0.1))^2 == 1.0200667556190757E+000
Math.Sinh(1.2) == 1.5094613554121725E+000
Math.Cosh(1.2) == 1.8106555673243747E+000
(Math.Cosh(1.2))^2 - (Math.Sinh(1.2))^2 == 1.0000000000000000E+000
Math.Sinh(2.4) == 5.4662292136760939E+000
2 * Math.Sinh(1.2) * Math.Cosh(1.2) == 5.4662292136760939E+000
Math.Cosh(2.4) == 5.5569471669655064E+000
(Math.Cosh(1.2))^2 + (Math.Sinh(1.2))^2 == 5.5569471669655064E+000
Math.Sinh(4.9) == 6.7141166550932297E+001
Math.Cosh(4.9) == 6.7148613134003227E+001
(Math.Cosh(4.9))^2 - (Math.Sinh(4.9))^2 == 1.0000000000000000E+000
Math.Sinh(9.8) == 9.0168724361884615E+003
2 * Math.Sinh(4.9) * Math.Cosh(4.9) == 9.0168724361884615E+003
Math.Cosh(9.8) == 9.0168724916400624E+003
(Math.Cosh(4.9))^2 + (Math.Sinh(4.9))^2 == 9.0168724916400606E+003
Evaluate these hyperbolic identities with selected values for X and Y:
sinh(X + Y) == sinh(X) * cosh(Y) + cosh(X) * sinh(Y)
cosh(X + Y) == cosh(X) * cosh(Y) + sinh(X) * sinh(Y)
Math.Sinh(0.1) * Math.Cosh(1.2) +
Math.Cosh(0.1) * Math.Sinh(1.2) == 1.6983824372926155E+000
Math.Sinh(1.3) == 1.6983824372926160E+000
Math.Cosh(0.1) * Math.Cosh(1.2) +
Math.Sinh(0.1) * Math.Sinh(1.2) == 1.9709142303266281E+000
Math.Cosh(1.3) == 1.9709142303266285E+000
Math.Sinh(1.2) * Math.Cosh(4.9) +
Math.Cosh(1.2) * Math.Sinh(4.9) == 2.2292776360739879E+002
Math.Sinh(6.1) == 2.2292776360739885E+002
Math.Cosh(1.2) * Math.Cosh(4.9) +
Math.Sinh(1.2) * Math.Sinh(4.9) == 2.2293000647511826E+002
Math.Cosh(6.1) == 2.2293000647511832E+002
*/
Version Information
Silverlight
Supported in: 5, 4, 3
Silverlight for Windows Phone
Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0
XNA Framework
Supported in: Xbox 360, Windows Phone OS 7.0
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.