Example usage for java.lang StrictMath cosh

List of usage examples for java.lang StrictMath cosh

Introduction

In this page you can find the example usage for java.lang StrictMath cosh.

Prototype

public static native double cosh(double x);

Source Link

Document

Returns the hyperbolic cosine of a double value.

Usage

From source file:Main.java

public static void main(String[] args) {

    double d1 = (60 * (Math.PI)) / 180, d2 = 0.0, d3 = (1.0 / 0.0);

    double coshValue = StrictMath.cosh(d1);
    System.out.println("Hyperbolic cosine of d1 = " + coshValue);

    coshValue = StrictMath.cosh(d2);
    System.out.println("Hyperbolic cosine of d2 = " + coshValue);

    coshValue = StrictMath.cosh(d3);
    System.out.println("Hyperbolic cosine of d3 = " + coshValue);
}

From source file:org.esa.beam.util.math.FastMathPerformance.java

public void testCosh() {
    System.gc();// w w  w  .ja  v a  2s  . c  om
    double x = 0;
    long time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        x += StrictMath.cosh(i * F1);
    long strictTime = System.nanoTime() - time;

    System.gc();
    double y = 0;
    time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        y += FastMath.cosh(i * F1);
    long fastTime = System.nanoTime() - time;

    System.gc();
    double z = 0;
    time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        z += Math.cosh(i * F1);
    long mathTime = System.nanoTime() - time;

    report("cosh", x + y + z, strictTime, fastTime, mathTime);
}