Example usage for java.lang StrictMath tanh

List of usage examples for java.lang StrictMath tanh

Introduction

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

Prototype

public static native double tanh(double x);

Source Link

Document

Returns the hyperbolic tangent of a double value.

Usage

From source file:Main.java

public static void main(String[] args) {

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

    System.out.println("hyperbolic tangent of d1 = " + StrictMath.tanh(d1));

    System.out.println("hyperbolic tangent of d2 = " + StrictMath.tanh(d2));

    System.out.println("hyperbolic tangent of d3 = " + StrictMath.tanh(d3));

    System.out.println("hyperbolic tangent of d4 = " + StrictMath.tanh(d4));
}

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

public void testTanh() {
    System.gc();//from ww  w. ja  v  a 2  s.  c  o  m
    double x = 0;
    long time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        x += StrictMath.tanh(i * F1);
    long strictTime = System.nanoTime() - time;

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

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

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