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

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

\end{array}
double f(double a, double b) {
        double r259471 = a;
        double r259472 = r259471 * r259471;
        double r259473 = b;
        double r259474 = r259473 * r259473;
        double r259475 = r259472 + r259474;
        double r259476 = 2.0;
        double r259477 = pow(r259475, r259476);
        double r259478 = 4.0;
        double r259479 = r259478 * r259474;
        double r259480 = r259477 + r259479;
        double r259481 = 1.0;
        double r259482 = r259480 - r259481;
        return r259482;
}

double f(double a, double b) {
        double r259483 = a;
        double r259484 = -0.0006735223120487487;
        bool r259485 = r259483 <= r259484;
        double r259486 = 9.00135537302134e-08;
        bool r259487 = r259483 <= r259486;
        double r259488 = !r259487;
        bool r259489 = r259485 || r259488;
        double r259490 = 2.0;
        double r259491 = pow(r259483, r259490);
        double r259492 = r259490 * r259491;
        double r259493 = b;
        double r259494 = pow(r259493, r259490);
        double r259495 = 4.0;
        double r259496 = pow(r259493, r259495);
        double r259497 = fma(r259492, r259494, r259496);
        double r259498 = pow(r259483, r259495);
        double r259499 = r259497 + r259498;
        double r259500 = 1.0;
        double r259501 = r259499 - r259500;
        double r259502 = 2.0;
        double r259503 = r259502 * r259491;
        double r259504 = fma(r259503, r259494, r259496);
        double r259505 = 4.0;
        double r259506 = r259493 * r259493;
        double r259507 = r259505 * r259506;
        double r259508 = r259504 + r259507;
        double r259509 = r259508 - r259500;
        double r259510 = r259489 ? r259501 : r259509;
        return r259510;
}

Error

Bits error versus a

Bits error versus b

Derivation

  1. Split input into 2 regimes
  2. if a < -0.0006735223120487487 or 9.00135537302134e-08 < a

    1. Initial program 0.5

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

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

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

    if -0.0006735223120487487 < a < 9.00135537302134e-08

    1. Initial program 0.1

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

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

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

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

Reproduce

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