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

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r26053810 = x;
        double r26053811 = y;
        double r26053812 = z;
        double r26053813 = r26053811 * r26053812;
        double r26053814 = r26053810 + r26053813;
        double r26053815 = t;
        double r26053816 = a;
        double r26053817 = r26053815 * r26053816;
        double r26053818 = r26053814 + r26053817;
        double r26053819 = r26053816 * r26053812;
        double r26053820 = b;
        double r26053821 = r26053819 * r26053820;
        double r26053822 = r26053818 + r26053821;
        return r26053822;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r26053823 = a;
        double r26053824 = 1.648045334066036e-74;
        bool r26053825 = r26053823 <= r26053824;
        double r26053826 = b;
        double r26053827 = r26053826 * r26053823;
        double r26053828 = z;
        double r26053829 = r26053827 * r26053828;
        double r26053830 = t;
        double r26053831 = r26053823 * r26053830;
        double r26053832 = x;
        double r26053833 = y;
        double r26053834 = r26053833 * r26053828;
        double r26053835 = r26053832 + r26053834;
        double r26053836 = r26053831 + r26053835;
        double r26053837 = r26053829 + r26053836;
        double r26053838 = r26053828 * r26053826;
        double r26053839 = r26053838 + r26053830;
        double r26053840 = r26053823 * r26053839;
        double r26053841 = r26053840 + r26053835;
        double r26053842 = r26053825 ? r26053837 : r26053841;
        return r26053842;
}

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 -1.1820553527347888 \cdot 10^{+19}:\\ \;\;\;\;z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\ \mathbf{elif}\;z \lt 4.7589743188364287 \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.648045334066036e-74

    1. Initial program 1.5

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
    2. Using strategy rm
    3. Applied *-commutative1.5

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(z \cdot a\right)} \cdot b\]
    4. Applied associate-*l*1.8

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

    if 1.648045334066036e-74 < a

    1. Initial program 3.9

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
    2. Using strategy rm
    3. Applied *-commutative3.9

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(z \cdot a\right)} \cdot b\]
    4. Applied associate-*l*4.8

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{z \cdot \left(a \cdot b\right)}\]
    5. Using strategy rm
    6. Applied associate-+l+4.8

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

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

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

Reproduce

herbie shell --seed 2019158 
(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)))