Average Error: 2.0 → 0.5
Time: 16.7s
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 -2.711362632576514974545306133803088111513 \cdot 10^{101}:\\ \;\;\;\;a \cdot \mathsf{fma}\left(b, z, t\right) + \left(x + y \cdot z\right)\\ \mathbf{elif}\;a \le 1.389488629724143166693422139504604657007 \cdot 10^{-73}:\\ \;\;\;\;\mathsf{fma}\left(t, a, \mathsf{fma}\left(z, \mathsf{fma}\left(a, b, y\right), x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot \mathsf{fma}\left(b, z, 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 -2.711362632576514974545306133803088111513 \cdot 10^{101}:\\
\;\;\;\;a \cdot \mathsf{fma}\left(b, z, t\right) + \left(x + y \cdot z\right)\\

\mathbf{elif}\;a \le 1.389488629724143166693422139504604657007 \cdot 10^{-73}:\\
\;\;\;\;\mathsf{fma}\left(t, a, \mathsf{fma}\left(z, \mathsf{fma}\left(a, b, y\right), x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;a \cdot \mathsf{fma}\left(b, z, 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 r30633343 = x;
        double r30633344 = y;
        double r30633345 = z;
        double r30633346 = r30633344 * r30633345;
        double r30633347 = r30633343 + r30633346;
        double r30633348 = t;
        double r30633349 = a;
        double r30633350 = r30633348 * r30633349;
        double r30633351 = r30633347 + r30633350;
        double r30633352 = r30633349 * r30633345;
        double r30633353 = b;
        double r30633354 = r30633352 * r30633353;
        double r30633355 = r30633351 + r30633354;
        return r30633355;
}

double f(double x, double y, double z, double t, double a, double b) {
        double r30633356 = a;
        double r30633357 = -2.711362632576515e+101;
        bool r30633358 = r30633356 <= r30633357;
        double r30633359 = b;
        double r30633360 = z;
        double r30633361 = t;
        double r30633362 = fma(r30633359, r30633360, r30633361);
        double r30633363 = r30633356 * r30633362;
        double r30633364 = x;
        double r30633365 = y;
        double r30633366 = r30633365 * r30633360;
        double r30633367 = r30633364 + r30633366;
        double r30633368 = r30633363 + r30633367;
        double r30633369 = 1.3894886297241432e-73;
        bool r30633370 = r30633356 <= r30633369;
        double r30633371 = fma(r30633356, r30633359, r30633365);
        double r30633372 = fma(r30633360, r30633371, r30633364);
        double r30633373 = fma(r30633361, r30633356, r30633372);
        double r30633374 = r30633370 ? r30633373 : r30633368;
        double r30633375 = r30633358 ? r30633368 : r30633374;
        return r30633375;
}

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

Target

Original2.0
Target0.4
Herbie0.5
\[\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 < -2.711362632576515e+101 or 1.3894886297241432e-73 < a

    1. Initial program 4.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 associate-+l+4.5

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

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

    if -2.711362632576515e+101 < a < 1.3894886297241432e-73

    1. Initial program 0.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -2.711362632576514974545306133803088111513 \cdot 10^{101}:\\ \;\;\;\;a \cdot \mathsf{fma}\left(b, z, t\right) + \left(x + y \cdot z\right)\\ \mathbf{elif}\;a \le 1.389488629724143166693422139504604657007 \cdot 10^{-73}:\\ \;\;\;\;\mathsf{fma}\left(t, a, \mathsf{fma}\left(z, \mathsf{fma}\left(a, b, y\right), x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot \mathsf{fma}\left(b, z, t\right) + \left(x + y \cdot z\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019192 +o rules:numerics
(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)))