Average Error: 2.1 → 4.0
Time: 14.8s
Precision: binary64
Cost: 1096
\[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
\[\begin{array}{l} t_1 := z \cdot \left(y + a \cdot b\right) + \left(x + t \cdot a\right)\\ \mathbf{if}\;t \leq -1.4637220511651103 \cdot 10^{-5}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.856297627304547 \cdot 10^{-252}:\\ \;\;\;\;y \cdot z + \left(x + a \cdot \left(z \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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
 (let* ((t_1 (+ (* z (+ y (* a b))) (+ x (* t a)))))
   (if (<= t -1.4637220511651103e-5)
     t_1
     (if (<= t -1.856297627304547e-252) (+ (* y z) (+ x (* a (* z b)))) t_1))))
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 t_1 = (z * (y + (a * b))) + (x + (t * a));
	double tmp;
	if (t <= -1.4637220511651103e-5) {
		tmp = t_1;
	} else if (t <= -1.856297627304547e-252) {
		tmp = (y * z) + (x + (a * (z * b)));
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = ((x + (y * z)) + (t * a)) + ((a * z) * b)
end function
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (z * (y + (a * b))) + (x + (t * a))
    if (t <= (-1.4637220511651103d-5)) then
        tmp = t_1
    else if (t <= (-1.856297627304547d-252)) then
        tmp = (y * z) + (x + (a * (z * b)))
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (z * (y + (a * b))) + (x + (t * a));
	double tmp;
	if (t <= -1.4637220511651103e-5) {
		tmp = t_1;
	} else if (t <= -1.856297627304547e-252) {
		tmp = (y * z) + (x + (a * (z * b)));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	return ((x + (y * z)) + (t * a)) + ((a * z) * b)
def code(x, y, z, t, a, b):
	t_1 = (z * (y + (a * b))) + (x + (t * a))
	tmp = 0
	if t <= -1.4637220511651103e-5:
		tmp = t_1
	elif t <= -1.856297627304547e-252:
		tmp = (y * z) + (x + (a * (z * b)))
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a, b)
	return Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b))
end
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(z * Float64(y + Float64(a * b))) + Float64(x + Float64(t * a)))
	tmp = 0.0
	if (t <= -1.4637220511651103e-5)
		tmp = t_1;
	elseif (t <= -1.856297627304547e-252)
		tmp = Float64(Float64(y * z) + Float64(x + Float64(a * Float64(z * b))));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp = code(x, y, z, t, a, b)
	tmp = ((x + (y * z)) + (t * a)) + ((a * z) * b);
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = (z * (y + (a * b))) + (x + (t * a));
	tmp = 0.0;
	if (t <= -1.4637220511651103e-5)
		tmp = t_1;
	elseif (t <= -1.856297627304547e-252)
		tmp = (y * z) + (x + (a * (z * b)));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(z * N[(y + N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x + N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -1.4637220511651103e-5], t$95$1, If[LessEqual[t, -1.856297627304547e-252], N[(N[(y * z), $MachinePrecision] + N[(x + N[(a * N[(z * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\begin{array}{l}
t_1 := z \cdot \left(y + a \cdot b\right) + \left(x + t \cdot a\right)\\
\mathbf{if}\;t \leq -1.4637220511651103 \cdot 10^{-5}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t \leq -1.856297627304547 \cdot 10^{-252}:\\
\;\;\;\;y \cdot z + \left(x + a \cdot \left(z \cdot b\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.1
Target0.3
Herbie4.0
\[\begin{array}{l} \mathbf{if}\;z < -11820553527347888000:\\ \;\;\;\;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} \]

Derivation

  1. Split input into 2 regimes
  2. if t < -1.4637220511651103e-5 or -1.85629762730454693e-252 < t

    1. Initial program 2.0

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

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

    if -1.4637220511651103e-5 < t < -1.85629762730454693e-252

    1. Initial program 2.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1.4637220511651103 \cdot 10^{-5}:\\ \;\;\;\;z \cdot \left(y + a \cdot b\right) + \left(x + t \cdot a\right)\\ \mathbf{elif}\;t \leq -1.856297627304547 \cdot 10^{-252}:\\ \;\;\;\;y \cdot z + \left(x + a \cdot \left(z \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y + a \cdot b\right) + \left(x + t \cdot a\right)\\ \end{array} \]

Alternatives

Alternative 1
Error1.2
Cost3016
\[\begin{array}{l} t_1 := \left(t \cdot a + \left(x + y \cdot z\right)\right) + \left(z \cdot a\right) \cdot b\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;z \cdot \left(y + a \cdot b\right) + \left(x + t \cdot a\right)\\ \mathbf{elif}\;t_1 \leq \infty:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(z \cdot b\right)\\ \end{array} \]
Alternative 2
Error22.5
Cost1768
\[\begin{array}{l} t_1 := x + y \cdot z\\ t_2 := t \cdot a + y \cdot z\\ t_3 := z \cdot \left(y + a \cdot b\right)\\ t_4 := x + t \cdot a\\ \mathbf{if}\;z \leq -1.9 \cdot 10^{+30}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -0.0028340895768170717:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.4624629237885058 \cdot 10^{-22}:\\ \;\;\;\;a \cdot \left(t + z \cdot b\right)\\ \mathbf{elif}\;z \leq -6.950156675137166 \cdot 10^{-68}:\\ \;\;\;\;x + \left(z \cdot a\right) \cdot b\\ \mathbf{elif}\;z \leq -3.6262116036236815 \cdot 10^{-91}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -7.363062941310546 \cdot 10^{-147}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;z \leq -5.820976346244592 \cdot 10^{-214}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 6.3392757371517026 \cdot 10^{-77}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;z \leq 3 \cdot 10^{+123}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{+201}:\\ \;\;\;\;x + a \cdot \left(z \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 3
Error22.8
Cost1636
\[\begin{array}{l} t_1 := x + y \cdot z\\ t_2 := t \cdot a + y \cdot z\\ t_3 := x + t \cdot a\\ \mathbf{if}\;z \leq -1.9 \cdot 10^{+30}:\\ \;\;\;\;z \cdot \left(y + a \cdot b\right)\\ \mathbf{elif}\;z \leq -0.0028340895768170717:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.4624629237885058 \cdot 10^{-22}:\\ \;\;\;\;a \cdot \left(t + z \cdot b\right)\\ \mathbf{elif}\;z \leq -6.950156675137166 \cdot 10^{-68}:\\ \;\;\;\;x + \left(z \cdot a\right) \cdot b\\ \mathbf{elif}\;z \leq -3.6262116036236815 \cdot 10^{-91}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -7.363062941310546 \cdot 10^{-147}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -5.820976346244592 \cdot 10^{-214}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 6.3392757371517026 \cdot 10^{-77}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 3 \cdot 10^{+123}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(a \cdot b\right)\\ \end{array} \]
Alternative 4
Error22.6
Cost1504
\[\begin{array}{l} t_1 := x + y \cdot z\\ t_2 := x + t \cdot a\\ t_3 := x + a \cdot \left(z \cdot b\right)\\ \mathbf{if}\;t \leq -7.6030415784995 \cdot 10^{+39}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -1.8052442541423586 \cdot 10^{+21}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -385373528822530050:\\ \;\;\;\;t \cdot a\\ \mathbf{elif}\;t \leq -1.466965972060633 \cdot 10^{-191}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 1.5580369987464485 \cdot 10^{-237}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.679994329274377 \cdot 10^{-104}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 5.765230016814161 \cdot 10^{-27}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.3965305626951928 \cdot 10^{+71}:\\ \;\;\;\;t \cdot a + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error22.0
Cost1504
\[\begin{array}{l} t_1 := x + y \cdot z\\ t_2 := z \cdot \left(y + a \cdot b\right)\\ t_3 := x + t \cdot a\\ \mathbf{if}\;z \leq -1.9 \cdot 10^{+30}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -0.0028340895768170717:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.801978966197514 \cdot 10^{-8}:\\ \;\;\;\;z \cdot \left(a \cdot b\right)\\ \mathbf{elif}\;z \leq -7.363062941310546 \cdot 10^{-147}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -5.820976346244592 \cdot 10^{-214}:\\ \;\;\;\;t \cdot a + y \cdot z\\ \mathbf{elif}\;z \leq 6.3392757371517026 \cdot 10^{-77}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 3 \cdot 10^{+123}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{+201}:\\ \;\;\;\;x + a \cdot \left(z \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error33.8
Cost1116
\[\begin{array}{l} \mathbf{if}\;x \leq -8.863191899706931 \cdot 10^{+52}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -7.363111200179054 \cdot 10^{+27}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;x \leq -6.499506491571345 \cdot 10^{-113}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.042917871466028 \cdot 10^{-238}:\\ \;\;\;\;t \cdot a\\ \mathbf{elif}\;x \leq 2.933725948432046 \cdot 10^{-98}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;x \leq 9.444562194570417 \cdot 10^{-69}:\\ \;\;\;\;t \cdot a\\ \mathbf{elif}\;x \leq 2.0113527231817214 \cdot 10^{+43}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error20.8
Cost976
\[\begin{array}{l} t_1 := t \cdot a + y \cdot z\\ t_2 := x + t \cdot a\\ \mathbf{if}\;x \leq -2.600896127997836 \cdot 10^{+54}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -3.039470356861945 \cdot 10^{+23}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -8.467391771131245 \cdot 10^{-60}:\\ \;\;\;\;a \cdot \left(z \cdot b\right)\\ \mathbf{elif}\;x \leq 2.0113527231817214 \cdot 10^{+43}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error13.9
Cost972
\[\begin{array}{l} t_1 := x + z \cdot \left(y + a \cdot b\right)\\ \mathbf{if}\;z \leq -5.870048260948902 \cdot 10^{-152}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5.820976346244592 \cdot 10^{-214}:\\ \;\;\;\;t \cdot a + y \cdot z\\ \mathbf{elif}\;z \leq 1.677715437472011 \cdot 10^{-96}:\\ \;\;\;\;x + t \cdot a\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error8.0
Cost968
\[\begin{array}{l} t_1 := \left(x + t \cdot a\right) + y \cdot z\\ \mathbf{if}\;t \leq -4.264095502311943 \cdot 10^{+42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.679994329274377 \cdot 10^{-104}:\\ \;\;\;\;y \cdot z + \left(x + a \cdot \left(z \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error8.4
Cost840
\[\begin{array}{l} t_1 := \left(x + t \cdot a\right) + y \cdot z\\ \mathbf{if}\;t \leq -4.264095502311943 \cdot 10^{+42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.3800061980030278 \cdot 10^{-67}:\\ \;\;\;\;x + z \cdot \left(y + a \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error26.0
Cost716
\[\begin{array}{l} t_1 := x + y \cdot z\\ \mathbf{if}\;a \leq -8409470.535571951:\\ \;\;\;\;t \cdot a\\ \mathbf{elif}\;a \leq 1.45 \cdot 10^{+42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 9.4 \cdot 10^{+111}:\\ \;\;\;\;t \cdot a\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error20.5
Cost584
\[\begin{array}{l} t_1 := x + t \cdot a\\ \mathbf{if}\;a \leq -4.153610336901004 \cdot 10^{-10}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.6304008924069853 \cdot 10^{-22}:\\ \;\;\;\;x + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error33.8
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -6.499506491571345 \cdot 10^{-113}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.89552208019858 \cdot 10^{+19}:\\ \;\;\;\;t \cdot a\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 14
Error40.1
Cost64
\[x \]

Error

Reproduce

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

  :herbie-target
  (if (< z -11820553527347888000.0) (+ (* 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)))