Average Error: 2.1 → 0.1
Time: 17.4s
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 r543362 = x;
        double r543363 = y;
        double r543364 = z;
        double r543365 = r543363 * r543364;
        double r543366 = r543362 + r543365;
        double r543367 = t;
        double r543368 = a;
        double r543369 = r543367 * r543368;
        double r543370 = r543366 + r543369;
        double r543371 = r543368 * r543364;
        double r543372 = b;
        double r543373 = r543371 * r543372;
        double r543374 = r543370 + r543373;
        return r543374;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r543375 = z;
        double r543376 = -1.3315553548023204e-57;
        bool r543377 = r543375 <= r543376;
        double r543378 = 9.400476948445346e-34;
        bool r543379 = r543375 <= r543378;
        double r543380 = !r543379;
        bool r543381 = r543377 || r543380;
        double r543382 = x;
        double r543383 = y;
        double r543384 = r543383 * r543375;
        double r543385 = r543382 + r543384;
        double r543386 = t;
        double r543387 = a;
        double r543388 = r543386 * r543387;
        double r543389 = r543385 + r543388;
        double r543390 = b;
        double r543391 = r543387 * r543390;
        double r543392 = r543391 * r543375;
        double r543393 = r543389 + r543392;
        double r543394 = r543390 * r543375;
        double r543395 = r543387 * r543394;
        double r543396 = r543389 + r543395;
        double r543397 = r543381 ? r543393 : r543396;
        return r543397;
}

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