Click here to Skip to main content
Click here to Skip to main content

Special Function(s) for C#

By , 15 Sep 2005
 

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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Miroslav Stampar
Software Developer (Senior)
Croatia Croatia
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralThank you!memberJeff Manning24 Jan '13 - 14:06 
QuestionThanks a lotmemberMember 341649812 Jan '13 - 3:41 
QuestionAwesome !!! ty very much!memberMember 822634013 Dec '12 - 2:23 
QuestionCopied functionsmemberiliyapolak5 Apr '12 - 3:01 
QuestionMACHEPmemberagelospanagiotakis3 Oct '11 - 13:39 
QuestionLicensingmemberMember 10990310 Aug '09 - 6:02 
AnswerRe: LicensingmemberMember 816281415 Aug '11 - 11:12 
GeneralRe: LicensingmemberMember 816368815 Aug '11 - 21:12 
GeneralAh, I could kiss you!!!memberMember 40338572 Apr '08 - 0:10 
GeneralGood workmemberram kumar 20212 Sep '07 - 22:46 
GeneralGood work!memberDesmond McCarter17 May '07 - 18:41 
GeneralRe: Good work!membera26gen11 Jun '07 - 21:54 
Generalfantasticmemberrabbithacking12 Apr '07 - 10:40 
GeneralStrange unitsmembermav.northwind15 Sep '05 - 11:40 
GeneralRe: Strange unitsmemberMiroslav Stampar15 Sep '05 - 22:49 
GeneralNeat, but...memberKeith Farmer15 Sep '05 - 8:15 
GeneralRe: Neat, but...memberHerbert Sauro5 Nov '05 - 8:59 
GeneralRe: Neat, but...memberKeith Farmer5 Nov '05 - 10:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 15 Sep 2005
Article Copyright 2005 by Miroslav Stampar
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid