Here you can find the source of tanh(double x)
public static double tanh(double x)
//package com.java2s; public class Main { public static double tanh(double x) { return sinh(x) / cosh(x); }//from w ww. j av a 2 s. c o m public static double sinh(double x) { return 0.5 * (Math.exp(x) - Math.exp(-x)); } public static double cosh(double x) { return 0.5 * (Math.exp(x) + Math.exp(-x)); } }