Average Error: 2.0 → 0.2
Time: 12.1s
Precision: binary64
Cost: 1160
\[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
\[\begin{array}{l} \mathbf{if}\;a \leq -8.47331770737554 \cdot 10^{-45} \lor \neg \left(a \leq 2.676632411961761 \cdot 10^{-75}\right):\\ \;\;\;\;x + \left(z \cdot y + a \cdot \left(t + z \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot t + \left(x + z \cdot \left(y + a \cdot b\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}\;a \leq -8.47331770737554 \cdot 10^{-45} \lor \neg \left(a \leq 2.676632411961761 \cdot 10^{-75}\right):\\
\;\;\;\;x + \left(z \cdot y + a \cdot \left(t + z \cdot b\right)\right)\\

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

\end{array}
(FPCore (x y z t a b)
 :precision binary64
 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))
(FPCore (x y z t a b)
 :precision binary64
 (if (or (<= a -8.47331770737554e-45) (not (<= a 2.676632411961761e-75)))
   (+ x (+ (* z y) (* a (+ t (* z b)))))
   (+ (* a t) (+ x (* z (+ y (* a b)))))))
double code(double x, double y, double z, double t, double a, double b) {
	return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((a <= -8.47331770737554e-45) || !(a <= 2.676632411961761e-75)) {
		tmp = x + ((z * y) + (a * (t + (z * b))));
	} else {
		tmp = (a * t) + (x + (z * (y + (a * b))));
	}
	return tmp;
}

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.0
Target0.4
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;z < -1.1820553527347888 \cdot 10^{+19}:\\ \;\;\;\;z \cdot \left(b \cdot a + y\right) + \left(x + t \cdot a\right)\\ \mathbf{elif}\;z < 4.7589743188364287 \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}\]

Alternatives

Alternative 1
Error2.5
Cost1160
\[\begin{array}{l} \mathbf{if}\;z \leq -2.1230643997964132 \cdot 10^{-197} \lor \neg \left(z \leq 8.318023686747397 \cdot 10^{-188}\right):\\ \;\;\;\;a \cdot t + \left(x + z \cdot \left(y + a \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot t + \left(x + z \cdot y\right)\\ \end{array}\]
Alternative 2
Error8.9
Cost2181
\[\begin{array}{l} \mathbf{if}\;a \leq -6.8930790922360095 \cdot 10^{+152}:\\ \;\;\;\;x + a \cdot \left(t + z \cdot b\right)\\ \mathbf{elif}\;a \leq -2.6717041202288387 \cdot 10^{+101}:\\ \;\;\;\;z \cdot y + a \cdot \left(t + z \cdot b\right)\\ \mathbf{elif}\;a \leq -4.373758221644222 \cdot 10^{-22}:\\ \;\;\;\;x + a \cdot \left(t + z \cdot b\right)\\ \mathbf{elif}\;a \leq -6.299296492312375 \cdot 10^{-291}:\\ \;\;\;\;x + z \cdot \left(y + a \cdot b\right)\\ \mathbf{elif}\;a \leq 7.238714085294908 \cdot 10^{+58}:\\ \;\;\;\;a \cdot t + \left(x + z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x + a \cdot \left(t + z \cdot b\right)\\ \end{array}\]
Alternative 3
Error8.6
Cost1539
\[\begin{array}{l} \mathbf{if}\;a \leq -7.564774461131198 \cdot 10^{-23}:\\ \;\;\;\;x + a \cdot \left(t + z \cdot b\right)\\ \mathbf{elif}\;a \leq -3.652234854062094 \cdot 10^{-293}:\\ \;\;\;\;x + z \cdot \left(y + a \cdot b\right)\\ \mathbf{elif}\;a \leq 7.173571613651311 \cdot 10^{+64}:\\ \;\;\;\;a \cdot t + \left(x + z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x + a \cdot \left(t + z \cdot b\right)\\ \end{array}\]
Alternative 4
Error8.3
Cost904
\[\begin{array}{l} \mathbf{if}\;z \leq -8.133286699910391 \cdot 10^{+119} \lor \neg \left(z \leq 4.541560410564862 \cdot 10^{+82}\right):\\ \;\;\;\;x + z \cdot \left(y + a \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot t + \left(x + z \cdot y\right)\\ \end{array}\]
Alternative 5
Error10.5
Cost904
\[\begin{array}{l} \mathbf{if}\;t \leq 1.6082889250353312 \cdot 10^{-209} \lor \neg \left(t \leq 1.7972959645303482 \cdot 10^{-187}\right):\\ \;\;\;\;a \cdot t + \left(x + z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y + a \cdot b\right)\\ \end{array}\]
Alternative 6
Error21.1
Cost1411
\[\begin{array}{l} \mathbf{if}\;a \leq -5.312283232766349 \cdot 10^{-23}:\\ \;\;\;\;a \cdot \left(t + z \cdot b\right)\\ \mathbf{elif}\;a \leq 6.780882240567086 \cdot 10^{-238}:\\ \;\;\;\;x + z \cdot y\\ \mathbf{elif}\;a \leq 9.094974354333698 \cdot 10^{+77}:\\ \;\;\;\;x + a \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(t + z \cdot b\right)\\ \end{array}\]
Alternative 7
Error21.8
Cost1932
\[\begin{array}{l} \mathbf{if}\;a \leq -8.189215736993678 \cdot 10^{+157}:\\ \;\;\;\;x + a \cdot t\\ \mathbf{elif}\;a \leq -2.456909026928667 \cdot 10^{+101}:\\ \;\;\;\;z \cdot y + a \cdot t\\ \mathbf{elif}\;a \leq -4.4255821400711167 \cdot 10^{-23}:\\ \;\;\;\;x + a \cdot t\\ \mathbf{elif}\;a \leq 7.363587674465142 \cdot 10^{-238}:\\ \;\;\;\;x + z \cdot y\\ \mathbf{elif}\;a \leq 1.2352505870065415 \cdot 10^{+78} \lor \neg \left(a \leq 2.7126171027806673 \cdot 10^{+140}\right):\\ \;\;\;\;x + a \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(z \cdot b\right)\\ \end{array}\]
Alternative 8
Error21.6
Cost1290
\[\begin{array}{l} \mathbf{if}\;a \leq -6.114931831363238 \cdot 10^{-22}:\\ \;\;\;\;x + a \cdot t\\ \mathbf{elif}\;a \leq 7.363587674465142 \cdot 10^{-238}:\\ \;\;\;\;x + z \cdot y\\ \mathbf{elif}\;a \leq 1.1863088112867798 \cdot 10^{+78} \lor \neg \left(a \leq 2.9287769652737246 \cdot 10^{+140}\right):\\ \;\;\;\;x + a \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(z \cdot b\right)\\ \end{array}\]
Alternative 9
Error20.6
Cost648
\[\begin{array}{l} \mathbf{if}\;a \leq -4.632893299996056 \cdot 10^{-21} \lor \neg \left(a \leq 7.072234957516114 \cdot 10^{-238}\right):\\ \;\;\;\;x + a \cdot t\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot y\\ \end{array}\]
Alternative 10
Error24.8
Cost648
\[\begin{array}{l} \mathbf{if}\;a \leq -0.007294006378164435 \lor \neg \left(a \leq 1.1416021359785604 \cdot 10^{+151}\right):\\ \;\;\;\;a \cdot t\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot y\\ \end{array}\]
Alternative 11
Error32.9
Cost2118
\[\begin{array}{l} \mathbf{if}\;x \leq -7.1841344922596 \cdot 10^{-30}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.1975721068622777 \cdot 10^{-89}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;x \leq -1.832601650028201 \cdot 10^{-92}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.2248165631983694 \cdot 10^{-168}:\\ \;\;\;\;a \cdot t\\ \mathbf{elif}\;x \leq 5.260880275461012 \cdot 10^{-290}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;x \leq 9.851096892267522 \cdot 10^{+39}:\\ \;\;\;\;a \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]
Alternative 12
Error33.3
Cost834
\[\begin{array}{l} \mathbf{if}\;x \leq -4.050763059606233 \cdot 10^{-92}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.2680506541622528 \cdot 10^{+39}:\\ \;\;\;\;a \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]
Alternative 13
Error39.3
Cost64
\[x\]
Alternative 14
Error62.0
Cost64
\[-1\]
Alternative 15
Error62.0
Cost64
\[1\]

Error

Derivation

  1. Split input into 2 regimes
  2. if a < -8.47331770737554031e-45 or 2.676632411961761e-75 < a

    1. Initial program 3.7

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

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

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

    if -8.47331770737554031e-45 < a < 2.676632411961761e-75

    1. Initial program 0.4

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b\]
    2. Taylor expanded around 0 4.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \leq -8.47331770737554 \cdot 10^{-45} \lor \neg \left(a \leq 2.676632411961761 \cdot 10^{-75}\right):\\ \;\;\;\;x + \left(z \cdot y + a \cdot \left(t + z \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot t + \left(x + z \cdot \left(y + a \cdot b\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2021044 
(FPCore (x y z t a b)
  :name "Graphics.Rasterific.CubicBezier:cachedBezierAt from Rasterific-0.6.1"
  :precision binary64

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