65.9K
CodeProject is changing. Read more.
Home

Special Function(s) for C#

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.60/5 (33 votes)

Sep 15, 2005

CPOL
viewsIcon

99182

downloadIcon

3389

Physical constants and special functions not found in the System.Math class

Introduction

This class contains physical constants and special functions not found in the System.Math class (C# port of the Cephes math library).

Constants

// Physical Constants in cgs Units
    
// Boltzman Constant. Units erg/deg(K) 
public const double BOLTZMAN = 1.3807e-16;
    
// Elementary Charge. Units statcoulomb 
public const double ECHARGE = 4.8032e-10;
    
// Electron Mass. Units g 
public const double EMASS = 9.1095e-28;
    
// Proton Mass. Units g 
public const double PMASS = 1.6726e-24;
    
// Gravitational Constant. Units dyne-cm^2/g^2
public const double GRAV = 6.6720e-08;
    
// Planck constant. Units erg-sec 
public const double PLANCK = 6.6262e-27;
    
// Speed of Light in a Vacuum. Units cm/sec 
public const double LIGHTSPEED = 2.9979e10;
    
// Stefan-Boltzman Constant. Units erg/cm^2-sec-deg^4 
public const double STEFANBOLTZ = 5.6703e-5;
    
// Avogadro Number. Units  1/mol 
public const double AVOGADRO = 6.0220e23;
    
// Gas Constant. Units erg/deg-mol 
public const double GASCONSTANT = 8.3144e07;
    
// Gravitational Acceleration at the Earths surface. Units cm/sec^2 
public const double GRAVACC = 980.67;
    
// Solar Mass. Units g 
public const double SOLARMASS = 1.99e33;
    
// Solar Radius. Units cm
public const double SOLARRADIUS = 6.96e10;
    
// Solar Luminosity. Units erg/sec
public const double SOLARLUM = 3.90e33;
    
// Solar Flux. Units erg/cm^2-sec
public const double SOLARFLUX = 6.41e10;
    
// Astronomical Unit (radius of the Earth's orbit). Units cm
public const double AU = 1.50e13;

Methods

/// Returns the base 10 logarithm of the specified number.
public static double log10(double x);

/// Returns the hyperbolic cosine of the specified number.
public static double cosh(double x);

/// Returns the hyperbolic sine of the specified number.
public static double sinh(double x);

/// Returns the hyperbolic tangent of the specified number.
public static double tanh(double x);

/// Returns the hyperbolic arc cosine of the specified number.
public static double acosh(double x);

/// Returns the hyperbolic arc sine of the specified number.
public static double asinh(double xx);

/// Returns the hyperbolic arc tangent of the specified number.
public static double atanh(double x);

/// Returns the Bessel function of order 0 of the specified number.
public static double j0(double x);

/// Returns the Bessel function of order 1 of the specified number.
public static double j1(double x);

/// Returns the Bessel function of order n of the specified number.
public static double jn(int n, double x);

/// Returns the Bessel function of the second kind,
/// of order 0 of the specified number.
public static double y0(double x);

/// Returns the Bessel function of the second kind,
/// of order 1 of the specified number.
public static double y1(double x);

/// Returns the Bessel function of the second kind,
/// of order n of the specified number.
public static double yn(int n, double x);

/// Returns the factorial of the specified number.
public static double fac(double x);

/// Returns the factorial of the specified number.
public static int fac(int j);

/// Returns the gamma function of the specified number.
public static double gamma(double x);

/// Return the gamma function computed by Stirling's formula.
private static double stirf(double x);

/// Returns the complemented incomplete gamma function.
public static double igamc(double a, double x);

/// Returns the incomplete gamma function.
public static double igam(double a, double x);

/// Returns the chi-square function (left hand tail).
public static double chisq(double df, double x);

/// Returns the chi-square function (right hand tail).
public static double chisqc(double df, double x);

/// Returns the sum of the first k terms of the Poisson distribution.
public static double poisson(int k, double x);

/// Returns the sum of the terms k+1 to infinity of the Poisson distribution.
public static double poissonc(int k, double x);

/// Returns the area under the Gaussian probability density function, 
///integrated from minus infinity to a.
public static double normal(double a);

/// Returns the complementary error function of the specified number.
public static double erfc(double a);

/// Returns the error function of the specified number.
public static double erf(double x);

/// Evaluates polynomial of degree N
private static double polevl(double x, double[] coef, int N);

/// Evaluates polynomial of degree N with assumption that coef[N] = 1.0
private static double p1evl(double x, double[] coef, int N);

/// Returns the natural logarithm of gamma function.
public static double lgamma(double x);

/// Returns the incomplete beta function evaluated from zero to xx.
public static double ibeta(double aa, double bb, double xx);

/// Returns the continued fraction expansion #1 for incomplete beta integral.
private static double incbcf(double a, double b, double x);

/// Returns the continued fraction expansion #2 for incomplete beta integral.
private static double incbd(double a, double b, double x);

/// Returns the power series for incomplete beta integral.
/// Use when b*x is small and x not too close to 1.
private static double pseries(double a, double b, double x);

Outroduction

I hope this will put a smile on someone's face, at least one. :)

History

  • 15th September, 2005: Initial post