Average Error: 2.0 → 0.8
Time: 16.9s
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.029332914097035150003651381505816557895 \cdot 10^{146}:\\ \;\;\;\;\left(a \cdot z\right) \cdot b + \left(\left(x + y \cdot z\right) + a \cdot t\right)\\ \mathbf{elif}\;b \le 3.88479588022017558466900273665607578266 \cdot 10^{84}:\\ \;\;\;\;\mathsf{fma}\left(t, a, \mathsf{fma}\left(z, \mathsf{fma}\left(a, b, y\right), x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot z\right) \cdot b + \left(\left(x + y \cdot z\right) + a \cdot t\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.029332914097035150003651381505816557895 \cdot 10^{146}:\\
\;\;\;\;\left(a \cdot z\right) \cdot b + \left(\left(x + y \cdot z\right) + a \cdot t\right)\\

\mathbf{elif}\;b \le 3.88479588022017558466900273665607578266 \cdot 10^{84}:\\
\;\;\;\;\mathsf{fma}\left(t, a, \mathsf{fma}\left(z, \mathsf{fma}\left(a, b, y\right), x\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r25272722 = x;
        double r25272723 = y;
        double r25272724 = z;
        double r25272725 = r25272723 * r25272724;
        double r25272726 = r25272722 + r25272725;
        double r25272727 = t;
        double r25272728 = a;
        double r25272729 = r25272727 * r25272728;
        double r25272730 = r25272726 + r25272729;
        double r25272731 = r25272728 * r25272724;
        double r25272732 = b;
        double r25272733 = r25272731 * r25272732;
        double r25272734 = r25272730 + r25272733;
        return r25272734;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r25272735 = b;
        double r25272736 = -1.0293329140970352e+146;
        bool r25272737 = r25272735 <= r25272736;
        double r25272738 = a;
        double r25272739 = z;
        double r25272740 = r25272738 * r25272739;
        double r25272741 = r25272740 * r25272735;
        double r25272742 = x;
        double r25272743 = y;
        double r25272744 = r25272743 * r25272739;
        double r25272745 = r25272742 + r25272744;
        double r25272746 = t;
        double r25272747 = r25272738 * r25272746;
        double r25272748 = r25272745 + r25272747;
        double r25272749 = r25272741 + r25272748;
        double r25272750 = 3.8847958802201756e+84;
        bool r25272751 = r25272735 <= r25272750;
        double r25272752 = fma(r25272738, r25272735, r25272743);
        double r25272753 = fma(r25272739, r25272752, r25272742);
        double r25272754 = fma(r25272746, r25272738, r25272753);
        double r25272755 = r25272751 ? r25272754 : r25272749;
        double r25272756 = r25272737 ? r25272749 : r25272755;
        return r25272756;
}

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.0
Target0.3
Herbie0.8
\[\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.0293329140970352e+146 or 3.8847958802201756e+84 < b

    1. Initial program 0.9

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

    if -1.0293329140970352e+146 < b < 3.8847958802201756e+84

    1. Initial program 2.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.029332914097035150003651381505816557895 \cdot 10^{146}:\\ \;\;\;\;\left(a \cdot z\right) \cdot b + \left(\left(x + y \cdot z\right) + a \cdot t\right)\\ \mathbf{elif}\;b \le 3.88479588022017558466900273665607578266 \cdot 10^{84}:\\ \;\;\;\;\mathsf{fma}\left(t, a, \mathsf{fma}\left(z, \mathsf{fma}\left(a, b, y\right), x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot z\right) \cdot b + \left(\left(x + y \cdot z\right) + a \cdot t\right)\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< z -1.1820553527347888e+19) (+ (* z (+ (* b a) y)) (+ x (* t a))) (if (< z 4.7589743188364287e-122) (+ (* (+ (* b z) t) a) (+ (* z y) x)) (+ (* z (+ (* b a) y)) (+ x (* t a)))))

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