Average Error: 6.1 → 1.3
Time: 22.2s
Precision: binary64
Cost: 8648
\[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \]
\[\begin{array}{l} t_1 := 2 \cdot \left(t \cdot z - \left(c \cdot \left(b \cdot \left(c \cdot i\right)\right) + c \cdot \left(a \cdot i\right)\right)\right)\\ t_2 := c \cdot \left(a + b \cdot c\right)\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+264}:\\ \;\;\;\;2 \cdot \left(\left(t \cdot z + x \cdot y\right) - \frac{i}{\frac{\frac{1}{\mathsf{fma}\left(c, b, a\right)}}{c}}\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))
(FPCore (x y z t a b c i)
 :precision binary64
 (let* ((t_1 (* 2.0 (- (* t z) (+ (* c (* b (* c i))) (* c (* a i))))))
        (t_2 (* c (+ a (* b c)))))
   (if (<= t_2 (- INFINITY))
     t_1
     (if (<= t_2 5e+264)
       (* 2.0 (- (+ (* t z) (* x y)) (/ i (/ (/ 1.0 (fma c b a)) c))))
       t_1))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = 2.0 * ((t * z) - ((c * (b * (c * i))) + (c * (a * i))));
	double t_2 = c * (a + (b * c));
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_2 <= 5e+264) {
		tmp = 2.0 * (((t * z) + (x * y)) - (i / ((1.0 / fma(c, b, a)) / c)));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a, b, c, i)
	return Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(Float64(Float64(a + Float64(b * c)) * c) * i)))
