Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Math.Sinh() Method in C#
The Math.Sinh() method in C# calculates the hyperbolic sine of a specified angle in radians. The hyperbolic sine function is defined mathematically as (ex - e-x)/2, where e is Euler's number (approximately 2.71828).
This method is commonly used in mathematical calculations involving hyperbolic functions, engineering applications, and scientific computations.
Syntax
Following is the syntax of the Math.Sinh() method −
public static double Sinh(double value)
Parameters
value: A double-precision floating-point number representing an angle in radians for which the hyperbolic sine is to be calculated.
Return Value
Returns a double representing the hyperbolic sine of the specified angle. The method returns:
NegativeInfinity if the value is NegativeInfinity
PositiveInfinity if the value is PositiveInfinity
NaN if the value is NaN
Example with Large Values
This example demonstrates the Math.Sinh() method with larger angle values −
using System;
public class Demo {
public static void Main() {
double val1 = 30.0;
double val2 = 45.0;
Console.WriteLine("sinh(30.0) = " + Math.Sinh(val1));
Console.WriteLine("sinh(45.0) = " + Math.Sinh(val2));
}
}
The output of the above code is −
sinh(30.0) = 5343237290762.23 sinh(45.0) = 1.74671355287425E+19
Example with Small Values
This example shows the behavior of Math.Sinh() with smaller values including zero −
using System;
public class Demo {
public static void Main() {
double val1 = 0.0;
double val2 = 1.1;
double val3 = -1.5;
Console.WriteLine("sinh(0.0) = " + Math.Sinh(val1));
Console.WriteLine("sinh(1.1) = " + Math.Sinh(val2));
Console.WriteLine("sinh(-1.5) = " + Math.Sinh(val3));
}
}
The output of the above code is −
sinh(0.0) = 0 sinh(1.1) = 1.33564747012418 sinh(-1.5) = -2.12927945509482
Example with Special Values
This example demonstrates how Math.Sinh() handles special floating-point values −
using System;
public class Demo {
public static void Main() {
Console.WriteLine("sinh(Infinity) = " + Math.Sinh(Double.PositiveInfinity));
Console.WriteLine("sinh(-Infinity) = " + Math.Sinh(Double.NegativeInfinity));
Console.WriteLine("sinh(NaN) = " + Math.Sinh(Double.NaN));
Console.WriteLine("sinh(1) = " + Math.Sinh(1.0));
}
}
The output of the above code is −
sinh(Infinity) = Infinity sinh(-Infinity) = -Infinity sinh(NaN) = NaN sinh(1) = 1.1752011936438
Conclusion
The Math.Sinh() method in C# calculates the hyperbolic sine of an angle in radians, returning a double value. It handles special cases like infinity and NaN appropriately, making it suitable for mathematical and scientific calculations involving hyperbolic functions.
