Average Error: 2.1 → 0.1
Time: 16.5s
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}\;z \le -1.331555354802320444554982695754726880718 \cdot 10^{-57} \lor \neg \left(z \le 9.400476948445345631352833710421242680216 \cdot 10^{-34}\right):\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot b\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + a \cdot \left(b \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}\;z \le -1.331555354802320444554982695754726880718 \cdot 10^{-57} \lor \neg \left(z \le 9.400476948445345631352833710421242680216 \cdot 10^{-34}\right):\\
\;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot b\right) \cdot z\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b) {
        double r451873 = x;
        double r451874 = y;
        double r451875 = z;
        double r451876 = r451874 * r451875;
        double r451877 = r451873 + r451876;
        double r451878 = t;
        double r451879 = a;
        double r451880 = r451878 * r451879;
        double r451881 = r451877 + r451880;
        double r451882 = r451879 * r451875;
        double r451883 = b;
        double r451884 = r451882 * r451883;
        double r451885 = r451881 + r451884;
        return r451885;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r451886 = z;
        double r451887 = -1.3315553548023204e-57;
        bool r451888 = r451886 <= r451887;
        double r451889 = 9.400476948445346e-34;
        bool r451890 = r451886 <= r451889;
        double r451891 = !r451890;
        bool r451892 = r451888 || r451891;
        double r451893 = x;
        double r451894 = y;
        double r451895 = r451894 * r451886;
        double r451896 = r451893 + r451895;
        double r451897 = t;
        double r451898 = a;
        double r451899 = r451897 * r451898;
        double r451900 = r451896 + r451899;
        double r451901 = b;
        double r451902 = r451898 * r451901;
        double r451903 = r451902 * r451886;
        double r451904 = r451900 + r451903;
        double r451905 = r451901 * r451886;
        double r451906 = r451898 * r451905;
        double r451907 = r451900 + r451906;
        double r451908 = r451892 ? r451904 : r451907;
        return r451908;
}

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.3
Herbie0.1
\[\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 z < -1.3315553548023204e-57 or 9.400476948445346e-34 < z

    1. Initial program 4.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*6.0

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

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

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

    if -1.3315553548023204e-57 < z < 9.400476948445346e-34

    1. Initial program 0.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*0.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.331555354802320444554982695754726880718 \cdot 10^{-57} \lor \neg \left(z \le 9.400476948445345631352833710421242680216 \cdot 10^{-34}\right):\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot b\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + y \cdot z\right) + t \cdot a\right) + a \cdot \left(b \cdot z\right)\\ \end{array}\]

Reproduce

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