Average Error: 2.1 → 0.1
Time: 18.1s
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 r463006 = x;
        double r463007 = y;
        double r463008 = z;
        double r463009 = r463007 * r463008;
        double r463010 = r463006 + r463009;
        double r463011 = t;
        double r463012 = a;
        double r463013 = r463011 * r463012;
        double r463014 = r463010 + r463013;
        double r463015 = r463012 * r463008;
        double r463016 = b;
        double r463017 = r463015 * r463016;
        double r463018 = r463014 + r463017;
        return r463018;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r463019 = z;
        double r463020 = -1.3315553548023204e-57;
        bool r463021 = r463019 <= r463020;
        double r463022 = 9.400476948445346e-34;
        bool r463023 = r463019 <= r463022;
        double r463024 = !r463023;
        bool r463025 = r463021 || r463024;
        double r463026 = x;
        double r463027 = y;
        double r463028 = r463027 * r463019;
        double r463029 = r463026 + r463028;
        double r463030 = t;
        double r463031 = a;
        double r463032 = r463030 * r463031;
        double r463033 = r463029 + r463032;
        double r463034 = b;
        double r463035 = r463031 * r463034;
        double r463036 = r463035 * r463019;
        double r463037 = r463033 + r463036;
        double r463038 = r463034 * r463019;
        double r463039 = r463031 * r463038;
        double r463040 = r463033 + r463039;
        double r463041 = r463025 ? r463037 : r463040;
        return r463041;
}

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)))