Average Error: 0.2 → 0.8
Time: 5.2s
Precision: 64
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1\]
\[\begin{array}{l} \mathbf{if}\;b \cdot b \le 1.936931190143802367694542132525725719461 \cdot 10^{-6}:\\ \;\;\;\;\left(\mathsf{fma}\left({a}^{4}, 1, 4 \cdot \left({a}^{2} - {a}^{3}\right)\right) + \left(\left(b \cdot b\right) \cdot \left(3 + a\right)\right) \cdot 4\right) - 1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left({a}^{3}, a, \mathsf{fma}\left(2 \cdot {a}^{2}, {b}^{2}, {b}^{4}\right)\right) - 1\\ \end{array}\]
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\begin{array}{l}
\mathbf{if}\;b \cdot b \le 1.936931190143802367694542132525725719461 \cdot 10^{-6}:\\
\;\;\;\;\left(\mathsf{fma}\left({a}^{4}, 1, 4 \cdot \left({a}^{2} - {a}^{3}\right)\right) + \left(\left(b \cdot b\right) \cdot \left(3 + a\right)\right) \cdot 4\right) - 1\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left({a}^{3}, a, \mathsf{fma}\left(2 \cdot {a}^{2}, {b}^{2}, {b}^{4}\right)\right) - 1\\

\end{array}
double f(double a, double b) {
        double r423403 = a;
        double r423404 = r423403 * r423403;
        double r423405 = b;
        double r423406 = r423405 * r423405;
        double r423407 = r423404 + r423406;
        double r423408 = 2.0;
        double r423409 = pow(r423407, r423408);
        double r423410 = 4.0;
        double r423411 = 1.0;
        double r423412 = r423411 - r423403;
        double r423413 = r423404 * r423412;
        double r423414 = 3.0;
        double r423415 = r423414 + r423403;
        double r423416 = r423406 * r423415;
        double r423417 = r423413 + r423416;
        double r423418 = r423410 * r423417;
        double r423419 = r423409 + r423418;
        double r423420 = r423419 - r423411;
        return r423420;
}

double f(double a, double b) {
        double r423421 = b;
        double r423422 = r423421 * r423421;
        double r423423 = 1.9369311901438024e-06;
        bool r423424 = r423422 <= r423423;
        double r423425 = a;
        double r423426 = 4.0;
        double r423427 = pow(r423425, r423426);
        double r423428 = 1.0;
        double r423429 = 4.0;
        double r423430 = 2.0;
        double r423431 = pow(r423425, r423430);
        double r423432 = 3.0;
        double r423433 = pow(r423425, r423432);
        double r423434 = r423431 - r423433;
        double r423435 = r423429 * r423434;
        double r423436 = fma(r423427, r423428, r423435);
        double r423437 = 3.0;
        double r423438 = r423437 + r423425;
        double r423439 = r423422 * r423438;
        double r423440 = r423439 * r423429;
        double r423441 = r423436 + r423440;
        double r423442 = r423441 - r423428;
        double r423443 = r423430 * r423431;
        double r423444 = pow(r423421, r423430);
        double r423445 = pow(r423421, r423426);
        double r423446 = fma(r423443, r423444, r423445);
        double r423447 = fma(r423433, r423425, r423446);
        double r423448 = r423447 - r423428;
        double r423449 = r423424 ? r423442 : r423448;
        return r423449;
}

Error

Bits error versus a

Bits error versus b

Derivation

  1. Split input into 2 regimes
  2. if (* b b) < 1.9369311901438024e-06

    1. Initial program 0.1

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1\]
    2. Using strategy rm
    3. Applied distribute-rgt-in0.1

      \[\leadsto \left({\left(a \cdot a + b \cdot b\right)}^{2} + \color{blue}{\left(\left(\left(a \cdot a\right) \cdot \left(1 - a\right)\right) \cdot 4 + \left(\left(b \cdot b\right) \cdot \left(3 + a\right)\right) \cdot 4\right)}\right) - 1\]
    4. Applied associate-+r+0.1

      \[\leadsto \color{blue}{\left(\left({\left(a \cdot a + b \cdot b\right)}^{2} + \left(\left(a \cdot a\right) \cdot \left(1 - a\right)\right) \cdot 4\right) + \left(\left(b \cdot b\right) \cdot \left(3 + a\right)\right) \cdot 4\right)} - 1\]
    5. Simplified0.1

      \[\leadsto \left(\color{blue}{\mathsf{fma}\left({a}^{2}, \left(1 - a\right) \cdot 4, {\left(a \cdot a + b \cdot b\right)}^{2}\right)} + \left(\left(b \cdot b\right) \cdot \left(3 + a\right)\right) \cdot 4\right) - 1\]
    6. Taylor expanded around 0 0.0

      \[\leadsto \left(\color{blue}{\left(\left(4 \cdot {a}^{2} + 1 \cdot {a}^{4}\right) - 4 \cdot {a}^{3}\right)} + \left(\left(b \cdot b\right) \cdot \left(3 + a\right)\right) \cdot 4\right) - 1\]
    7. Simplified0.0

      \[\leadsto \left(\color{blue}{\mathsf{fma}\left({a}^{4}, 1, 4 \cdot \left({a}^{2} - {a}^{3}\right)\right)} + \left(\left(b \cdot b\right) \cdot \left(3 + a\right)\right) \cdot 4\right) - 1\]

    if 1.9369311901438024e-06 < (* b b)

    1. Initial program 0.5

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1\]
    2. Taylor expanded around inf 3.9

      \[\leadsto \color{blue}{\left({a}^{4} + \left({b}^{4} + 2 \cdot \left({a}^{2} \cdot {b}^{2}\right)\right)\right)} - 1\]
    3. Simplified3.9

      \[\leadsto \color{blue}{\mathsf{fma}\left({a}^{3}, a, \mathsf{fma}\left(2 \cdot {a}^{2}, {b}^{2}, {b}^{4}\right)\right)} - 1\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot b \le 1.936931190143802367694542132525725719461 \cdot 10^{-6}:\\ \;\;\;\;\left(\mathsf{fma}\left({a}^{4}, 1, 4 \cdot \left({a}^{2} - {a}^{3}\right)\right) + \left(\left(b \cdot b\right) \cdot \left(3 + a\right)\right) \cdot 4\right) - 1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left({a}^{3}, a, \mathsf{fma}\left(2 \cdot {a}^{2}, {b}^{2}, {b}^{4}\right)\right) - 1\\ \end{array}\]

Reproduce

herbie shell --seed 2019353 +o rules:numerics
(FPCore (a b)
  :name "Bouland and Aaronson, Equation (24)"
  :precision binary64
  (- (+ (pow (+ (* a a) (* b b)) 2) (* 4 (+ (* (* a a) (- 1 a)) (* (* b b) (+ 3 a))))) 1))