Average Error: 2.1 → 0.2
Time: 11.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}\;z \le -6.667078785546412172981280839127214761515 \cdot 10^{85} \lor \neg \left(z \le 4478482220332740233991075628318720\right):\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot b\right) \cdot z\\ \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}\;z \le -6.667078785546412172981280839127214761515 \cdot 10^{85} \lor \neg \left(z \le 4478482220332740233991075628318720\right):\\
\;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot b\right) \cdot z\\

\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 r438815 = x;
        double r438816 = y;
        double r438817 = z;
        double r438818 = r438816 * r438817;
        double r438819 = r438815 + r438818;
        double r438820 = t;
        double r438821 = a;
        double r438822 = r438820 * r438821;
        double r438823 = r438819 + r438822;
        double r438824 = r438821 * r438817;
        double r438825 = b;
        double r438826 = r438824 * r438825;
        double r438827 = r438823 + r438826;
        return r438827;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r438828 = z;
        double r438829 = -6.667078785546412e+85;
        bool r438830 = r438828 <= r438829;
        double r438831 = 4.47848222033274e+33;
        bool r438832 = r438828 <= r438831;
        double r438833 = !r438832;
        bool r438834 = r438830 || r438833;
        double r438835 = x;
        double r438836 = y;
        double r438837 = r438836 * r438828;
        double r438838 = r438835 + r438837;
        double r438839 = t;
        double r438840 = a;
        double r438841 = r438839 * r438840;
        double r438842 = r438838 + r438841;
        double r438843 = b;
        double r438844 = r438840 * r438843;
        double r438845 = r438844 * r438828;
        double r438846 = r438842 + r438845;
        double r438847 = fma(r438828, r438843, r438839);
        double r438848 = fma(r438847, r438840, r438835);
        double r438849 = fma(r438828, r438836, r438848);
        double r438850 = r438834 ? r438846 : r438849;
        return r438850;
}

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

Original2.1
Target0.4
Herbie0.2
\[\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 z < -6.667078785546412e+85 or 4.47848222033274e+33 < z

    1. Initial program 6.6

      \[\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-cbrt6.8

      \[\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*6.8

      \[\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. Simplified6.8

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \left(a \cdot z\right)\right)} \cdot \sqrt[3]{b}\]
    6. Taylor expanded around inf 9.3

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{a \cdot \left(z \cdot b\right)}\]
    7. Simplified0.1

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot b\right) \cdot z}\]

    if -6.667078785546412e+85 < z < 4.47848222033274e+33

    1. Initial program 0.4

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

      \[\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.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -6.667078785546412172981280839127214761515 \cdot 10^{85} \lor \neg \left(z \le 4478482220332740233991075628318720\right):\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot b\right) \cdot z\\ \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 2019235 +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)))