erfQ.cc

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

Generated on Mon May 27 17:47:34 2013 for Geant4 by  doxygen 1.4.7