Java Math.sinh
In Java, Math.sinh returns the hyperbolic sine of x, equal to (eˣ − e⁻ˣ) / 2. At zero the result is 0.
A simple example
Math.sinh
- Start with 0
- Do this Evaluate at the origin
- Result 0
class Main {
public static void main(String[] args) throws Exception {
System.out.println(Math.sinh(0.0));
}
}
0.0
Syntax
Math.sinh(offset)
JDK 21 method signatures (1)
public static double sinh(double x)Run these examples in Java
Save one example at a time as Main.java. Use JDK 21.
java Main.javaEstimate the slope of a hanging cable
An engineering class models a freely hanging cable. Evaluate the curve at the sample position so the team can relate the plotted shape or slope to that point on the cable.
class Main {
public static void main(String[] args) throws Exception {
double offset = 0.5;
System.out.printf(java.util.Locale.ROOT, "%.3f%n", (double) (Math.sinh(offset)));
}
}
0.521
Half a scale length from the centre, the slope is approximately 0.521.
Trace the left half of a cable model
A design student plots the normalized hanging curve y = cosh(x). She needs its slope one scale length to the left of the centre.
Using -1 gives -1.175 for this measurement.
Check the model at its centre
The middle of a symmetrical model cable is its lowest point. Its drawing routine evaluates the slope at position zero.
Using 0 gives 0.000 for this measurement.
What to watch for
Measure horizontal displacement in units of the cable model’s scale length.