Average Error: 11.1 → 0.3
Time: 27.4s
Precision: 64
\[0.0 \lt a \lt b\]
\[\left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{a}{\sqrt{2}}\right)\right) - \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{b}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{b}{\sqrt{2}}\right)\right)\]
\[\begin{array}{l} \mathbf{if}\;b \le 1.03713521897481766 \cdot 10^{-6}:\\ \;\;\;\;\left(0.5 \cdot \left(\left({b}^{2} \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{\pi}}\right) + a \cdot \mathsf{erf} \left(\frac{a}{\sqrt{2}}\right)\right) - \left(a \cdot \mathsf{erf} \left(\frac{b}{\sqrt{2}}\right) + 0.5 \cdot \left(\left({a}^{2} \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{\pi}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{a}{\sqrt{2}}\right)\right) - \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{b}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{1}{\sqrt{\sqrt{2}}} \cdot \frac{b}{\sqrt{\sqrt{2}}}\right)\right)\\ \end{array}\]
\left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{a}{\sqrt{2}}\right)\right) - \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{b}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{b}{\sqrt{2}}\right)\right)
\begin{array}{l}
\mathbf{if}\;b \le 1.03713521897481766 \cdot 10^{-6}:\\
\;\;\;\;\left(0.5 \cdot \left(\left({b}^{2} \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{\pi}}\right) + a \cdot \mathsf{erf} \left(\frac{a}{\sqrt{2}}\right)\right) - \left(a \cdot \mathsf{erf} \left(\frac{b}{\sqrt{2}}\right) + 0.5 \cdot \left(\left({a}^{2} \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{\pi}}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{a}{\sqrt{2}}\right)\right) - \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{b}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{1}{\sqrt{\sqrt{2}}} \cdot \frac{b}{\sqrt{\sqrt{2}}}\right)\right)\\

\end{array}
double f(double a, double b) {
        double r62466 = 2.0;
        double r62467 = atan2(1.0, 0.0);
        double r62468 = r62466 / r62467;
        double r62469 = sqrt(r62468);
        double r62470 = a;
        double r62471 = pow(r62470, r62466);
        double r62472 = -r62471;
        double r62473 = r62472 / r62466;
        double r62474 = exp(r62473);
        double r62475 = r62469 * r62474;
        double r62476 = sqrt(r62466);
        double r62477 = r62470 / r62476;
        double r62478 = erf(r62477);
        double r62479 = r62470 * r62478;
        double r62480 = r62475 + r62479;
        double r62481 = b;
        double r62482 = pow(r62481, r62466);
        double r62483 = -r62482;
        double r62484 = r62483 / r62466;
        double r62485 = exp(r62484);
        double r62486 = r62469 * r62485;
        double r62487 = r62481 / r62476;
        double r62488 = erf(r62487);
        double r62489 = r62470 * r62488;
        double r62490 = r62486 + r62489;
        double r62491 = r62480 - r62490;
        return r62491;
}

double f(double a, double b) {
        double r62492 = b;
        double r62493 = 1.0371352189748177e-06;
        bool r62494 = r62492 <= r62493;
        double r62495 = 0.5;
        double r62496 = 2.0;
        double r62497 = pow(r62492, r62496);
        double r62498 = 2.0;
        double r62499 = sqrt(r62498);
        double r62500 = r62497 * r62499;
        double r62501 = 1.0;
        double r62502 = atan2(1.0, 0.0);
        double r62503 = r62501 / r62502;
        double r62504 = sqrt(r62503);
        double r62505 = r62500 * r62504;
        double r62506 = r62495 * r62505;
        double r62507 = a;
        double r62508 = r62507 / r62499;
        double r62509 = erf(r62508);
        double r62510 = r62507 * r62509;
        double r62511 = r62506 + r62510;
        double r62512 = r62492 / r62499;
        double r62513 = erf(r62512);
        double r62514 = r62507 * r62513;
        double r62515 = pow(r62507, r62496);
        double r62516 = r62515 * r62499;
        double r62517 = r62516 * r62504;
        double r62518 = r62495 * r62517;
        double r62519 = r62514 + r62518;
        double r62520 = r62511 - r62519;
        double r62521 = r62498 / r62502;
        double r62522 = sqrt(r62521);
        double r62523 = pow(r62507, r62498);
        double r62524 = -r62523;
        double r62525 = r62524 / r62498;
        double r62526 = exp(r62525);
        double r62527 = r62522 * r62526;
        double r62528 = r62527 + r62510;
        double r62529 = pow(r62492, r62498);
        double r62530 = -r62529;
        double r62531 = r62530 / r62498;
        double r62532 = exp(r62531);
        double r62533 = r62522 * r62532;
        double r62534 = sqrt(r62499);
        double r62535 = r62501 / r62534;
        double r62536 = r62492 / r62534;
        double r62537 = r62535 * r62536;
        double r62538 = erf(r62537);
        double r62539 = r62507 * r62538;
        double r62540 = r62533 + r62539;
        double r62541 = r62528 - r62540;
        double r62542 = r62494 ? r62520 : r62541;
        return r62542;
}

