Average Error: 1.9 → 0.3
Time: 8.7s
Precision: 64
\[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.105946974802992278559418043363022786483 \cdot 10^{84} \lor \neg \left(b \le 3.559618109462254448564983969943849591294 \cdot 10^{-29}\right):\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\right)\\ \end{array}\]
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\begin{array}{l}
\mathbf{if}\;b \le -1.105946974802992278559418043363022786483 \cdot 10^{84} \lor \neg \left(b \le 3.559618109462254448564983969943849591294 \cdot 10^{-29}\right):\\
\;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r439457 = x;
        double r439458 = y;
        double r439459 = z;
        double r439460 = r439458 * r439459;
        double r439461 = r439457 + r439460;
        double r439462 = t;
        double r439463 = a;
        double r439464 = r439462 * r439463;
        double r439465 = r439461 + r439464;
        double r439466 = r439463 * r439459;
        double r439467 = b;
        double r439468 = r439466 * r439467;
        double r439469 = r439465 + r439468;
        return r439469;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r439470 = b;
        double r439471 = -1.1059469748029923e+84;
        bool r439472 = r439470 <= r439471;
        double r439473 = 3.5596181094622544e-29;
        bool r439474 = r439470 <= r439473;
        double r439475 = !r439474;
        bool r439476 = r439472 || r439475;
        double r439477 = x;
        double r439478 = y;
        double r439479 = z;
        double r439480 = r439478 * r439479;
        double r439481 = r439477 + r439480;
        double r439482 = t;
        double r439483 = a;
        double r439484 = r439482 * r439483;
        double r439485 = r439481 + r439484;
        double r439486 = r439483 * r439479;
        double r439487 = r439486 * r439470;
        double r439488 = r439485 + r439487;
        double r439489 = fma(r439479, r439470, r439482);
        double r439490 = fma(r439489, r439483, r439477);
        double r439491 = fma(r439479, r439478, r439490);
        double r439492 = r439476 ? r439488 : r439491;
        return r439492;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Bits error versus b

Target

Original1.9
Target0.3
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;z \lt -11820553527347888128:\\ \;\;\;\;z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\ \mathbf{elif}\;z \lt 4.758974318836428710669076838657752600596 \cdot 10^{-122}:\\ \;\;\;\;\left(b \cdot z + t\right) \cdot a + \left(z \cdot y + x\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if b < -1.1059469748029923e+84 or 3.5596181094622544e-29 < b

    1. Initial program 0.6

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]

    if -1.1059469748029923e+84 < b < 3.5596181094622544e-29

    1. Initial program 2.8

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
    2. Simplified0.1

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, y, \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.105946974802992278559418043363022786483 \cdot 10^{84} \lor \neg \left(b \le 3.559618109462254448564983969943849591294 \cdot 10^{-29}\right):\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019208 +o rules:numerics
(FPCore (x y z t a b)
  :name "Graphics.Rasterific.CubicBezier:cachedBezierAt from Rasterific-0.6.1"
  :precision binary64

  :herbie-target
  (if (< z -11820553527347888000) (+ (* z (+ (* b a) y)) (+ x (* t a))) (if (< z 4.75897431883642871e-122) (+ (* (+ (* b z) t) a) (+ (* z y) x)) (+ (* z (+ (* b a) y)) (+ x (* t a)))))

  (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))