Average Error: 1.9 → 1.6
Time: 4.6s
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.6607943700588965 \cdot 10^{-190}:\\ \;\;\;\;\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.6607943700588965 \cdot 10^{-190}:\\
\;\;\;\;\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 r713636 = x;
        double r713637 = y;
        double r713638 = z;
        double r713639 = r713637 * r713638;
        double r713640 = r713636 + r713639;
        double r713641 = t;
        double r713642 = a;
        double r713643 = r713641 * r713642;
        double r713644 = r713640 + r713643;
        double r713645 = r713642 * r713638;
        double r713646 = b;
        double r713647 = r713645 * r713646;
        double r713648 = r713644 + r713647;
        return r713648;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r713649 = a;
        double r713650 = -1.6607943700588965e-190;
        bool r713651 = r713649 <= r713650;
        double r713652 = x;
        double r713653 = y;
        double r713654 = z;
        double r713655 = r713653 * r713654;
        double r713656 = r713652 + r713655;
        double r713657 = t;
        double r713658 = r713657 * r713649;
        double r713659 = r713656 + r713658;
        double r713660 = b;
        double r713661 = r713654 * r713660;
        double r713662 = r713649 * r713661;
        double r713663 = r713659 + r713662;
        double r713664 = r713649 * r713654;
        double r713665 = r713664 * r713660;
        double r713666 = r713659 + r713665;
        double r713667 = r713651 ? r713663 : r713666;
        return r713667;
}

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

Original1.9
Target0.4
Herbie1.6
\[\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.6607943700588965e-190

    1. Initial program 2.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 associate-*l*1.7

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

    if -1.6607943700588965e-190 < 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.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -1.6607943700588965 \cdot 10^{-190}:\\ \;\;\;\;\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 2020060 +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)))