Java tanh tanh(double t)

Here you can find the source of tanh(double t)

Description

tanh

License

Open Source License

Declaration

public static double tanh(double t) 

Method Source Code

//package com.java2s;
/*/*  w  ww. java  2 s. c o  m*/
Copyright 2008,
CCTC - Computer Science and Technology Center
IBB-DEB - Institute for Biotechnology and  Bioengineering - Department of Biological Engineering
University of Minho
    
This is free software: you can redistribute it and/or modify
it under the terms of the GNU Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
    
This code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Public License for more details.
    
You should have received a copy of the GNU Public License
along with this code.  If not, see <http://www.gnu.org/licenses/>.
    
Created inside the SysBio Research Group (http://sysbio.di.uminho.pt)
University of Minho
*/

public class Main {
    public static double tanh(double t) {
        Double aux = new Double(sinh(t) / cosh(t));
        if (aux.isNaN()) {
            if (t > 0.0)
                return 1.0;
            else
                return -1.0;
        }
        return aux.doubleValue();
    }

    public static double sinh(double t) {
        return (Math.exp(t) - Math.exp(-t)) / 2;
    }

    public static double cosh(double t) {
        return (Math.exp(t) + Math.exp(-t)) / 2;
    }
}

Related

  1. tanh(double paramDouble)
  2. tanh(double x)
  3. tanh(double x)
  4. tanh(Double x)
  5. tanh(double z)