Average Error: 1.9 → 0.9
Time: 17.2s
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}\;a \le -6.491061615135976035471078554718961981828 \cdot 10^{45}:\\ \;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\left(\left(\sqrt[3]{b} \cdot a\right) \cdot z\right) \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}\\ \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}\;a \le -6.491061615135976035471078554718961981828 \cdot 10^{45}:\\
\;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\left(\left(\sqrt[3]{b} \cdot a\right) \cdot z\right) \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}\\

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r557676 = x;
        double r557677 = y;
        double r557678 = z;
        double r557679 = r557677 * r557678;
        double r557680 = r557676 + r557679;
        double r557681 = t;
        double r557682 = a;
        double r557683 = r557681 * r557682;
        double r557684 = r557680 + r557683;
        double r557685 = r557682 * r557678;
        double r557686 = b;
        double r557687 = r557685 * r557686;
        double r557688 = r557684 + r557687;
        return r557688;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r557689 = a;
        double r557690 = -6.491061615135976e+45;
        bool r557691 = r557689 <= r557690;
        double r557692 = z;
        double r557693 = y;
        double r557694 = b;
        double r557695 = t;
        double r557696 = fma(r557692, r557694, r557695);
        double r557697 = x;
        double r557698 = fma(r557696, r557689, r557697);
        double r557699 = fma(r557692, r557693, r557698);
        double r557700 = r557693 * r557692;
        double r557701 = r557697 + r557700;
        double r557702 = r557695 * r557689;
        double r557703 = r557701 + r557702;
        double r557704 = cbrt(r557694);
        double r557705 = r557704 * r557689;
        double r557706 = r557705 * r557692;
        double r557707 = r557706 * r557704;
        double r557708 = r557707 * r557704;
        double r557709 = r557703 + r557708;
        double r557710 = r557691 ? r557699 : r557709;
        return r557710;
}

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.4
Herbie0.9
\[\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 a < -6.491061615135976e+45

    1. Initial program 6.1

      \[\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)}\]

    if -6.491061615135976e+45 < a

    1. Initial program 1.3

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
    2. Using strategy rm
    3. Applied add-cube-cbrt1.4

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot \color{blue}{\left(\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}\right)}\]
    4. Applied associate-*r*1.4

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(\left(a \cdot z\right) \cdot \left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right)\right) \cdot \sqrt[3]{b}}\]
    5. Using strategy rm
    6. Applied associate-*r*1.4

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(\left(\left(a \cdot z\right) \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}\right)} \cdot \sqrt[3]{b}\]
    7. Simplified1.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -6.491061615135976035471078554718961981828 \cdot 10^{45}:\\ \;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\left(\left(\sqrt[3]{b} \cdot a\right) \cdot z\right) \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019306 +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)))