Average Error: 2.1 → 0.4
Time: 4.8s
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.07422854836868 \cdot 10^{-15} \lor \neg \left(z \le 2.9993001878202427 \cdot 10^{122}\right):\\ \;\;\;\;\mathsf{fma}\left(t \cdot 1, a, \mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t \cdot 1, a, a \cdot \left(z \cdot b\right) + \mathsf{fma}\left(z, y, x\right)\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.07422854836868 \cdot 10^{-15} \lor \neg \left(z \le 2.9993001878202427 \cdot 10^{122}\right):\\
\;\;\;\;\mathsf{fma}\left(t \cdot 1, a, \mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\right)\\

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

\end{array}
double code(double x, double y, double z, double t, double a, double b) {
	return ((double) (((double) (((double) (x + ((double) (y * z)))) + ((double) (t * a)))) + ((double) (((double) (a * z)) * b))));
}
double code(double x, double y, double z, double t, double a, double b) {
	double VAR;
	if (((z <= -1.0742285483686794e-15) || !(z <= 2.9993001878202427e+122))) {
		VAR = ((double) fma(((double) (t * 1.0)), a, ((double) fma(((double) fma(b, a, y)), z, x))));
	} else {
		VAR = ((double) fma(((double) (t * 1.0)), a, ((double) (((double) (a * ((double) (z * b)))) + ((double) fma(z, y, x))))));
	}
	return VAR;
}

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.4
\[\begin{array}{l} \mathbf{if}\;z \lt -11820553527347888000:\\ \;\;\;\;z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\ \mathbf{elif}\;z \lt 4.75897431883642871 \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.0742285483686794e-15 or 2.9993001878202427e+122 < z

    1. Initial program 5.6

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
    2. Using strategy rm
    3. Applied +-commutative5.6

      \[\leadsto \color{blue}{\left(t \cdot a + \left(x + y \cdot z\right)\right)} + \left(a \cdot z\right) \cdot b\]
    4. Applied associate-+l+5.6

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

      \[\leadsto t \cdot a + \color{blue}{\mathsf{fma}\left(a \cdot z, b, \mathsf{fma}\left(z, y, x\right)\right)}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity5.6

      \[\leadsto t \cdot \color{blue}{\left(1 \cdot a\right)} + \mathsf{fma}\left(a \cdot z, b, \mathsf{fma}\left(z, y, x\right)\right)\]
    8. Applied associate-*r*5.6

      \[\leadsto \color{blue}{\left(t \cdot 1\right) \cdot a} + \mathsf{fma}\left(a \cdot z, b, \mathsf{fma}\left(z, y, x\right)\right)\]
    9. Applied fma-def5.6

      \[\leadsto \color{blue}{\mathsf{fma}\left(t \cdot 1, a, \mathsf{fma}\left(a \cdot z, b, \mathsf{fma}\left(z, y, x\right)\right)\right)}\]
    10. Taylor expanded around inf 8.2

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

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

    if -1.0742285483686794e-15 < z < 2.9993001878202427e+122

    1. Initial program 0.7

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
    2. Using strategy rm
    3. Applied +-commutative0.7

      \[\leadsto \color{blue}{\left(t \cdot a + \left(x + y \cdot z\right)\right)} + \left(a \cdot z\right) \cdot b\]
    4. Applied associate-+l+0.7

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

      \[\leadsto t \cdot a + \color{blue}{\mathsf{fma}\left(a \cdot z, b, \mathsf{fma}\left(z, y, x\right)\right)}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity0.7

      \[\leadsto t \cdot \color{blue}{\left(1 \cdot a\right)} + \mathsf{fma}\left(a \cdot z, b, \mathsf{fma}\left(z, y, x\right)\right)\]
    8. Applied associate-*r*0.7

      \[\leadsto \color{blue}{\left(t \cdot 1\right) \cdot a} + \mathsf{fma}\left(a \cdot z, b, \mathsf{fma}\left(z, y, x\right)\right)\]
    9. Applied fma-def0.7

      \[\leadsto \color{blue}{\mathsf{fma}\left(t \cdot 1, a, \mathsf{fma}\left(a \cdot z, b, \mathsf{fma}\left(z, y, x\right)\right)\right)}\]
    10. Using strategy rm
    11. Applied fma-udef0.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.07422854836868 \cdot 10^{-15} \lor \neg \left(z \le 2.9993001878202427 \cdot 10^{122}\right):\\ \;\;\;\;\mathsf{fma}\left(t \cdot 1, a, \mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t \cdot 1, a, a \cdot \left(z \cdot b\right) + \mathsf{fma}\left(z, y, x\right)\right)\\ \end{array}\]

Reproduce

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