Sunday, June 24, 2012

Error and Gamma Functions in ANSI C

To use error and gamma functions in ANSI C, you will need to include the mathematics header:
#include<math.h>
1.Error Functions
ANSI C mathematical library provides functions for computing the Gauss error function and its complementary.

Example:
 float nrF = 0.32f;
 double nrD = 0.3232;
 long double nrL = 0.323232;
 /*Error function*/
 float eF = erff(nrF);
 double eD = erf(nrD);
 long double eL = erfL(nrL);
 /*Complementary error function*/
 float ceF = erfcf(nrF);
 double ceD = erfc(nrD);
 long double ceL = erfcl(ceL);
2.Gamma Functions
ANSI C mathematical library provides functions for computing gamma function and the natural logarithm of the gamma function. 

Example:
 float nrF = 0.32f;
 double nrD = 0.3232;
 long double nrL = 0.323232;
 /*Gamma function*/
 float eF = tgammaf(nrF);
 double eD = tgamma(nrD);
 long double eL = tgammal(nrL);
 /*Natural logarithm of the gamma function*/
 float ceF = lgammaf(nrF);
 double ceD = lgamma(nrD);
 long double ceL = lgammal(ceL);
Mathematical notions:

No comments:

Post a Comment

Got a question regarding something in the article? Leave me a comment and I will get back at you as soon as I can!

Related Posts Plugin for WordPress, Blogger...
Recommended Post Slide Out For Blogger