CLHEP VERSION 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 namespace CLHEP {
00024 
00025 double HepStat::erfQ (double x) {
00026 //
00027 // erfQ is accurate to 7 places.
00028 // See Numerical Recipes P 221
00029 //
00030 
00031   double t, z, erfc; 
00032 
00033   z = std::abs(x);
00034   t = 1.0/(1.0+.5*z);
00035 
00036   erfc= t*std::exp(-z*z-1.26551223+t*(1.00002368+t*(0.37409196+t*(0.09678418+
00037         t*(-0.18628806+t*(0.27886807+t*(-1.13520398+t*(1.48851587+
00038         t*(-0.82215223+t*0.17087277 ))) ))) )));
00039 
00040   // (The derivation of this formula should be obvious.)
00041 
00042   if ( x < 0 ) erfc = 2.0 - erfc;
00043 
00044   return 1 - erfc;
00045 
00046 }
00047 
00048 
00049 }  // namespace CLHEP
00050 

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7