Here you can find the source of cosh(double x)
Parameter | Description |
---|---|
x | The value whose hyperbolic cosine is desired. |
If x is NaN, the result is NaN.
This method is a modified version of the one in the Visual Numerics Sfun class.
static public double cosh(double x)
//package com.java2s; /* Please see the license information in the header below. */ public class Main { /** Return the hyperbolic cosine of a double. *// w w w .j a va 2 s .com * @param x The value whose hyperbolic cosine is desired. * * @return The hyperbolic cosine of x. * * <p> * If x is NaN, the result is NaN. * </p> * * <p> * This method is a modified version of the one in the * Visual Numerics Sfun class. * </p> */ static public double cosh(double x) { double ans; double y = Math.exp(Math.abs(x)); if (Double.isNaN(x)) { ans = Double.NaN; } else if (Double.isInfinite(x)) { ans = x; } // 94906265.62 = 1.0/Math.sqrt(EPSILON_SMALL) else if (y < 94906265.62D) { ans = 0.5D * (y + 1.0D / y); } else { ans = 0.5D * y; } return ans; } }