Average Error: 17.3 → 16.0
Time: 14.6s
Precision: 64
$1 - e^{\frac{-{x}^{2}}{2 \cdot {a}^{2}}}$
$\begin{array}{l} \mathbf{if}\;x \le -1.503293347553669608151868605149335038254 \cdot 10^{-26} \lor \neg \left(x \le -2.768001142293592205746307713969614392851 \cdot 10^{-128}\right):\\ \;\;\;\;\frac{1 \cdot 1 - e^{-2 \cdot \frac{{x}^{\left(\frac{2}{2}\right)}}{\frac{2 \cdot {a}^{2}}{{x}^{\left(\frac{2}{2}\right)}}}}}{1 + e^{\frac{-{x}^{\left(\frac{2}{2}\right)}}{\frac{2 \cdot {a}^{2}}{{x}^{\left(\frac{2}{2}\right)}}}}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left({\left(\frac{1}{{a}^{2}}\right)}^{1} \cdot {x}^{2}\right)\\ \end{array}$
1 - e^{\frac{-{x}^{2}}{2 \cdot {a}^{2}}}
\begin{array}{l}
\mathbf{if}\;x \le -1.503293347553669608151868605149335038254 \cdot 10^{-26} \lor \neg \left(x \le -2.768001142293592205746307713969614392851 \cdot 10^{-128}\right):\\
\;\;\;\;\frac{1 \cdot 1 - e^{-2 \cdot \frac{{x}^{\left(\frac{2}{2}\right)}}{\frac{2 \cdot {a}^{2}}{{x}^{\left(\frac{2}{2}\right)}}}}}{1 + e^{\frac{-{x}^{\left(\frac{2}{2}\right)}}{\frac{2 \cdot {a}^{2}}{{x}^{\left(\frac{2}{2}\right)}}}}}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left({\left(\frac{1}{{a}^{2}}\right)}^{1} \cdot {x}^{2}\right)\\

\end{array}
double f(double x, double a) {
double r55290 = 1.0;
double r55291 = x;
double r55292 = 2.0;
double r55293 = pow(r55291, r55292);
double r55294 = -r55293;
double r55295 = a;
double r55296 = pow(r55295, r55292);
double r55297 = r55292 * r55296;
double r55298 = r55294 / r55297;
double r55299 = exp(r55298);
double r55300 = r55290 - r55299;
return r55300;
}


double f(double x, double a) {
double r55301 = x;
double r55302 = -1.5032933475536696e-26;
bool r55303 = r55301 <= r55302;
double r55304 = -2.768001142293592e-128;
bool r55305 = r55301 <= r55304;
double r55306 = !r55305;
bool r55307 = r55303 || r55306;
double r55308 = 1.0;
double r55309 = r55308 * r55308;
double r55310 = -2.0;
double r55311 = 2.0;
double r55312 = 2.0;
double r55313 = r55311 / r55312;
double r55314 = pow(r55301, r55313);
double r55315 = a;
double r55316 = pow(r55315, r55311);
double r55317 = r55311 * r55316;
double r55318 = r55317 / r55314;
double r55319 = r55314 / r55318;
double r55320 = r55310 * r55319;
double r55321 = exp(r55320);
double r55322 = r55309 - r55321;
double r55323 = -r55314;
double r55324 = r55323 / r55318;
double r55325 = exp(r55324);
double r55326 = r55308 + r55325;
double r55327 = r55322 / r55326;
double r55328 = 0.5;
double r55329 = 1.0;
double r55330 = r55329 / r55316;
double r55331 = pow(r55330, r55308);
double r55332 = pow(r55301, r55312);
double r55333 = r55331 * r55332;
double r55334 = r55328 * r55333;
double r55335 = r55307 ? r55327 : r55334;
return r55335;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 2 regimes
2. ## if x < -1.5032933475536696e-26 or -2.768001142293592e-128 < x

1. Initial program 17.4

$1 - e^{\frac{-{x}^{2}}{2 \cdot {a}^{2}}}$
2. Using strategy rm
3. Applied sqr-pow17.4

$\leadsto 1 - e^{\frac{-\color{blue}{{x}^{\left(\frac{2}{2}\right)} \cdot {x}^{\left(\frac{2}{2}\right)}}}{2 \cdot {a}^{2}}}$
4. Applied distribute-lft-neg-in17.4

$\leadsto 1 - e^{\frac{\color{blue}{\left(-{x}^{\left(\frac{2}{2}\right)}\right) \cdot {x}^{\left(\frac{2}{2}\right)}}}{2 \cdot {a}^{2}}}$
5. Applied associate-/l*15.2

$\leadsto 1 - e^{\color{blue}{\frac{-{x}^{\left(\frac{2}{2}\right)}}{\frac{2 \cdot {a}^{2}}{{x}^{\left(\frac{2}{2}\right)}}}}}$
6. Using strategy rm
7. Applied flip--15.2

$\leadsto \color{blue}{\frac{1 \cdot 1 - e^{\frac{-{x}^{\left(\frac{2}{2}\right)}}{\frac{2 \cdot {a}^{2}}{{x}^{\left(\frac{2}{2}\right)}}}} \cdot e^{\frac{-{x}^{\left(\frac{2}{2}\right)}}{\frac{2 \cdot {a}^{2}}{{x}^{\left(\frac{2}{2}\right)}}}}}{1 + e^{\frac{-{x}^{\left(\frac{2}{2}\right)}}{\frac{2 \cdot {a}^{2}}{{x}^{\left(\frac{2}{2}\right)}}}}}}$
8. Simplified15.1

$\leadsto \frac{\color{blue}{1 \cdot 1 - e^{2 \cdot \frac{-{x}^{\left(\frac{2}{2}\right)}}{\frac{2 \cdot {a}^{2}}{{x}^{\left(\frac{2}{2}\right)}}}}}}{1 + e^{\frac{-{x}^{\left(\frac{2}{2}\right)}}{\frac{2 \cdot {a}^{2}}{{x}^{\left(\frac{2}{2}\right)}}}}}$

## if -1.5032933475536696e-26 < x < -2.768001142293592e-128

1. Initial program 15.9

$1 - e^{\frac{-{x}^{2}}{2 \cdot {a}^{2}}}$
2. Taylor expanded around 0 24.8

$\leadsto \color{blue}{0.5 \cdot \left({\left(\frac{1}{{a}^{2}}\right)}^{1} \cdot {x}^{2}\right)}$
3. Recombined 2 regimes into one program.
4. Final simplification16.0

$\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.503293347553669608151868605149335038254 \cdot 10^{-26} \lor \neg \left(x \le -2.768001142293592205746307713969614392851 \cdot 10^{-128}\right):\\ \;\;\;\;\frac{1 \cdot 1 - e^{-2 \cdot \frac{{x}^{\left(\frac{2}{2}\right)}}{\frac{2 \cdot {a}^{2}}{{x}^{\left(\frac{2}{2}\right)}}}}}{1 + e^{\frac{-{x}^{\left(\frac{2}{2}\right)}}{\frac{2 \cdot {a}^{2}}{{x}^{\left(\frac{2}{2}\right)}}}}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left({\left(\frac{1}{{a}^{2}}\right)}^{1} \cdot {x}^{2}\right)\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (x a)
:name "1-exp(-x^2/(2*a^2))"
:precision binary64
(- 1 (exp (/ (- (pow x 2)) (* 2 (pow a 2))))))