CLHEP 2.0.4.7 Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

erfQ.cc

Go to the documentation of this file.
00001 // $Id: erfQ.cc,v 1.3 2003/08/13 20:00:12 garren Exp $
00002 // -*- C++ -*-
00003 //
00004 // -----------------------------------------------------------------------
00005 //                             HEP Random
00006 //                          --- erfQ ---
00007 //                      method implementation file
00008 // -----------------------------------------------------------------------
00009 
00010 // Contains methods that do not depend on large tables.
00011 //
00012 // erfQ           (double x)
00013 
00014 // =======================================================================
00015 // M Fischler     - Created 1/26/00.
00016 //
00017 // =======================================================================
00018 
00019 #include "CLHEP/Random/Stat.h"
00020 #include "CLHEP/Random/defs.h"
00021 #include <cmath>
00022 
00023 using namespace std;
00024 
00025 namespace CLHEP {
00026 
00027 double HepStat::erfQ (double x) {
00028 //
00029 // erfQ is accurate to 7 places.
00030 // See Numerical Recipes P 221
00031 //
00032 
00033   double t, z, erfc; 
00034 
00035   z = abs(x);
00036   t = 1.0/(1.0+.5*z);
00037 
00038   erfc= t*exp(-z*z-1.26551223+t*(1.00002368+t*(0.37409196+t*(0.09678418+
00039         t*(-0.18628806+t*(0.27886807+t*(-1.13520398+t*(1.48851587+
00040         t*(-0.82215223+t*0.17087277 ))) ))) )));
00041 
00042   // (The derivation of this formula should be obvious.)
00043 
00044   if ( x < 0 ) erfc = 2.0 - erfc;
00045 
00046   return 1 - erfc;
00047 
00048 }
00049 
00050 
00051 }  // namespace CLHEP
00052 

Generated on Thu Jul 1 22:02:30 2010 for CLHEP by  doxygen 1.4.7