Average Error: 2.1 → 1.4
Time: 7.8s
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.071371100277623 \cdot 10^{138}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + a \cdot \left(z \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot 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 -1.071371100277623 \cdot 10^{138}:\\
\;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + a \cdot \left(z \cdot b\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r3642 = x;
        double r3643 = y;
        double r3644 = z;
        double r3645 = r3643 * r3644;
        double r3646 = r3642 + r3645;
        double r3647 = t;
        double r3648 = a;
        double r3649 = r3647 * r3648;
        double r3650 = r3646 + r3649;
        double r3651 = r3648 * r3644;
        double r3652 = b;
        double r3653 = r3651 * r3652;
        double r3654 = r3650 + r3653;
        return r3654;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r3655 = a;
        double r3656 = -1.071371100277623e+138;
        bool r3657 = r3655 <= r3656;
        double r3658 = x;
        double r3659 = y;
        double r3660 = z;
        double r3661 = r3659 * r3660;
        double r3662 = r3658 + r3661;
        double r3663 = t;
        double r3664 = r3663 * r3655;
        double r3665 = r3662 + r3664;
        double r3666 = b;
        double r3667 = r3660 * r3666;
        double r3668 = r3655 * r3667;
        double r3669 = r3665 + r3668;
        double r3670 = r3655 * r3660;
        double r3671 = r3670 * r3666;
        double r3672 = r3665 + r3671;
        double r3673 = r3657 ? r3669 : r3672;
        return r3673;
}

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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.1
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.071371100277623e+138

    1. Initial program 9.1

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

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

    if -1.071371100277623e+138 < a

    1. Initial program 1.6

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -1.071371100277623 \cdot 10^{138}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + a \cdot \left(z \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\\ \end{array}\]

Reproduce

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