Returns the hyperbolic arc tangent of the specified number. - CSharp System

CSharp examples for System:Math Number

Description

Returns the hyperbolic arc tangent of the specified number.

Demo Code

/*//ww  w.  j  a  v a  2 s  .  co m
    **************************************************************************
    **
    **    Class  SpecialFunction (C#)
    **
    **************************************************************************
    **    Copyright (C) 1984 Stephen L. Moshier (original C version - Cephes Math Library)
    **    Copyright (C) 1996 Leigh Brookshaw    (Java version)
    **    Copyright (C) 2005 Miroslav Stampar   (C# version [->this<-])
    **
    **    This program is free software; you can redistribute it and/or modify
    **    it under the terms of the GNU General Public License as published by
    **    the Free Software Foundation; either version 2 of the License, or
    **    (at your option) any later version.
    **
    **    This program 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 General Public License for more details.
    **
    **    You should have received a copy of the GNU General Public License
    **    along with this program; if not, write to the Free Software
    **    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    **************************************************************************
    **
    **    This class is an extension of System.Math. It includes a number
    **    of special functions not found in the Math class.
    **
    *************************************************************************/
using System;

public class Main{
        /// <summary>
        ///     Returns the hyperbolic arc tangent of the specified number.
        /// </summary>
        /// <param name="x"></param>
        /// <returns></returns>
        public static double atanh(double x)
        {
            if (x > 1.0 || x < -1.0)
                throw
                    new ArithmeticException("range exception");
            return 0.5*Math.Log((1.0 + x)/(1.0 - x));
        }
}

Related Tutorials