Error

Bits error versus a

Bits error versus b

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if b < 1.0371352189748177e-06

    1. Initial program 45.5

      \[\left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{a}{\sqrt{2}}\right)\right) - \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{b}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{b}{\sqrt{2}}\right)\right)\]
    2. Taylor expanded around 0 0.4

      \[\leadsto \color{blue}{\left(0.5 \cdot \left(\left({b}^{2} \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{\pi}}\right) + a \cdot \mathsf{erf} \left(\frac{a}{\sqrt{2}}\right)\right) - \left(a \cdot \mathsf{erf} \left(\frac{b}{\sqrt{2}}\right) + 0.5 \cdot \left(\left({a}^{2} \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{\pi}}\right)\right)}\]

    if 1.0371352189748177e-06 < b

    1. Initial program 0.3

      \[\left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{a}{\sqrt{2}}\right)\right) - \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{b}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{b}{\sqrt{2}}\right)\right)\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.3

      \[\leadsto \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{a}{\sqrt{2}}\right)\right) - \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{b}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{b}{\sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}}\right)\right)\]
    4. Applied sqrt-prod0.3

      \[\leadsto \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{a}{\sqrt{2}}\right)\right) - \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{b}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{b}{\color{blue}{\sqrt{\sqrt{2}} \cdot \sqrt{\sqrt{2}}}}\right)\right)\]
    5. Applied *-un-lft-identity0.3

      \[\leadsto \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{a}{\sqrt{2}}\right)\right) - \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{b}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{\color{blue}{1 \cdot b}}{\sqrt{\sqrt{2}} \cdot \sqrt{\sqrt{2}}}\right)\right)\]
    6. Applied times-frac0.3

      \[\leadsto \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{a}{\sqrt{2}}\right)\right) - \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{b}^{2}}{2}} + a \cdot \mathsf{erf} \color{blue}{\left(\frac{1}{\sqrt{\sqrt{2}}} \cdot \frac{b}{\sqrt{\sqrt{2}}}\right)}\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 1.03713521897481766 \cdot 10^{-6}:\\ \;\;\;\;\left(0.5 \cdot \left(\left({b}^{2} \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{\pi}}\right) + a \cdot \mathsf{erf} \left(\frac{a}{\sqrt{2}}\right)\right) - \left(a \cdot \mathsf{erf} \left(\frac{b}{\sqrt{2}}\right) + 0.5 \cdot \left(\left({a}^{2} \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{\pi}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{a}{\sqrt{2}}\right)\right) - \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{b}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{1}{\sqrt{\sqrt{2}}} \cdot \frac{b}{\sqrt{\sqrt{2}}}\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (a b)
  :name "(sqrt(2/PI)*exp(-pow(a,2)/2) + a * erf(a/sqrt(2))) - (sqrt(2/PI)*exp(-pow(b,2)/2) + a * erf(b/sqrt(2)))"
  :pre (< 0.0 a b)
  (- (+ (* (sqrt (/ 2.0 PI)) (exp (/ (- (pow a 2.0)) 2.0))) (* a (erf (/ a (sqrt 2.0))))) (+ (* (sqrt (/ 2.0 PI)) (exp (/ (- (pow b 2.0)) 2.0))) (* a (erf (/ b (sqrt 2.0)))))))