end
function code(x, y, z, t, a, b, c, i)
	t_1 = Float64(2.0 * Float64(Float64(t * z) - Float64(Float64(c * Float64(b * Float64(c * i))) + Float64(c * Float64(a * i)))))
	t_2 = Float64(c * Float64(a + Float64(b * c)))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_2 <= 5e+264)
		tmp = Float64(2.0 * Float64(Float64(Float64(t * z) + Float64(x * y)) - Float64(i / Float64(Float64(1.0 / fma(c, b, a)) / c))));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(2.0 * N[(N[(t * z), $MachinePrecision] - N[(N[(c * N[(b * N[(c * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c * N[(a * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(c * N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 5e+264], N[(2.0 * N[(N[(N[(t * z), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision] - N[(i / N[(N[(1.0 / N[(c * b + a), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
\begin{array}{l}
t_1 := 2 \cdot \left(t \cdot z - \left(c \cdot \left(b \cdot \left(c \cdot i\right)\right) + c \cdot \left(a \cdot i\right)\right)\right)\\
t_2 := c \cdot \left(a + b \cdot c\right)\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+264}:\\
\;\;\;\;2 \cdot \left(\left(t \cdot z + x \cdot y\right) - \frac{i}{\frac{\frac{1}{\mathsf{fma}\left(c, b, a\right)}}{c}}\right)\\

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


\end{array}

Error

Target

Original6.1
Target1.8
Herbie1.3
\[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(a + b \cdot c\right) \cdot \left(c \cdot i\right)\right) \]

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 (+.f64 a (*.f64 b c)) c) < -inf.0 or 5.00000000000000033e264 < (*.f64 (+.f64 a (*.f64 b c)) c)

    1. Initial program 55.9

      \[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \]
    2. Applied egg-rr10.3

      \[\leadsto 2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \color{blue}{{\left(\sqrt[3]{c \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot i\right)}\right)}^{3}}\right) \]
    3. Taylor expanded in i around 0 10.3

      \[\leadsto 2 \cdot \left(\left(x \cdot y + z \cdot t\right) - {\left(\sqrt[3]{\color{blue}{c \cdot \left(i \cdot \left(c \cdot b + a\right)\right)}}\right)}^{3}\right) \]
    4. Applied egg-rr0.3

      \[\leadsto 2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \color{blue}{\left(\left(b \cdot \left(c \cdot i\right)\right) \cdot c + \left(i \cdot a\right) \cdot c\right)}\right) \]
    5. Taylor expanded in x around 0 8.9

      \[\leadsto 2 \cdot \left(\color{blue}{t \cdot z} - \left(\left(b \cdot \left(c \cdot i\right)\right) \cdot c + \left(i \cdot a\right) \cdot c\right)\right) \]

    if -inf.0 < (*.f64 (+.f64 a (*.f64 b c)) c) < 5.00000000000000033e264

    1. Initial program 0.4

      \[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \]
    2. Applied egg-rr17.9

      \[\leadsto 2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \color{blue}{\frac{c \cdot \left(a \cdot a - {\left(b \cdot c\right)}^{2}\right)}{a - b \cdot c}} \cdot i\right) \]
    3. Applied egg-rr0.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \cdot \left(a + b \cdot c\right) \leq -\infty:\\ \;\;\;\;2 \cdot \left(t \cdot z - \left(c \cdot \left(b \cdot \left(c \cdot i\right)\right) + c \cdot \left(a \cdot i\right)\right)\right)\\ \mathbf{elif}\;c \cdot \left(a + b \cdot c\right) \leq 5 \cdot 10^{+264}:\\ \;\;\;\;2 \cdot \left(\left(t \cdot z + x \cdot y\right) - \frac{i}{\frac{\frac{1}{\mathsf{fma}\left(c, b, a\right)}}{c}}\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(t \cdot z - \left(c \cdot \left(b \cdot \left(c \cdot i\right)\right) + c \cdot \left(a \cdot i\right)\right)\right)\\ \end{array} \]

Alternatives

Alternative 1
Error7.0
Cost9936
\[\begin{array}{l} t_1 := \left(c \cdot \left(a + b \cdot c\right)\right) \cdot i\\ t_2 := 2 \cdot \left(t \cdot z - t_1\right)\\ t_3 := c \cdot \left(b \cdot \left(c \cdot i\right)\right)\\ \mathbf{if}\;t_1 \leq -4 \cdot 10^{+287}:\\ \;\;\;\;2 \cdot \left(t \cdot z - \left(t_3 + c \cdot \left(a \cdot i\right)\right)\right)\\ \mathbf{elif}\;t_1 \leq -5 \cdot 10^{+114}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 4000000000000:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, t \cdot z - a \cdot \left(c \cdot i\right)\right)\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+277}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, t \cdot z - t_3\right)\\ \end{array} \]
Alternative 2
Error6.6
Cost9164
\[\begin{array}{l} t_1 := 2 \cdot \left(t \cdot z - \left(c \cdot \left(b \cdot \left(c \cdot i\right)\right) + c \cdot \left(a \cdot i\right)\right)\right)\\ t_2 := \left(c \cdot \left(a + b \cdot c\right)\right) \cdot i\\ t_3 := 2 \cdot \left(t \cdot z - t_2\right)\\ \mathbf{if}\;t_2 \leq -4 \cdot 10^{+287}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq -5 \cdot 10^{+114}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq 4000000000000:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, t \cdot z - a \cdot \left(c \cdot i\right)\right)\\ \mathbf{elif}\;t_2 \leq 4 \cdot 10^{+286}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error8.9
Cost8780
\[\begin{array}{l} t_1 := 2 \cdot \left(t \cdot z - \left(c \cdot \left(b \cdot \left(c \cdot i\right)\right) + c \cdot \left(a \cdot i\right)\right)\right)\\ t_2 := \left(c \cdot \left(a + b \cdot c\right)\right) \cdot i\\ t_3 := 2 \cdot \left(t \cdot z - t_2\right)\\ \mathbf{if}\;t_2 \leq -4 \cdot 10^{+287}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq -2 \cdot 10^{-10}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq 4000000000000:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, t \cdot z\right)\\ \mathbf{elif}\;t_2 \leq 4 \cdot 10^{+286}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error8.9
Cost3792
\[\begin{array}{l} t_1 := 2 \cdot \left(t \cdot z - \left(c \cdot \left(b \cdot \left(c \cdot i\right)\right) + c \cdot \left(a \cdot i\right)\right)\right)\\ t_2 := \left(c \cdot \left(a + b \cdot c\right)\right) \cdot i\\ t_3 := 2 \cdot \left(t \cdot z - t_2\right)\\ \mathbf{if}\;t_2 \leq -4 \cdot 10^{+287}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq -2 \cdot 10^{-10}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq 4000000000000:\\ \;\;\;\;2 \cdot \left(t \cdot z + x \cdot y\right)\\ \mathbf{elif}\;t_2 \leq 4 \cdot 10^{+286}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error10.0
Cost3536
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := \left(c \cdot t_1\right) \cdot i\\ t_3 := 2 \cdot \left(t \cdot z - t_2\right)\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;2 \cdot \left(t \cdot z - c \cdot \left(c \cdot \left(b \cdot i\right)\right)\right)\\ \mathbf{elif}\;t_2 \leq -2 \cdot 10^{-10}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq 4000000000000:\\ \;\;\;\;2 \cdot \left(t \cdot z + x \cdot y\right)\\ \mathbf{elif}\;t_2 \leq 4 \cdot 10^{+286}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(t \cdot z - c \cdot \left(t_1 \cdot i\right)\right)\\ \end{array} \]
Alternative 6
Error18.1
Cost1884
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y - i \cdot \left(a \cdot c\right)\right)\\ t_2 := 2 \cdot \left(t \cdot z - c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)\right)\\ t_3 := 2 \cdot \left(t \cdot z + x \cdot y\right)\\ \mathbf{if}\;c \leq -8.2 \cdot 10^{-29}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -4.197398061787405 \cdot 10^{-135}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -4.309226070735741 \cdot 10^{-160}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -1.984449487175986 \cdot 10^{-195}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.850204756827436 \cdot 10^{-204}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 1.2064372110878135 \cdot 10^{-136}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 3.913805027947862 \cdot 10^{-79}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error22.9
Cost1628
\[\begin{array}{l} t_1 := 2 \cdot \left(t \cdot z + x \cdot y\right)\\ t_2 := \left(c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)\right) \cdot -2\\ t_3 := 2 \cdot \left(x \cdot y - i \cdot \left(a \cdot c\right)\right)\\ \mathbf{if}\;z \leq -7.8 \cdot 10^{+57}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.58593856817749 \cdot 10^{+30}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -5.365912491106748 \cdot 10^{-32}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.2106288143668117 \cdot 10^{-75}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -6.897065752762456 \cdot 10^{-151}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.771404663125861 \cdot 10^{-265}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 3.344883570490363 \cdot 10^{-234}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error37.2
Cost1244
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y\right)\\ t_2 := 2 \cdot \left(t \cdot z\right)\\ t_3 := \left(i \cdot \left(a \cdot c\right)\right) \cdot -2\\ \mathbf{if}\;z \leq -3.8 \cdot 10^{+123}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.15 \cdot 10^{+94}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.7 \cdot 10^{+45}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -3.58593856817749 \cdot 10^{+30}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -1.30759128785578 \cdot 10^{-214}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -6.491854672573744 \cdot 10^{-244}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 1.951903396255144 \cdot 10^{-131}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Error37.2
Cost1244
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y\right)\\ t_2 := 2 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;z \leq -3.8 \cdot 10^{+123}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.15 \cdot 10^{+94}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.7 \cdot 10^{+45}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -3.58593856817749 \cdot 10^{+30}:\\ \;\;\;\;\left(c \cdot i\right) \cdot \left(a \cdot -2\right)\\ \mathbf{elif}\;z \leq -1.30759128785578 \cdot 10^{-214}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -6.491854672573744 \cdot 10^{-244}:\\ \;\;\;\;\left(i \cdot \left(a \cdot c\right)\right) \cdot -2\\ \mathbf{elif}\;z \leq 1.951903396255144 \cdot 10^{-131}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 10
Error23.4
Cost1104
\[\begin{array}{l} t_1 := 2 \cdot \left(t \cdot z + x \cdot y\right)\\ \mathbf{if}\;z \leq -2.7 \cdot 10^{+45}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.58593856817749 \cdot 10^{+30}:\\ \;\;\;\;\left(c \cdot i\right) \cdot \left(a \cdot -2\right)\\ \mathbf{elif}\;z \leq -1.30759128785578 \cdot 10^{-214}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -6.491854672573744 \cdot 10^{-244}:\\ \;\;\;\;\left(i \cdot \left(a \cdot c\right)\right) \cdot -2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error22.7
Cost968
\[\begin{array}{l} \mathbf{if}\;c \leq -1.7 \cdot 10^{+83}:\\ \;\;\;\;c \cdot \left(b \cdot \left(i \cdot \left(c \cdot -2\right)\right)\right)\\ \mathbf{elif}\;c \leq 3.913805027947862 \cdot 10^{-79}:\\ \;\;\;\;2 \cdot \left(t \cdot z + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(t \cdot z - c \cdot \left(a \cdot i\right)\right)\\ \end{array} \]
Alternative 12
Error21.7
Cost968
\[\begin{array}{l} \mathbf{if}\;c \leq -1.25 \cdot 10^{+36}:\\ \;\;\;\;\left(c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)\right) \cdot -2\\ \mathbf{elif}\;c \leq 3.913805027947862 \cdot 10^{-79}:\\ \;\;\;\;2 \cdot \left(t \cdot z + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(t \cdot z - c \cdot \left(a \cdot i\right)\right)\\ \end{array} \]
Alternative 13
Error36.4
Cost848
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y\right)\\ t_2 := 2 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;t \leq -3.512294892352042 \cdot 10^{-30}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 97505.87658007017:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.891258135971632 \cdot 10^{+74}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 2.6 \cdot 10^{+162}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 14
Error22.0
Cost708
\[\begin{array}{l} \mathbf{if}\;c \leq -1.7 \cdot 10^{+83}:\\ \;\;\;\;c \cdot \left(b \cdot \left(i \cdot \left(c \cdot -2\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(t \cdot z + x \cdot y\right)\\ \end{array} \]
Alternative 15
Error42.6
Cost320
\[2 \cdot \left(x \cdot y\right) \]

Error

Reproduce

herbie shell --seed 2022325 
(FPCore (x y z t a b c i)
  :name "Diagrams.ThreeD.Shapes:frustum from diagrams-lib-1.3.0.3, A"
  :precision binary64

  :herbie-target
  (* 2.0 (- (+ (* x y) (* z t)) (* (+ a (* b c)) (* c i))))

  (* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))