Geant4  10.00.p01
erfQ.cc
Go to the documentation of this file.
1 // $Id:$
2 // -*- C++ -*-
3 //
4 // -----------------------------------------------------------------------
5 // HEP Random
6 // --- erfQ ---
7 // method implementation file
8 // -----------------------------------------------------------------------
9 
10 // Contains methods that do not depend on large tables.
11 //
12 // erfQ (double x)
13 
14 // =======================================================================
15 // M Fischler - Created 1/26/00.
16 //
17 // =======================================================================
18 
19 #include "CLHEP/Random/Stat.h"
20 #include <cmath>
21 
22 namespace CLHEP {
23 
24 double HepStat::erfQ (double x) {
25 //
26 // erfQ is accurate to 7 places.
27 // See Numerical Recipes P 221
28 //
29 
30  double t, z, erfc;
31 
32  z = std::abs(x);
33  t = 1.0/(1.0+.5*z);
34 
35  erfc= t*std::exp(-z*z-1.26551223+t*(1.00002368+t*(0.37409196+t*(0.09678418+
36  t*(-0.18628806+t*(0.27886807+t*(-1.13520398+t*(1.48851587+
37  t*(-0.82215223+t*0.17087277 ))) ))) )));
38 
39  // (The derivation of this formula should be obvious.)
40 
41  if ( x < 0 ) erfc = 2.0 - erfc;
42 
43  return 1 - erfc;
44 
45 }
46 
47 
48 } // namespace CLHEP
49 
G4double z
Definition: TRTMaterials.hh:39