Average Error: 6.4 → 1.8
Time: 32.1s
Precision: binary64
Cost: 14024
\[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 \mathsf{fma}\left(y, x, z \cdot t - c \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot i\right)\right)\\ \mathbf{if}\;c \leq -100:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 4.364772356247958 \cdot 10^{-109}:\\ \;\;\;\;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}:\\ \;\;\;\;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 (fma y x (- (* z t) (* c (* (fma b c a) i)))))))
   (if (<= c -100.0)
     t_1
     (if (<= c 4.364772356247958e-109)
       (* 2.0 (- (+ (* x y) (* z t)) (* i (* c (+ a (* b 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 * fma(y, x, ((z * t) - (c * (fma(b, c, a) * i))));
	double tmp;
	if (c <= -100.0) {
		tmp = t_1;
	} else if (c <= 4.364772356247958e-109) {
		tmp = 2.0 * (((x * y) + (z * t)) - (i * (c * (a + (b * 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 * fma(y, x, Float64(Float64(z * t) - Float64(c * Float64(fma(b, c, a) * i)))))
	tmp = 0.0
	if (c <= -100.0)
		tmp = t_1;
	elseif (c <= 4.364772356247958e-109)
		tmp = Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(i * Float64(c * Float64(a + Float64(b * 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[(y * x + N[(N[(z * t), $MachinePrecision] - N[(c * N[(N[(b * c + a), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -100.0], t$95$1, If[LessEqual[c, 4.364772356247958e-109], N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(i * N[(c * N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision]), $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 \mathsf{fma}\left(y, x, z \cdot t - c \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot i\right)\right)\\
\mathbf{if}\;c \leq -100:\\
\;\;\;\;t_1\\

\mathbf{elif}\;c \leq 4.364772356247958 \cdot 10^{-109}:\\
\;\;\;\;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}:\\
\;\;\;\;t_1\\


\end{array}

Error

Target

Original6.4
Target1.9
Herbie1.8
\[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 c < -100 or 4.3647723562479581e-109 < c

    1. Initial program 14.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-rr3.6

      \[\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)} \]

    if -100 < c < 4.3647723562479581e-109

    1. Initial program 0.5

      \[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -100:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - c \cdot \left(\mathsf{fma}\left(b, c, a\right) \cdot i\right)\right)\\ \mathbf{elif}\;c \leq 4.364772356247958 \cdot 10^{-109}:\\ \;\;\;\;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
Error1.9
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.7
Cost7876
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := i \cdot \left(c \cdot t_1\right)\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;2 \cdot \left(x \cdot y - \mathsf{fma}\left(c, b, a\right) \cdot \left(c \cdot i\right)\right)\\ \mathbf{elif}\;t_2 \leq 10^{+260}:\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - t_2\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t - c \cdot \left(i \cdot t_1\right)\right)\\ \end{array} \]
Alternative 3
Error2.7
Cost2504
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := i \cdot \left(c \cdot t_1\right)\\ t_3 := c \cdot \left(i \cdot t_1\right)\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;2 \cdot \left(x \cdot y - t_3\right)\\ \mathbf{elif}\;t_2 \leq 10^{+260}:\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - t_2\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t - t_3\right)\\ \end{array} \]
Alternative 4
Error41.1
Cost1768
\[\begin{array}{l} t_1 := y \cdot \left(2 \cdot x\right)\\ t_2 := a \cdot \left(i \cdot \left(c \cdot -2\right)\right)\\ t_3 := z \cdot \left(2 \cdot t\right)\\ \mathbf{if}\;a \leq -7 \cdot 10^{+263}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -1.7121418961106466 \cdot 10^{+67}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -1.9961062425994186 \cdot 10^{-140}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -3.057039249783384 \cdot 10^{-275}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.449217511734002 \cdot 10^{-194}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq 8.891693441951979 \cdot 10^{-6}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.2167033286966886 \cdot 10^{+47}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq 3.558749204838883 \cdot 10^{+130}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 2.3 \cdot 10^{+214}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq 6.2 \cdot 10^{+284}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 5
Error41.7
Cost1768
\[\begin{array}{l} t_1 := a \cdot \left(i \cdot \left(c \cdot -2\right)\right)\\ t_2 := z \cdot \left(2 \cdot t\right)\\ \mathbf{if}\;a \leq -7 \cdot 10^{+263}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -1.7121418961106466 \cdot 10^{+67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -1.9961062425994186 \cdot 10^{-140}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -6.777581103577743 \cdot 10^{-280}:\\ \;\;\;\;y \cdot \left(2 \cdot x\right)\\ \mathbf{elif}\;a \leq 7.980692421032868 \cdot 10^{-247}:\\ \;\;\;\;i \cdot \left(c \cdot \left(\left(b \cdot c\right) \cdot -2\right)\right)\\ \mathbf{elif}\;a \leq 8.891693441951979 \cdot 10^{-6}:\\ \;\;\;\;2 \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;a \leq 3.2167033286966886 \cdot 10^{+47}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 3.558749204838883 \cdot 10^{+130}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 2.3 \cdot 10^{+214}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 6.2 \cdot 10^{+284}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error41.6
Cost1768
\[\begin{array}{l} t_1 := a \cdot \left(i \cdot \left(c \cdot -2\right)\right)\\ t_2 := z \cdot \left(2 \cdot t\right)\\ \mathbf{if}\;a \leq -7 \cdot 10^{+263}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -1.7121418961106466 \cdot 10^{+67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -1.9961062425994186 \cdot 10^{-140}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -6.777581103577743 \cdot 10^{-280}:\\ \;\;\;\;y \cdot \left(2 \cdot x\right)\\ \mathbf{elif}\;a \leq 7.980692421032868 \cdot 10^{-247}:\\ \;\;\;\;-2 \cdot \left(\left(c \cdot i\right) \cdot \left(b \cdot c\right)\right)\\ \mathbf{elif}\;a \leq 8.891693441951979 \cdot 10^{-6}:\\ \;\;\;\;2 \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;a \leq 3.2167033286966886 \cdot 10^{+47}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 3.558749204838883 \cdot 10^{+130}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 2.3 \cdot 10^{+214}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 6.2 \cdot 10^{+284}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error22.6
Cost1624
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{if}\;x \leq -3.25 \cdot 10^{+177}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5.5 \cdot 10^{+137}:\\ \;\;\;\;\left(c \cdot \left(i \cdot \left(a + b \cdot c\right)\right)\right) \cdot -2\\ \mathbf{elif}\;x \leq -1.6186629961430765 \cdot 10^{-203}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5.746243488249378 \cdot 10^{-237}:\\ \;\;\;\;2 \cdot \left(z \cdot t - c \cdot \left(a \cdot i\right)\right)\\ \mathbf{elif}\;x \leq -8.511109285581904 \cdot 10^{-266}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.9046934297149128 \cdot 10^{-229}:\\ \;\;\;\;2 \cdot \left(z \cdot t - \left(c \cdot i\right) \cdot \left(b \cdot c\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error17.4
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}\;c \leq -6.4 \cdot 10^{-9}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -1.1519982890732605 \cdot 10^{-82}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -3.16928346529467 \cdot 10^{-95}:\\ \;\;\;\;a \cdot \left(i \cdot \left(c \cdot -2\right)\right)\\ \mathbf{elif}\;c \leq 620000000000:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error16.8
Cost1488
\[\begin{array}{l} t_1 := c \cdot \left(i \cdot \left(a + b \cdot c\right)\right)\\ t_2 := 2 \cdot \left(z \cdot t - t_1\right)\\ t_3 := 2 \cdot \left(x \cdot y - t_1\right)\\ \mathbf{if}\;c \leq -1 \cdot 10^{+55}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -1 \cdot 10^{+32}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -6.4 \cdot 10^{-9}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 4 \cdot 10^{+15}:\\ \;\;\;\;2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 10
Error8.7
Cost1488
\[\begin{array}{l} t_1 := c \cdot \left(i \cdot \left(a + b \cdot c\right)\right)\\ t_2 := 2 \cdot \left(z \cdot t - t_1\right)\\ t_3 := 2 \cdot \left(x \cdot y - t_1\right)\\ \mathbf{if}\;c \leq -1 \cdot 10^{+55}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -1 \cdot 10^{+32}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -6.4 \cdot 10^{-9}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 4 \cdot 10^{+15}:\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - i \cdot \left(c \cdot a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 11
Error23.3
Cost1232
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{if}\;c \leq -1.1519982890732605 \cdot 10^{-82}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -3.16928346529467 \cdot 10^{-95}:\\ \;\;\;\;a \cdot \left(i \cdot \left(c \cdot -2\right)\right)\\ \mathbf{elif}\;c \leq 5.5 \cdot 10^{+125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 4.7 \cdot 10^{+155}:\\ \;\;\;\;-2 \cdot \left(\left(c \cdot i\right) \cdot \left(b \cdot c\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(x \cdot y - c \cdot \left(a \cdot i\right)\right)\\ \end{array} \]
Alternative 12
Error8.3
Cost1224
\[\begin{array}{l} t_1 := x \cdot y + z \cdot t\\ \mathbf{if}\;c \leq -1.9 \cdot 10^{-13}:\\ \;\;\;\;2 \cdot \left(t_1 - c \cdot \left(c \cdot \left(b \cdot i\right)\right)\right)\\ \mathbf{elif}\;c \leq 4 \cdot 10^{+15}:\\ \;\;\;\;2 \cdot \left(t_1 - i \cdot \left(c \cdot a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(x \cdot y - c \cdot \left(i \cdot \left(a + b \cdot c\right)\right)\right)\\ \end{array} \]
Alternative 13
Error24.0
Cost1104
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{if}\;a \leq -7 \cdot 10^{+263}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -4.1 \cdot 10^{+247}:\\ \;\;\;\;a \cdot \left(i \cdot \left(c \cdot -2\right)\right)\\ \mathbf{elif}\;a \leq 4.433266704237237 \cdot 10^{-295}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 2.673364239150518 \cdot 10^{-248}:\\ \;\;\;\;-2 \cdot \left(\left(c \cdot i\right) \cdot \left(b \cdot c\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 14
Error22.3
Cost1100
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{if}\;c \leq -1.1519982890732605 \cdot 10^{-82}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -3.16928346529467 \cdot 10^{-95}:\\ \;\;\;\;a \cdot \left(i \cdot \left(c \cdot -2\right)\right)\\ \mathbf{elif}\;c \leq 4 \cdot 10^{+15}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\left(c \cdot \left(i \cdot \left(a + b \cdot c\right)\right)\right) \cdot -2\\ \end{array} \]
Alternative 15
Error24.4
Cost972
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{if}\;a \leq -33330.50576744949:\\ \;\;\;\;2 \cdot \left(z \cdot t - c \cdot \left(a \cdot i\right)\right)\\ \mathbf{elif}\;a \leq 4.433266704237237 \cdot 10^{-295}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 2.673364239150518 \cdot 10^{-248}:\\ \;\;\;\;-2 \cdot \left(\left(c \cdot i\right) \cdot \left(b \cdot c\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 16
Error37.7
Cost848
\[\begin{array}{l} t_1 := z \cdot \left(2 \cdot t\right)\\ \mathbf{if}\;z \leq -2.8 \cdot 10^{+117}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.6580983876128143 \cdot 10^{-147}:\\ \;\;\;\;2 \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;z \leq -3.109769020725721 \cdot 10^{-210}:\\ \;\;\;\;i \cdot \left(a \cdot \left(c \cdot -2\right)\right)\\ \mathbf{elif}\;z \leq 8.577165754387119 \cdot 10^{-122}:\\ \;\;\;\;y \cdot \left(2 \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 17
Error36.7
Cost584
\[\begin{array}{l} t_1 := z \cdot \left(2 \cdot t\right)\\ \mathbf{if}\;t \leq -7.770843334183487 \cdot 10^{-143}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.1 \cdot 10^{+52}:\\ \;\;\;\;y \cdot \left(2 \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 18
Error36.7
Cost584
\[\begin{array}{l} t_1 := z \cdot \left(2 \cdot t\right)\\ \mathbf{if}\;t \leq -7.770843334183487 \cdot 10^{-143}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.1 \cdot 10^{+52}:\\ \;\;\;\;2 \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 19
Error42.7
Cost320
\[z \cdot \left(2 \cdot t\right) \]

Error

Reproduce

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