CSharp examples for System:Math Number
Returns the hyperbolic cosine of the specified number.
/*// w w w . j ava 2s .c o 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 cosine of the specified number. /// </summary> /// <param name="x"></param> /// <returns></returns> public static double cosh(double x) { double a; a = x; if (a < 0.0) a = Math.Abs(x); a = Math.Exp(a); return 0.5*(a + 1/a); } }