Here you can find the source of tanh(double z)
public static double tanh(double z)
//package com.java2s; public class Main { /** *///w w w. j a va2 s .c om public static double tanh(double z) { double eToTheZ = StrictMath.pow(StrictMath.E, z); double eToTheMinusZ = StrictMath.pow(StrictMath.E, -z); return ((eToTheZ - eToTheMinusZ) / (eToTheZ + eToTheMinusZ)); } }