How to get the hyperbolic tangent of a double value in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {
 
    public static void main(String[] args) {
        
        System.out.println("Math.tanh(45 * Math.PI / 180.0) = " + Math.tanh(45 * Math.PI/180.0));
        System.out.println("Math.tanh(3 * Math.PI / 4) = " + Math.tanh(3 * Math.PI / 4));
        System.out.println("Math.tanh(5 * Math.PI / 4) = " + Math.tanh(5 * Math.PI / 4));
        System.out.println("Math.tanh(7 * Math.PI / 4) = " + Math.tanh(7 * Math.PI / 4));
        System.out.println("Math.tanh(Math.PI / 4) = " + Math.tanh(Math.PI / 4));
        System.out.println("Math.tanh(0) = " + Math.tanh(0));
        System.out.println("Math.tanh(-0) = " + Math.tanh(-0));
        System.out.println("Math.tanh(1) = " + Math.tanh(1));
        System.out.println("Math.tanh(Infinity) = " + Math.tanh(Double.POSITIVE_INFINITY));
    }
}
 
/*
run:

Math.tanh(45 * Math.PI / 180.0) = 0.6557942026326724
Math.tanh(3 * Math.PI / 4) = 0.9821933800072388
Math.tanh(5 * Math.PI / 4) = 0.9992238948786412
Math.tanh(7 * Math.PI / 4) = 0.9999664489997958
Math.tanh(Math.PI / 4) = 0.6557942026326724
Math.tanh(0) = 0.0
Math.tanh(-0) = 0.0
Math.tanh(1) = 0.7615941559557649
Math.tanh(Infinity) = 1.0
 
*/

 



answered Sep 10, 2016 by avibootz

Related questions

1 answer 205 views
1 answer 274 views
1 answer 155 views
1 answer 179 views
1 answer 184 views
...