?

Average Accuracy: 89.8% → 97.1%
Time: 32.2s
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

Original89.8%
Target97.1%
Herbie97.1%
\[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 89.8%

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

    \[\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]89.8

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

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

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

    \[\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
Accuracy83.5%
Cost3536
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := \left(c \cdot \left(t_1 \cdot i\right)\right) \cdot -2\\ t_3 := i \cdot \left(c \cdot t_1\right)\\ t_4 := 2 \cdot \left(z \cdot t - t_3\right)\\ \mathbf{if}\;t_3 \leq -\infty:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_3 \leq -1 \cdot 10^{+59}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t_3 \leq 10^{-36}:\\ \;\;\;\;2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{elif}\;t_3 \leq 5 \cdot 10^{+263}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Accuracy83.4%
Cost3536
\[\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 := i \cdot \left(c \cdot t_1\right)\\ t_4 := 2 \cdot \left(z \cdot t - t_3\right)\\ \mathbf{if}\;t_3 \leq -2 \cdot 10^{+266}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_3 \leq -1 \cdot 10^{+59}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t_3 \leq 10^{-36}:\\ \;\;\;\;2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{elif}\;t_3 \leq 5 \cdot 10^{+263}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Accuracy84.2%
Cost3536
\[\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 := i \cdot \left(c \cdot t_1\right)\\ \mathbf{if}\;t_3 \leq -\infty:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_3 \leq -1 \cdot 10^{+59}:\\ \;\;\;\;2 \cdot \left(x \cdot y - t_3\right)\\ \mathbf{elif}\;t_3 \leq 10^{-36}:\\ \;\;\;\;2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{elif}\;t_3 \leq 5 \cdot 10^{+263}:\\ \;\;\;\;2 \cdot \left(z \cdot t - t_3\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Accuracy87.0%
Cost3536
\[\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 := i \cdot \left(c \cdot t_1\right)\\ \mathbf{if}\;t_3 \leq -\infty:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_3 \leq -1 \cdot 10^{+59}:\\ \;\;\;\;2 \cdot \left(x \cdot y - t_3\right)\\ \mathbf{elif}\;t_3 \leq 5 \cdot 10^{+24}:\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - c \cdot \left(b \cdot \left(c \cdot i\right)\right)\right)\\ \mathbf{elif}\;t_3 \leq 5 \cdot 10^{+263}:\\ \;\;\;\;2 \cdot \left(z \cdot t - t_3\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Accuracy53.9%
Cost2288
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ t_2 := \left(c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)\right) \cdot -2\\ t_3 := 2 \cdot \left(z \cdot t - i \cdot \left(a \cdot c\right)\right)\\ \mathbf{if}\;b \leq -5.6 \cdot 10^{+215}:\\ \;\;\;\;2 \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;b \leq -1.95 \cdot 10^{+138}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq -3 \cdot 10^{+63}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq -1.5 \cdot 10^{+45}:\\ \;\;\;\;b \cdot \left(-2 \cdot \left(c \cdot \left(c \cdot i\right)\right)\right)\\ \mathbf{elif}\;b \leq -8.6 \cdot 10^{-11}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq -1.3 \cdot 10^{-199}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq -2.05 \cdot 10^{-256}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq 1.05 \cdot 10^{-196}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 4.5 \cdot 10^{-161}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq 7.5 \cdot 10^{-132}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 7.2 \cdot 10^{-12}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq 9.8 \cdot 10^{+183}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Accuracy96.6%
Cost2249
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := c \cdot t_1\\ \mathbf{if}\;t_2 \leq -\infty \lor \neg \left(t_2 \leq 5 \cdot 10^{+272}\right):\\ \;\;\;\;2 \cdot \left(x \cdot y - c \cdot \left(t_1 \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - i \cdot t_2\right)\\ \end{array} \]
Alternative 7
Accuracy53.5%
Cost1892
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ t_2 := \left(c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)\right) \cdot -2\\ t_3 := 2 \cdot \left(z \cdot t - i \cdot \left(a \cdot c\right)\right)\\ t_4 := 2 \cdot \left(x \cdot y - a \cdot \left(c \cdot i\right)\right)\\ \mathbf{if}\;b \leq -8.4 \cdot 10^{+215}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \leq -8 \cdot 10^{+42}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq -9.2 \cdot 10^{-200}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq -3.1 \cdot 10^{-257}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq 3.1 \cdot 10^{-196}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 1.65 \cdot 10^{-164}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq 7.6 \cdot 10^{-131}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \leq 9.5 \cdot 10^{-12}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq 1.66 \cdot 10^{+188}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Accuracy35.1%
Cost1637
\[\begin{array}{l} t_1 := 2 \cdot \left(z \cdot t\right)\\ t_2 := -2 \cdot \left(i \cdot \left(a \cdot c\right)\right)\\ t_3 := 2 \cdot \left(x \cdot y\right)\\ \mathbf{if}\;a \leq -9.5 \cdot 10^{+133}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -7 \cdot 10^{-6}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -2.6 \cdot 10^{-114}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq 4.5 \cdot 10^{-308}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.7 \cdot 10^{-163}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq 1.05 \cdot 10^{-88}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.65 \cdot 10^{+63}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq 5.8 \cdot 10^{+165} \lor \neg \left(a \leq 5 \cdot 10^{+204}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Accuracy37.0%
Cost1637
\[\begin{array}{l} t_1 := 2 \cdot \left(z \cdot t\right)\\ t_2 := -2 \cdot \left(a \cdot \left(c \cdot i\right)\right)\\ t_3 := 2 \cdot \left(x \cdot y\right)\\ \mathbf{if}\;a \leq -5.4 \cdot 10^{+133}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -7.8 \cdot 10^{-6}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -3.75 \cdot 10^{-115}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq 5 \cdot 10^{-308}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.15 \cdot 10^{-162}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq 4.3 \cdot 10^{-88}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 7.6 \cdot 10^{+63}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq 2.8 \cdot 10^{+166} \lor \neg \left(a \leq 3 \cdot 10^{+189}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Accuracy63.1%
Cost1368
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ t_2 := -2 \cdot \left(a \cdot \left(c \cdot i\right)\right)\\ \mathbf{if}\;a \leq -4.5 \cdot 10^{+208}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -7 \cdot 10^{+171}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -4.8 \cdot 10^{+152}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 3.3 \cdot 10^{+126}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 5.2 \cdot 10^{+166}:\\ \;\;\;\;-2 \cdot \left(i \cdot \left(a \cdot c\right)\right)\\ \mathbf{elif}\;a \leq 8 \cdot 10^{+204}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 11
Accuracy61.6%
Cost1368
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ t_2 := -2 \cdot \left(a \cdot \left(c \cdot i\right)\right)\\ \mathbf{if}\;a \leq -5.2 \cdot 10^{+207}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -6.1 \cdot 10^{+172}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -2.05 \cdot 10^{+150}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 1.7 \cdot 10^{+63}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 7.2 \cdot 10^{+154}:\\ \;\;\;\;\left(c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)\right) \cdot -2\\ \mathbf{elif}\;a \leq 1.6 \cdot 10^{+205}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 12
Accuracy90.8%
Cost1353
\[\begin{array}{l} t_1 := x \cdot y + z \cdot t\\ \mathbf{if}\;a \leq -5.5 \cdot 10^{+23} \lor \neg \left(a \leq 8.5 \cdot 10^{+75}\right):\\ \;\;\;\;2 \cdot \left(t_1 - \frac{c \cdot i}{\frac{1}{a}}\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(t_1 - c \cdot \left(b \cdot \left(c \cdot i\right)\right)\right)\\ \end{array} \]
Alternative 13
Accuracy90.8%
Cost1352
\[\begin{array}{l} t_1 := x \cdot y + z \cdot t\\ \mathbf{if}\;a \leq -5.4 \cdot 10^{+23}:\\ \;\;\;\;2 \cdot \left(t_1 - \frac{c \cdot i}{\frac{1}{a}}\right)\\ \mathbf{elif}\;a \leq 1.04 \cdot 10^{+74}:\\ \;\;\;\;2 \cdot \left(t_1 - c \cdot \left(b \cdot \left(c \cdot i\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(t_1 + a \cdot \frac{c}{\frac{-1}{i}}\right)\\ \end{array} \]
Alternative 14
Accuracy42.6%
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -7 \cdot 10^{+54} \lor \neg \left(x \leq 1.08 \cdot 10^{-108}\right):\\ \;\;\;\;2 \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t\right)\\ \end{array} \]
Alternative 15
Accuracy33.0%
Cost320
\[2 \cdot \left(z \cdot t\right) \]
Alternative 16
Accuracy2.8%
Cost64
\[0 \]

Error

Reproduce?

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