Average Error: 6.0 → 1.6
Time: 41.7s
Precision: binary64
Cost: 14792
\[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 := c \cdot \left(a + b \cdot c\right)\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;2 \cdot \left(x \cdot y - \left(a \cdot \left(c \cdot i\right) + \left(c \cdot i\right) \cdot \left(b \cdot c\right)\right)\right)\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+164}:\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - i \cdot t_1\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - c \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot i\right)\right)\\ \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 (* c (+ a (* b c)))))
   (if (<= t_1 (- INFINITY))
     (* 2.0 (- (* x y) (+ (* a (* c i)) (* (* c i) (* b c)))))
     (if (<= t_1 2e+164)
       (* 2.0 (- (+ (* x y) (* z t)) (* i t_1)))
       (* 2.0 (fma y x (- (* z t) (* c (* (fma b c a) i)))))))))
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 = c * (a + (b * c));
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = 2.0 * ((x * y) - ((a * (c * i)) + ((c * i) * (b * c))));
	} else if (t_1 <= 2e+164) {
		tmp = 2.0 * (((x * y) + (z * t)) - (i * t_1));
	} else {
		tmp = 2.0 * fma(y, x, ((z * t) - (c * (fma(b, c, a) * i))));
	}
	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(c * Float64(a + Float64(b * c)))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(2.0 * Float64(Float64(x * y) - Float64(Float64(a * Float64(c * i)) + Float64(Float64(c * i) * Float64(b * c)))));
	elseif (t_1 <= 2e+164)
		tmp = Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(i * t_1)));
	else
		tmp = Float64(2.0 * fma(y, x, Float64(Float64(z * t) - Float64(c * Float64(fma(b, c, a) * i)))));
	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[(c * N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(2.0 * N[(N[(x * y), $MachinePrecision] - N[(N[(a * N[(c * i), $MachinePrecision]), $MachinePrecision] + N[(N[(c * i), $MachinePrecision] * N[(b * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+164], N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(i * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(y * x + N[(N[(z * t), $MachinePrecision] - N[(c * N[(N[(b * c + a), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
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 := c \cdot \left(a + b \cdot c\right)\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;2 \cdot \left(x \cdot y - \left(a \cdot \left(c \cdot i\right) + \left(c \cdot i\right) \cdot \left(b \cdot c\right)\right)\right)\\

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+164}:\\
\;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - i \cdot t_1\right)\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - c \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot i\right)\right)\\


\end{array}

Error

Target

Original6.0
Target2.0
Herbie1.6
\[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 3 regimes
  2. if (*.f64 (+.f64 a (*.f64 b c)) c) < -inf.0

    1. Initial program 64.0

      \[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-rr12.1

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

      \[\leadsto 2 \cdot \color{blue}{\left(y \cdot x - c \cdot \left(i \cdot \left(c \cdot b + a\right)\right)\right)} \]
    4. Applied egg-rr17.5

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

    if -inf.0 < (*.f64 (+.f64 a (*.f64 b c)) c) < 2e164

    1. Initial program 0.3

      \[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \]

    if 2e164 < (*.f64 (+.f64 a (*.f64 b c)) c)

    1. Initial program 26.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-rr5.3

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

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

Alternatives

Alternative 1
Error2.0
Cost20096
\[2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(\mathsf{fma}\left(b, c, a\right), c \cdot \left(-i\right), x \cdot y\right)\right) \]
Alternative 2
Error2.0
Cost2248
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := c \cdot t_1\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;2 \cdot \left(x \cdot y - \left(a \cdot \left(c \cdot i\right) + \left(c \cdot i\right) \cdot \left(b \cdot c\right)\right)\right)\\ \mathbf{elif}\;t_2 \leq 10^{+261}:\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - i \cdot t_2\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t - c \cdot \left(i \cdot t_1\right)\right)\\ \end{array} \]
Alternative 3
Error23.5
Cost1760
\[\begin{array}{l} t_1 := \left(c \cdot \left(i \cdot \left(a + b \cdot c\right)\right)\right) \cdot -2\\ t_2 := 2 \cdot \left(x \cdot y - i \cdot \left(c \cdot a\right)\right)\\ t_3 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{if}\;t \leq -2.1583171234143344 \cdot 10^{-172}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -1.7627241649990088 \cdot 10^{-240}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.9549787125208428 \cdot 10^{-300}:\\ \;\;\;\;2 \cdot \left(x \cdot y - i \cdot \left(c \cdot \left(b \cdot c\right)\right)\right)\\ \mathbf{elif}\;t \leq 6.065356461762274 \cdot 10^{-64}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 0.051313246165105186:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 1106865966.6923602:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 8.764418265068039 \cdot 10^{+54}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 3.8 \cdot 10^{+99}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 4
Error8.7
Cost1736
\[\begin{array}{l} t_1 := 2 \cdot \left(\left(x \cdot y + z \cdot t\right) - i \cdot \left(c \cdot a\right)\right)\\ \mathbf{if}\;z \cdot t \leq -1 \cdot 10^{-93}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \cdot t \leq 4 \cdot 10^{-137}:\\ \;\;\;\;2 \cdot \left(x \cdot y - \left(a \cdot \left(c \cdot i\right) + \left(c \cdot i\right) \cdot \left(b \cdot c\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error26.1
Cost1624
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{if}\;b \leq -1.4 \cdot 10^{+204}:\\ \;\;\;\;2 \cdot \left(x \cdot y - i \cdot \left(c \cdot \left(b \cdot c\right)\right)\right)\\ \mathbf{elif}\;b \leq -2.4995178169016874 \cdot 10^{-9}:\\ \;\;\;\;2 \cdot \left(x \cdot y - i \cdot \left(c \cdot a\right)\right)\\ \mathbf{elif}\;b \leq -1.5177290755997318 \cdot 10^{-279}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 1.0511562209163823 \cdot 10^{-230}:\\ \;\;\;\;2 \cdot \left(z \cdot t - c \cdot \left(a \cdot i\right)\right)\\ \mathbf{elif}\;b \leq 11547989390216786000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 1.02 \cdot 10^{+74}:\\ \;\;\;\;2 \cdot \left(x \cdot y - \left(c \cdot i\right) \cdot \left(b \cdot c\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error10.8
Cost1620
\[\begin{array}{l} t_1 := x \cdot y + z \cdot t\\ t_2 := 2 \cdot \left(t_1 - i \cdot \left(c \cdot a\right)\right)\\ \mathbf{if}\;c \leq -3.9 \cdot 10^{-14}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -2.35 \cdot 10^{-42}:\\ \;\;\;\;2 \cdot \left(t_1 - i \cdot \left(c \cdot \left(b \cdot c\right)\right)\right)\\ \mathbf{elif}\;c \leq 6.7 \cdot 10^{-43}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 2.65 \cdot 10^{+76}:\\ \;\;\;\;2 \cdot \left(t_1 - \left(c \cdot c\right) \cdot \left(b \cdot i\right)\right)\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{+85}:\\ \;\;\;\;2 \cdot \left(x \cdot y - c \cdot \left(a \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t - c \cdot \left(i \cdot \left(a + b \cdot c\right)\right)\right)\\ \end{array} \]
Alternative 7
Error18.6
Cost1496
\[\begin{array}{l} t_1 := c \cdot \left(i \cdot \left(a + b \cdot c\right)\right)\\ t_2 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{if}\;t \leq -7.661648913068308 \cdot 10^{-106}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.6797099297526677 \cdot 10^{-28}:\\ \;\;\;\;2 \cdot \left(x \cdot y - t_1\right)\\ \mathbf{elif}\;t \leq 0.051313246165105186:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1106865966.6923602:\\ \;\;\;\;t_1 \cdot -2\\ \mathbf{elif}\;t \leq 8.764418265068039 \cdot 10^{+54}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 3.8 \cdot 10^{+99}:\\ \;\;\;\;2 \cdot \left(x \cdot y - i \cdot \left(c \cdot a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error18.2
Cost1488
\[\begin{array}{l} t_1 := 2 \cdot \left(z \cdot t - c \cdot \left(i \cdot \left(a + b \cdot c\right)\right)\right)\\ t_2 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{if}\;x \leq -1.7256088940803232 \cdot 10^{+25}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.3305574602180974:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.099438297702959 \cdot 10^{-89}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 3.598272352614425 \cdot 10^{-61}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Error10.6
Cost1480
\[\begin{array}{l} t_1 := 2 \cdot \left(\left(x \cdot y + z \cdot t\right) - i \cdot \left(c \cdot a\right)\right)\\ \mathbf{if}\;z \cdot t \leq -2 \cdot 10^{-318}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \cdot t \leq 4 \cdot 10^{-137}:\\ \;\;\;\;2 \cdot \left(x \cdot y - c \cdot \left(i \cdot \left(a + b \cdot c\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error38.3
Cost1236
\[\begin{array}{l} t_1 := 2 \cdot \left(z \cdot t\right)\\ t_2 := 2 \cdot \left(x \cdot y\right)\\ \mathbf{if}\;t \leq -3.403165837863062 \cdot 10^{-119}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -7.338723494049035 \cdot 10^{-258}:\\ \;\;\;\;a \cdot \left(\left(c \cdot i\right) \cdot -2\right)\\ \mathbf{elif}\;t \leq 2.5989306199548694 \cdot 10^{-20}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.76 \cdot 10^{+74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.4 \cdot 10^{+113}:\\ \;\;\;\;-1 + \left(t_2 + 1\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error22.8
Cost1100
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ t_2 := 2 \cdot \left(x \cdot y - i \cdot \left(c \cdot a\right)\right)\\ \mathbf{if}\;a \leq -1.2319773674839672 \cdot 10^{+59}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 2.3102417464438626 \cdot 10^{+25}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 4.5370432968666767 \cdot 10^{+108}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error38.3
Cost980
\[\begin{array}{l} t_1 := 2 \cdot \left(z \cdot t\right)\\ t_2 := 2 \cdot \left(x \cdot y\right)\\ \mathbf{if}\;t \leq -3.403165837863062 \cdot 10^{-119}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -7.338723494049035 \cdot 10^{-258}:\\ \;\;\;\;a \cdot \left(\left(c \cdot i\right) \cdot -2\right)\\ \mathbf{elif}\;t \leq 2.5989306199548694 \cdot 10^{-20}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.76 \cdot 10^{+74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.4 \cdot 10^{+113}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error21.6
Cost968
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{if}\;x \leq -1.5301311331213858 \cdot 10^{-172}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7.648767480294881 \cdot 10^{-177}:\\ \;\;\;\;2 \cdot \left(z \cdot t - c \cdot \left(a \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 14
Error36.7
Cost848
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y\right)\\ t_2 := 2 \cdot \left(z \cdot t\right)\\ \mathbf{if}\;t \leq -5.494747573546533 \cdot 10^{-94}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 2.5989306199548694 \cdot 10^{-20}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.76 \cdot 10^{+74}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.4 \cdot 10^{+113}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 15
Error23.5
Cost708
\[\begin{array}{l} \mathbf{if}\;i \leq -5.3 \cdot 10^{+185}:\\ \;\;\;\;a \cdot \left(\left(c \cdot i\right) \cdot -2\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(x \cdot y + z \cdot t\right)\\ \end{array} \]
Alternative 16
Error42.6
Cost320
\[2 \cdot \left(x \cdot y\right) \]

Error

Reproduce

herbie shell --seed 2022302 
(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))))