MCPcopy Create free account
hub / github.com/BoevaLab/FREEC / erfc

Function erfc

src/normaldistr.cpp:123–164  ·  view source on GitHub ↗

Complementary error function 1 - erf(x) = inf. - 2 | | 2 erfc(x) = -------- | exp( - t ) dt sqrt(pi) | | - x For small x, erfc(x) = 1 - erf(x); otherwise rational approximations are computed. ACCURACY:

Source from the content-addressed store, hash-verified

121Copyright 1984, 1987, 1988, 1992, 2000 by Stephen L. Moshier
122*************************************************************************/
123double erfc(double x)
124{
125 double result;
126 double p;
127 double q;
128
129 if( ap::fp_less(x,0) )
130 {
131 result = 2-erfc(-x);
132 return result;
133 }
134 if( ap::fp_less(x,0.5) )
135 {
136 result = 1.0-erf(x);
137 return result;
138 }
139 if( ap::fp_greater_eq(x,10) )
140 {
141 result = 0;
142 return result;
143 }
144 p = 0.0;
145 p = 0.5641877825507397413087057563+x*p;
146 p = 9.675807882987265400604202961+x*p;
147 p = 77.08161730368428609781633646+x*p;
148 p = 368.5196154710010637133875746+x*p;
149 p = 1143.262070703886173606073338+x*p;
150 p = 2320.439590251635247384768711+x*p;
151 p = 2898.0293292167655611275846+x*p;
152 p = 1826.3348842295112592168999+x*p;
153 q = 1.0;
154 q = 17.14980943627607849376131193+x*q;
155 q = 137.1255960500622202878443578+x*q;
156 q = 661.7361207107653469211984771+x*q;
157 q = 2094.384367789539593790281779+x*q;
158 q = 4429.612803883682726711528526+x*q;
159 q = 6089.5424232724435504633068+x*q;
160 q = 4958.82756472114071495438422+x*q;
161 q = 1826.3348842295112595576438+x*q;
162 result = exp(-ap::sqr(x))*p/q;
163 return result;
164}
165
166
167/*************************************************************************

Callers 1

erfFunction · 0.85

Calls 1

erfFunction · 0.85

Tested by

no test coverage detected