Average Error: 2.0 → 1.4
Time: 2.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}\;a \le -1.99124214636743267 \cdot 10^{51}:\\ \;\;\;\;1 \cdot \mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, \mathsf{fma}\left(z, y, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), z, \mathsf{fma}\left(a, t, 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}\;a \le -1.99124214636743267 \cdot 10^{51}:\\
\;\;\;\;1 \cdot \mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, \mathsf{fma}\left(z, y, x\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r580664 = x;
        double r580665 = y;
        double r580666 = z;
        double r580667 = r580665 * r580666;
        double r580668 = r580664 + r580667;
        double r580669 = t;
        double r580670 = a;
        double r580671 = r580669 * r580670;
        double r580672 = r580668 + r580671;
        double r580673 = r580670 * r580666;
        double r580674 = b;
        double r580675 = r580673 * r580674;
        double r580676 = r580672 + r580675;
        return r580676;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r580677 = a;
        double r580678 = -1.9912421463674327e+51;
        bool r580679 = r580677 <= r580678;
        double r580680 = 1.0;
        double r580681 = b;
        double r580682 = z;
        double r580683 = t;
        double r580684 = fma(r580681, r580682, r580683);
        double r580685 = y;
        double r580686 = x;
        double r580687 = fma(r580682, r580685, r580686);
        double r580688 = fma(r580684, r580677, r580687);
        double r580689 = r580680 * r580688;
        double r580690 = fma(r580677, r580681, r580685);
        double r580691 = fma(r580677, r580683, r580686);
        double r580692 = fma(r580690, r580682, r580691);
        double r580693 = r580679 ? r580689 : r580692;
        return r580693;
}

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.4
Herbie1.4
\[\begin{array}{l} \mathbf{if}\;z \lt -11820553527347888000:\\ \;\;\;\;z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\ \mathbf{elif}\;z \lt 4.75897431883642871 \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 < -1.9912421463674327e+51

    1. Initial program 5.4

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
    2. Using strategy rm
    3. Applied associate-+l+5.4

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

      \[\leadsto \left(x + y \cdot z\right) + \color{blue}{\mathsf{fma}\left(t, a, \left(a \cdot z\right) \cdot b\right)}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity5.4

      \[\leadsto \left(x + y \cdot z\right) + \color{blue}{1 \cdot \mathsf{fma}\left(t, a, \left(a \cdot z\right) \cdot b\right)}\]
    7. Applied *-un-lft-identity5.4

      \[\leadsto \color{blue}{1 \cdot \left(x + y \cdot z\right)} + 1 \cdot \mathsf{fma}\left(t, a, \left(a \cdot z\right) \cdot b\right)\]
    8. Applied distribute-lft-out5.4

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

      \[\leadsto 1 \cdot \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, z, t\right), a, \mathsf{fma}\left(z, y, x\right)\right)}\]

    if -1.9912421463674327e+51 < a

    1. Initial program 1.4

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

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

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

Reproduce

herbie shell --seed 2020039 +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.7589743188364287e-122) (+ (* (+ (* b z) t) a) (+ (* z y) x)) (+ (* z (+ (* b a) y)) (+ x (* t a)))))

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