Average Error: 2.1 → 1.2
Time: 15.0s
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.633099719810372038924919515496326271933 \cdot 10^{-76} \lor \neg \left(a \le 9.108876548869236631679254363644611836499 \cdot 10^{-243}\right):\\ \;\;\;\;a \cdot \left(t + z \cdot b\right) + \left(x + y \cdot z\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.633099719810372038924919515496326271933 \cdot 10^{-76} \lor \neg \left(a \le 9.108876548869236631679254363644611836499 \cdot 10^{-243}\right):\\
\;\;\;\;a \cdot \left(t + z \cdot b\right) + \left(x + y \cdot z\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 r400062 = x;
        double r400063 = y;
        double r400064 = z;
        double r400065 = r400063 * r400064;
        double r400066 = r400062 + r400065;
        double r400067 = t;
        double r400068 = a;
        double r400069 = r400067 * r400068;
        double r400070 = r400066 + r400069;
        double r400071 = r400068 * r400064;
        double r400072 = b;
        double r400073 = r400071 * r400072;
        double r400074 = r400070 + r400073;
        return r400074;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r400075 = a;
        double r400076 = -1.633099719810372e-76;
        bool r400077 = r400075 <= r400076;
        double r400078 = 9.108876548869237e-243;
        bool r400079 = r400075 <= r400078;
        double r400080 = !r400079;
        bool r400081 = r400077 || r400080;
        double r400082 = t;
        double r400083 = z;
        double r400084 = b;
        double r400085 = r400083 * r400084;
        double r400086 = r400082 + r400085;
        double r400087 = r400075 * r400086;
        double r400088 = x;
        double r400089 = y;
        double r400090 = r400089 * r400083;
        double r400091 = r400088 + r400090;
        double r400092 = r400087 + r400091;
        double r400093 = r400082 * r400075;
        double r400094 = r400091 + r400093;
        double r400095 = r400075 * r400083;
        double r400096 = r400095 * r400084;
        double r400097 = r400094 + r400096;
        double r400098 = r400081 ? r400092 : r400097;
        return r400098;
}

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
Herbie1.2
\[\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 a < -1.633099719810372e-76 or 9.108876548869237e-243 < a

    1. Initial program 2.8

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
    2. Simplified1.5

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

    if -1.633099719810372e-76 < a < 9.108876548869237e-243

    1. Initial program 0.5

      \[\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.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -1.633099719810372038924919515496326271933 \cdot 10^{-76} \lor \neg \left(a \le 9.108876548869236631679254363644611836499 \cdot 10^{-243}\right):\\ \;\;\;\;a \cdot \left(t + z \cdot b\right) + \left(x + y \cdot z\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 2019326 
(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)))