?

Average Accuracy: 88.7% → 97.0%
Time: 23.4s
Precision: binary64
Cost: 7488

?

\[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 \cdot \left(\mathsf{fma}\left(x, y, z \cdot t\right) - \left(a + b \cdot c\right) \cdot \left(c \cdot i\right)\right) \]
(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
 (* 2.0 (- (fma 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) {
	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) {
	return 2.0 * (fma(x, y, (z * t)) - ((a + (b * c)) * (c * i)));
}
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)
	return Float64(2.0 * Float64(fma(x, y, Float64(z * t)) - Float64(Float64(a + Float64(b * c)) * Float64(c * i))))
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_] := N[(2.0 * N[(N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * N[(c * i), $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)
2 \cdot \left(\mathsf{fma}\left(x, y, z \cdot t\right) - \left(a + b \cdot c\right) \cdot \left(c \cdot i\right)\right)

Error?

Target

Original88.7%
Target97.0%
Herbie97.0%
\[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. Initial program 88.7%

    \[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. Simplified97.0%

    \[\leadsto \color{blue}{2 \cdot \left(\mathsf{fma}\left(x, y, z \cdot t\right) - \left(a + b \cdot c\right) \cdot \left(c \cdot i\right)\right)} \]
    Proof

    [Start]88.7

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

    associate-*l* [=>]97.0

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

    fma-def [=>]97.0

    \[ 2 \cdot \left(\color{blue}{\mathsf{fma}\left(x, y, z \cdot t\right)} - \left(a + b \cdot c\right) \cdot \left(c \cdot i\right)\right) \]
  3. Final simplification97.0%

    \[\leadsto 2 \cdot \left(\mathsf{fma}\left(x, y, z \cdot t\right) - \left(a + b \cdot c\right) \cdot \left(c \cdot i\right)\right) \]

Alternatives

Alternative 1
Accuracy96.1%
Cost8392
\[\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 - c \cdot \left(t_1 \cdot i\right)\right)\\ \mathbf{elif}\;t_2 \leq 10^{+293}:\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - t_2\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(c \cdot i\right) \cdot -2}{\frac{1}{\mathsf{fma}\left(c, b, a\right)}}\\ \end{array} \]
Alternative 2
Accuracy75.4%
Cost5088
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := c \cdot \left(t_1 \cdot i\right)\\ t_3 := 2 \cdot \left(x \cdot y - t_2\right)\\ t_4 := c \cdot t_1\\ t_5 := 2 \cdot \left(z \cdot t - i \cdot t_4\right)\\ \mathbf{if}\;t_4 \leq -5 \cdot 10^{+113}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_4 \leq -0.5:\\ \;\;\;\;t_5\\ \mathbf{elif}\;t_4 \leq -1 \cdot 10^{-72}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_4 \leq -4 \cdot 10^{-118}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;t_4 \leq 2 \cdot 10^{-148}:\\ \;\;\;\;2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{elif}\;t_4 \leq 5 \cdot 10^{+37}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;t_4 \leq 2 \cdot 10^{+91}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_4 \leq 4 \cdot 10^{+286}:\\ \;\;\;\;t_5\\ \mathbf{else}:\\ \;\;\;\;t_2 \cdot -2\\ \end{array} \]
Alternative 3
Accuracy78.0%
Cost3668
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := 2 \cdot \left(x \cdot y - c \cdot \left(t_1 \cdot i\right)\right)\\ t_3 := c \cdot t_1\\ t_4 := 2 \cdot \left(z \cdot t - i \cdot t_3\right)\\ t_5 := 2 \cdot \left(\left(x \cdot y + z \cdot t\right) - c \cdot \left(b \cdot \left(c \cdot i\right)\right)\right)\\ \mathbf{if}\;t_3 \leq -5 \cdot 10^{+110}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_3 \leq 2 \cdot 10^{-148}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;t_3 \leq 5 \cdot 10^{+37}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t_3 \leq 2 \cdot 10^{+91}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_3 \leq 10^{+139}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_5\\ \end{array} \]
Alternative 4
Accuracy82.6%
Cost3536
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := i \cdot \left(c \cdot t_1\right)\\ t_3 := 2 \cdot \left(z \cdot t - t_2\right)\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;2 \cdot \left(x \cdot y - c \cdot \left(b \cdot \left(c \cdot i\right)\right)\right)\\ \mathbf{elif}\;t_2 \leq -4 \cdot 10^{-98}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq 10^{+29}:\\ \;\;\;\;2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{elif}\;t_2 \leq 4 \cdot 10^{+307}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;\left(c \cdot \left(t_1 \cdot i\right)\right) \cdot -2\\ \end{array} \]
Alternative 5
Accuracy96.1%
Cost2504
\[\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 - c \cdot \left(t_1 \cdot i\right)\right)\\ \mathbf{elif}\;t_2 \leq 10^{+293}:\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - t_2\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(\left(c \cdot i\right) \cdot \left(b \cdot c\right)\right) + -2 \cdot \left(a \cdot \left(c \cdot i\right)\right)\\ \end{array} \]
Alternative 6
Accuracy62.3%
Cost1764
\[\begin{array}{l} \mathbf{if}\;i \leq -1.5 \cdot 10^{+98} \lor \neg \left(i \leq -9.5 \cdot 10^{+63} \lor \neg \left(i \leq 1.16 \cdot 10^{-226}\right) \land \left(i \leq 1.22 \cdot 10^{-210} \lor \neg \left(i \leq 5 \cdot 10^{-114}\right) \land \left(i \leq 4 \cdot 10^{-99} \lor \neg \left(i \leq 1.05 \cdot 10^{+71}\right) \land i \leq 7 \cdot 10^{+109}\right)\right)\right):\\ \;\;\;\;2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)\right) \cdot -2\\ \end{array} \]
Alternative 7
Accuracy64.2%
Cost1760
\[\begin{array}{l} t_1 := \left(c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)\right) \cdot -2\\ t_2 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ t_3 := 2 \cdot \left(z \cdot t - i \cdot \left(a \cdot c\right)\right)\\ \mathbf{if}\;i \leq -9.5 \cdot 10^{+63}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;i \leq 1.16 \cdot 10^{-226}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;i \leq 1.22 \cdot 10^{-210}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;i \leq 5 \cdot 10^{-114}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;i \leq 3.7 \cdot 10^{-100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;i \leq 1.7 \cdot 10^{+71}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;i \leq 2.7 \cdot 10^{+110}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;i \leq 1.4 \cdot 10^{+169}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 8
Accuracy64.1%
Cost1760
\[\begin{array}{l} t_1 := \left(c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)\right) \cdot -2\\ t_2 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ t_3 := 2 \cdot \left(z \cdot t - i \cdot \left(a \cdot c\right)\right)\\ \mathbf{if}\;i \leq -9.5 \cdot 10^{+63}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;i \leq 1.16 \cdot 10^{-226}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;i \leq 1.22 \cdot 10^{-210}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;i \leq 6.5 \cdot 10^{-122}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;i \leq 3.1 \cdot 10^{-87}:\\ \;\;\;\;2 \cdot \left(x \cdot y - c \cdot \left(b \cdot \left(c \cdot i\right)\right)\right)\\ \mathbf{elif}\;i \leq 1.9 \cdot 10^{+69}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;i \leq 7 \cdot 10^{+109}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;i \leq 4.1 \cdot 10^{+168}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 9
Accuracy40.3%
Cost848
\[\begin{array}{l} t_1 := 2 \cdot \left(z \cdot t\right)\\ t_2 := 2 \cdot \left(x \cdot y\right)\\ \mathbf{if}\;y \leq -5.2 \cdot 10^{-92}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{-278}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 6 \cdot 10^{-176}:\\ \;\;\;\;c \cdot \left(-2 \cdot \left(a \cdot i\right)\right)\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{+121}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 10
Accuracy40.6%
Cost848
\[\begin{array}{l} t_1 := 2 \cdot \left(z \cdot t\right)\\ t_2 := 2 \cdot \left(x \cdot y\right)\\ \mathbf{if}\;y \leq -8 \cdot 10^{-91}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{-279}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 9.6 \cdot 10^{-176}:\\ \;\;\;\;-2 \cdot \left(a \cdot \left(c \cdot i\right)\right)\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+121}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 11
Accuracy62.1%
Cost841
\[\begin{array}{l} \mathbf{if}\;y \leq 1.6 \cdot 10^{-278} \lor \neg \left(y \leq 6 \cdot 10^{-176}\right):\\ \;\;\;\;2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(a \cdot \left(c \cdot i\right)\right)\\ \end{array} \]
Alternative 12
Accuracy43.2%
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -8.5 \cdot 10^{+36} \lor \neg \left(x \leq 1.2 \cdot 10^{-53}\right):\\ \;\;\;\;2 \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t\right)\\ \end{array} \]
Alternative 13
Accuracy34.5%
Cost320
\[2 \cdot \left(z \cdot t\right) \]
Alternative 14
Accuracy0.0%
Cost192
\[\frac{0}{0} \]

Error

Reproduce?

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