Average Error: 11.1 → 0.3
Time: 30.8s
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}:\\ \;\;\;\;a \cdot \mathsf{erf} \left(\sqrt[3]{\frac{1}{\sqrt{2}}} \cdot \left(a \cdot \sqrt[3]{0.5}\right)\right) + \left(0.5 \cdot \left(\left({b}^{2} \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{\pi}}\right) - \left(0.5 \cdot \left(\left({a}^{2} \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{\pi}}\right) + a \cdot \mathsf{erf} \left(\frac{b}{\sqrt{2}}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \left(\sqrt[3]{\frac{{a}^{3}}{\sqrt{2} \cdot 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)\\ \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}:\\
\;\;\;\;a \cdot \mathsf{erf} \left(\sqrt[3]{\frac{1}{\sqrt{2}}} \cdot \left(a \cdot \sqrt[3]{0.5}\right)\right) + \left(0.5 \cdot \left(\left({b}^{2} \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{\pi}}\right) - \left(0.5 \cdot \left(\left({a}^{2} \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{\pi}}\right) + a \cdot \mathsf{erf} \left(\frac{b}{\sqrt{2}}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \left(\sqrt[3]{\frac{{a}^{3}}{\sqrt{2} \cdot 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)\\

\end{array}
double f(double a, double b) {
        double r43352 = 2.0;
        double r43353 = atan2(1.0, 0.0);
        double r43354 = r43352 / r43353;
        double r43355 = sqrt(r43354);
        double r43356 = a;
        double r43357 = pow(r43356, r43352);
        double r43358 = -r43357;
        double r43359 = r43358 / r43352;
        double r43360 = exp(r43359);
        double r43361 = r43355 * r43360;
        double r43362 = sqrt(r43352);
        double r43363 = r43356 / r43362;
        double r43364 = erf(r43363);
        double r43365 = r43356 * r43364;
        double r43366 = r43361 + r43365;
        double r43367 = b;
        double r43368 = pow(r43367, r43352);
        double r43369 = -r43368;
        double r43370 = r43369 / r43352;
        double r43371 = exp(r43370);
        double r43372 = r43355 * r43371;
        double r43373 = r43367 / r43362;
        double r43374 = erf(r43373);
        double r43375 = r43356 * r43374;
        double r43376 = r43372 + r43375;
        double r43377 = r43366 - r43376;
        return r43377;
}

double f(double a, double b) {
        double r43378 = b;
        double r43379 = 1.0371352189748177e-06;
        bool r43380 = r43378 <= r43379;
        double r43381 = a;
        double r43382 = 1.0;
        double r43383 = 2.0;
        double r43384 = sqrt(r43383);
        double r43385 = r43382 / r43384;
        double r43386 = cbrt(r43385);
        double r43387 = 0.5;
        double r43388 = cbrt(r43387);
        double r43389 = r43381 * r43388;
        double r43390 = r43386 * r43389;
        double r43391 = erf(r43390);
        double r43392 = r43381 * r43391;
        double r43393 = 2.0;
        double r43394 = pow(r43378, r43393);
        double r43395 = r43394 * r43384;
        double r43396 = atan2(1.0, 0.0);
        double r43397 = r43382 / r43396;
        double r43398 = sqrt(r43397);
        double r43399 = r43395 * r43398;
        double r43400 = r43387 * r43399;
        double r43401 = pow(r43381, r43393);
        double r43402 = r43401 * r43384;
        double r43403 = r43402 * r43398;
        double r43404 = r43387 * r43403;
        double r43405 = r43378 / r43384;
        double r43406 = erf(r43405);
        double r43407 = r43381 * r43406;
        double r43408 = r43404 + r43407;
        double r43409 = r43400 - r43408;
        double r43410 = r43392 + r43409;
        double r43411 = r43383 / r43396;
        double r43412 = sqrt(r43411);
        double r43413 = pow(r43381, r43383);
        double r43414 = -r43413;
        double r43415 = r43414 / r43383;
        double r43416 = exp(r43415);
        double r43417 = r43412 * r43416;
        double r43418 = 3.0;
        double r43419 = pow(r43381, r43418);
        double r43420 = r43384 * r43383;
        double r43421 = r43419 / r43420;
        double r43422 = cbrt(r43421);
        double r43423 = erf(r43422);
        double r43424 = r43381 * r43423;
        double r43425 = r43417 + r43424;
        double r43426 = pow(r43378, r43383);
        double r43427 = -r43426;
        double r43428 = r43427 / r43383;
        double r43429 = exp(r43428);
        double r43430 = r43412 * r43429;
        double r43431 = r43430 + r43407;
        double r43432 = r43425 - r43431;
        double r43433 = r43380 ? r43410 : r43432;
        return r43433;
}

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. Using strategy rm
    3. Applied add-cbrt-cube45.5

      \[\leadsto \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{a}{\color{blue}{\sqrt[3]{\left(\sqrt{2} \cdot \sqrt{2}\right) \cdot \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)\]
    4. Applied add-cbrt-cube45.5

      \[\leadsto \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{\color{blue}{\sqrt[3]{\left(a \cdot a\right) \cdot a}}}{\sqrt[3]{\left(\sqrt{2} \cdot \sqrt{2}\right) \cdot \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)\]
    5. Applied cbrt-undiv45.5

      \[\leadsto \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \color{blue}{\left(\sqrt[3]{\frac{\left(a \cdot a\right) \cdot a}{\left(\sqrt{2} \cdot \sqrt{2}\right) \cdot \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)\]
    6. Simplified45.5

      \[\leadsto \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \left(\sqrt[3]{\color{blue}{\frac{{a}^{3}}{\sqrt{2} \cdot 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)\]
    7. Taylor expanded around 0 0.4

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

      \[\leadsto \color{blue}{a \cdot \mathsf{erf} \left(\sqrt[3]{\frac{1}{\sqrt{2}}} \cdot \left(a \cdot \sqrt[3]{0.5}\right)\right) + \left(0.5 \cdot \left(\left({b}^{2} \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{\pi}}\right) - \left(0.5 \cdot \left(\left({a}^{2} \cdot \sqrt{2}\right) \cdot \sqrt{\frac{1}{\pi}}\right) + a \cdot \mathsf{erf} \left(\frac{b}{\sqrt{2}}\right)\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-cbrt-cube0.3

      \[\leadsto \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{a}{\color{blue}{\sqrt[3]{\left(\sqrt{2} \cdot \sqrt{2}\right) \cdot \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)\]
    4. Applied add-cbrt-cube0.3

      \[\leadsto \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \left(\frac{\color{blue}{\sqrt[3]{\left(a \cdot a\right) \cdot a}}}{\sqrt[3]{\left(\sqrt{2} \cdot \sqrt{2}\right) \cdot \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)\]
    5. Applied cbrt-undiv0.3

      \[\leadsto \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \color{blue}{\left(\sqrt[3]{\frac{\left(a \cdot a\right) \cdot a}{\left(\sqrt{2} \cdot \sqrt{2}\right) \cdot \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)\]
    6. Simplified0.3

      \[\leadsto \left(\sqrt{\frac{2}{\pi}} \cdot e^{\frac{-{a}^{2}}{2}} + a \cdot \mathsf{erf} \left(\sqrt[3]{\color{blue}{\frac{{a}^{3}}{\sqrt{2} \cdot 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)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

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

Reproduce

herbie shell --seed 1 
(FPCore (a b)
  :name "(sqrt(2/PI)*exp(-a^2/2) + a * erf(a/sqrt(2))) - (sqrt(2/PI)*exp(-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)))))))