?

Average Accuracy: 90.4% → 96.9%
Time: 29.1s
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(c \cdot i\right) \cdot \left(a + b \cdot c\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)) (* (* c i) (+ a (* b c))))))
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)) - ((c * i) * (a + (b * c))));
}
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(c * i) * Float64(a + Float64(b * c)))))
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[(c * i), $MachinePrecision] * N[(a + N[(b * c), $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)
2 \cdot \left(\mathsf{fma}\left(x, y, z \cdot t\right) - \left(c \cdot i\right) \cdot \left(a + b \cdot c\right)\right)

Error?

Target

Original90.4%
Target96.8%
Herbie96.9%
\[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 90.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. Simplified96.9%

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

    associate-*l* [=>]96.8

    \[ 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 [=>]96.9

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

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

Alternatives

Alternative 1
Accuracy96.0%
Cost8520
\[\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:\\ \;\;\;\;\left(c \cdot \left(i \cdot t_1\right)\right) \cdot -2\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+240}:\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - t_2\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(x \cdot y - \left(c \cdot i\right) \cdot \mathsf{fma}\left(c, b, a\right)\right)\\ \end{array} \]
Alternative 2
Accuracy87.9%
Cost3537
\[\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:\\ \;\;\;\;\left(c \cdot \left(i \cdot t_1\right)\right) \cdot -2\\ \mathbf{elif}\;t_2 \leq -1 \cdot 10^{+34} \lor \neg \left(t_2 \leq 2 \cdot 10^{+43}\right) \land t_2 \leq 4 \cdot 10^{+304}:\\ \;\;\;\;2 \cdot \left(z \cdot t - t_2\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(x \cdot y + \left(z \cdot t - c \cdot \left(a \cdot i\right)\right)\right)\\ \end{array} \]
Alternative 3
Accuracy96.4%
Cost2504
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := c \cdot \left(i \cdot t_1\right)\\ t_3 := i \cdot \left(c \cdot t_1\right)\\ \mathbf{if}\;t_3 \leq -\infty:\\ \;\;\;\;t_2 \cdot -2\\ \mathbf{elif}\;t_3 \leq 4 \cdot 10^{+304}:\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - t_3\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(x \cdot y - t_2\right)\\ \end{array} \]
Alternative 4
Accuracy88.9%
Cost2249
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := i \cdot \left(c \cdot t_1\right)\\ \mathbf{if}\;t_2 \leq -1 \cdot 10^{+34} \lor \neg \left(t_2 \leq 2 \cdot 10^{+43}\right):\\ \;\;\;\;2 \cdot \left(z \cdot t - \left(c \cdot i\right) \cdot t_1\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(x \cdot y + \left(z \cdot t - c \cdot \left(a \cdot i\right)\right)\right)\\ \end{array} \]
Alternative 5
Accuracy89.3%
Cost2249
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := i \cdot \left(c \cdot t_1\right)\\ \mathbf{if}\;t_2 \leq -1 \cdot 10^{+44} \lor \neg \left(t_2 \leq 10^{+71}\right):\\ \;\;\;\;2 \cdot \left(z \cdot t - \left(c \cdot i\right) \cdot t_1\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - i \cdot \left(a \cdot c\right)\right)\\ \end{array} \]
Alternative 6
Accuracy57.1%
Cost2024
\[\begin{array}{l} t_1 := c \cdot \left(i \cdot \left(b \cdot c\right)\right)\\ t_2 := 2 \cdot \left(x \cdot y - t_1\right)\\ t_3 := 2 \cdot \left(z \cdot t - t_1\right)\\ t_4 := 2 \cdot \left(x \cdot y - c \cdot \left(a \cdot i\right)\right)\\ t_5 := 2 \cdot \left(x \cdot y - i \cdot \left(a \cdot c\right)\right)\\ \mathbf{if}\;t \leq -5.6 \cdot 10^{-189}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -2.4 \cdot 10^{-276}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq 8.5 \cdot 10^{-154}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 9 \cdot 10^{-107}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;t \leq 5 \cdot 10^{-70}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 3000:\\ \;\;\;\;t_5\\ \mathbf{elif}\;t \leq 3.1 \cdot 10^{+21}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 4.4 \cdot 10^{+26}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;t \leq 4.8 \cdot 10^{+45}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 7.8 \cdot 10^{+59}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(x \cdot y + z \cdot t\right)\\ \end{array} \]
Alternative 7
Accuracy36.2%
Cost1769
\[\begin{array}{l} t_1 := 2 \cdot \left(z \cdot t\right)\\ t_2 := 2 \cdot \left(x \cdot y\right)\\ t_3 := -2 \cdot \left(a \cdot \left(c \cdot i\right)\right)\\ \mathbf{if}\;a \leq -4.2 \cdot 10^{+129}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -5.5 \cdot 10^{+57}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -3.3 \cdot 10^{+38}:\\ \;\;\;\;\left(a \cdot i\right) \cdot \left(c \cdot -2\right)\\ \mathbf{elif}\;a \leq -1.5 \cdot 10^{-82}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -4.8 \cdot 10^{-182}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -2.15 \cdot 10^{-218}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 5.2 \cdot 10^{-244}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 2.9 \cdot 10^{-74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.9 \cdot 10^{+121} \lor \neg \left(a \leq 1.25 \cdot 10^{+225}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 8
Accuracy70.4%
Cost1744
\[\begin{array}{l} t_1 := 2 \cdot \left(z \cdot t - c \cdot \left(a \cdot i\right)\right)\\ t_2 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{if}\;x \cdot y \leq -1 \cdot 10^{-130}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \cdot y \leq 10^{-306}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{-202}:\\ \;\;\;\;2 \cdot \left(z \cdot t - c \cdot \left(i \cdot \left(b \cdot c\right)\right)\right)\\ \mathbf{elif}\;x \cdot y \leq 10^{-130}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Accuracy75.5%
Cost1490
\[\begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{-133} \lor \neg \left(x \leq -1.5 \cdot 10^{-235} \lor \neg \left(x \leq 5.5 \cdot 10^{-282}\right) \land x \leq 2.9 \cdot 10^{-223}\right):\\ \;\;\;\;2 \cdot \left(x \cdot y + \left(z \cdot t - c \cdot \left(a \cdot i\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t - c \cdot \left(i \cdot \left(b \cdot c\right)\right)\right)\\ \end{array} \]
Alternative 10
Accuracy82.8%
Cost1481
\[\begin{array}{l} \mathbf{if}\;x \cdot y \leq -2 \cdot 10^{-111} \lor \neg \left(x \cdot y \leq 1.35 \cdot 10^{-63}\right):\\ \;\;\;\;2 \cdot \left(x \cdot y + \left(z \cdot t - c \cdot \left(a \cdot i\right)\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 11
Accuracy70.7%
Cost1225
\[\begin{array}{l} \mathbf{if}\;x \cdot y \leq -1 \cdot 10^{-130} \lor \neg \left(x \cdot y \leq 10^{-130}\right):\\ \;\;\;\;2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t - c \cdot \left(a \cdot i\right)\right)\\ \end{array} \]
Alternative 12
Accuracy62.7%
Cost841
\[\begin{array}{l} \mathbf{if}\;b \leq 6.2 \cdot 10^{+162} \lor \neg \left(b \leq 6.5 \cdot 10^{+224}\right):\\ \;\;\;\;2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(i \cdot \left(b \cdot \left(c \cdot c\right)\right)\right)\\ \end{array} \]
Alternative 13
Accuracy43.5%
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -4.6 \cdot 10^{-46} \lor \neg \left(x \leq 2.1 \cdot 10^{-79}\right):\\ \;\;\;\;2 \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t\right)\\ \end{array} \]
Alternative 14
Accuracy33.3%
Cost320
\[2 \cdot \left(z \cdot t\right) \]

Error

Reproduce?

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