?

Average Accuracy: 89.9% → 96.8%
Time: 22.3s
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.9%
Target96.8%
Herbie96.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. Initial program 89.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. Simplified96.8%

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

    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.8

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

    \[\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.2%
Cost3536
\[\begin{array}{l} t_1 := i \cdot \left(c \cdot \left(a + b \cdot c\right)\right)\\ t_2 := 2 \cdot \left(z \cdot t - t_1\right)\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;\left(b \cdot \left(c \cdot \left(c \cdot i\right)\right)\right) \cdot -2\\ \mathbf{elif}\;t_1 \leq -0.002:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 10^{-8}:\\ \;\;\;\;2 \cdot \left(z \cdot t + x \cdot y\right)\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+217}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(a \cdot \left(c \cdot i\right) + \left(b \cdot c\right) \cdot \left(c \cdot i\right)\right)\\ \end{array} \]
Alternative 2
Accuracy84.5%
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(t_1 \cdot i\right)\right)\\ \mathbf{elif}\;t_2 \leq -0.002:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq 10^{-8}:\\ \;\;\;\;2 \cdot \left(z \cdot t + x \cdot y\right)\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+217}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(a \cdot \left(c \cdot i\right) + \left(b \cdot c\right) \cdot \left(c \cdot i\right)\right)\\ \end{array} \]
Alternative 3
Accuracy84.3%
Cost3536
\[\begin{array}{l} t_1 := i \cdot \left(c \cdot \left(a + b \cdot c\right)\right)\\ t_2 := \left(b \cdot c\right) \cdot \left(c \cdot i\right)\\ t_3 := -2 \cdot \left(a \cdot \left(c \cdot i\right) + t_2\right)\\ t_4 := 2 \cdot \left(\left(z \cdot t - t_2\right) + x \cdot y\right)\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t_1 \leq -1 \cdot 10^{+174}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_1 \leq 10^{-8}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+217}:\\ \;\;\;\;2 \cdot \left(z \cdot t - t_1\right)\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 4
Accuracy84.7%
Cost3536
\[\begin{array}{l} t_1 := \left(b \cdot c\right) \cdot \left(c \cdot i\right)\\ t_2 := -2 \cdot \left(a \cdot \left(c \cdot i\right) + t_1\right)\\ t_3 := i \cdot \left(c \cdot \left(a + b \cdot c\right)\right)\\ \mathbf{if}\;t_3 \leq -\infty:\\ \;\;\;\;2 \cdot \left(\left(z \cdot t + x \cdot y\right) - b \cdot \left(c \cdot \left(c \cdot i\right)\right)\right)\\ \mathbf{elif}\;t_3 \leq -1 \cdot 10^{+174}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_3 \leq 10^{-8}:\\ \;\;\;\;2 \cdot \left(\left(z \cdot t - t_1\right) + x \cdot y\right)\\ \mathbf{elif}\;t_3 \leq 5 \cdot 10^{+217}:\\ \;\;\;\;2 \cdot \left(z \cdot t - t_3\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Accuracy95.5%
Cost2504
\[\begin{array}{l} t_1 := z \cdot t + x \cdot y\\ t_2 := i \cdot \left(c \cdot \left(a + b \cdot c\right)\right)\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;2 \cdot \left(t_1 - b \cdot \left(c \cdot \left(c \cdot i\right)\right)\right)\\ \mathbf{elif}\;t_2 \leq 10^{+225}:\\ \;\;\;\;2 \cdot \left(t_1 - t_2\right)\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \left(a \cdot \left(c \cdot i\right) + \left(b \cdot c\right) \cdot \left(c \cdot i\right)\right)\\ \end{array} \]
Alternative 6
Accuracy40.3%
Cost1640
\[\begin{array}{l} t_1 := y \cdot \left(2 \cdot x\right)\\ t_2 := z \cdot \left(2 \cdot t\right)\\ t_3 := i \cdot \left(-2 \cdot \left(a \cdot c\right)\right)\\ \mathbf{if}\;z \leq -1.9 \cdot 10^{+166}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -7.4 \cdot 10^{+140}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-15}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -6 \cdot 10^{-65}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.7 \cdot 10^{-91}:\\ \;\;\;\;\left(b \cdot \left(c \cdot \left(c \cdot i\right)\right)\right) \cdot -2\\ \mathbf{elif}\;z \leq -8.6 \cdot 10^{-152}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -6.6 \cdot 10^{-185}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{-294}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{-174}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{-91}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Accuracy67.4%
Cost1356
\[\begin{array}{l} t_1 := -2 \cdot \left(a \cdot \left(c \cdot i\right) + \left(b \cdot c\right) \cdot \left(c \cdot i\right)\right)\\ \mathbf{if}\;c \leq -4.5 \cdot 10^{-13}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 2.2 \cdot 10^{-23}:\\ \;\;\;\;2 \cdot \left(z \cdot t + x \cdot y\right)\\ \mathbf{elif}\;c \leq 1.36 \cdot 10^{+143}:\\ \;\;\;\;2 \cdot \left(z \cdot t - \left(c \cdot c\right) \cdot \left(b \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Accuracy67.9%
Cost1228
\[\begin{array}{l} t_1 := -2 \cdot \left(c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)\right)\\ \mathbf{if}\;c \leq -2.9 \cdot 10^{+50}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 2.15 \cdot 10^{-26}:\\ \;\;\;\;2 \cdot \left(z \cdot t + x \cdot y\right)\\ \mathbf{elif}\;c \leq 5.5 \cdot 10^{+142}:\\ \;\;\;\;2 \cdot \left(z \cdot t - \left(c \cdot c\right) \cdot \left(b \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Accuracy67.5%
Cost969
\[\begin{array}{l} \mathbf{if}\;c \leq -1.42 \cdot 10^{+50} \lor \neg \left(c \leq 9.2 \cdot 10^{-22}\right):\\ \;\;\;\;-2 \cdot \left(c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t + x \cdot y\right)\\ \end{array} \]
Alternative 10
Accuracy42.8%
Cost850
\[\begin{array}{l} \mathbf{if}\;t \leq -1.12 \cdot 10^{-20} \lor \neg \left(t \leq -2.6 \cdot 10^{-92}\right) \land \left(t \leq -3.9 \cdot 10^{-175} \lor \neg \left(t \leq 3.4 \cdot 10^{-54}\right)\right):\\ \;\;\;\;z \cdot \left(2 \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(2 \cdot x\right)\\ \end{array} \]
Alternative 11
Accuracy61.1%
Cost841
\[\begin{array}{l} \mathbf{if}\;c \leq -9 \cdot 10^{+57} \lor \neg \left(c \leq 1.06 \cdot 10^{-21}\right):\\ \;\;\;\;-2 \cdot \left(c \cdot \left(\left(b \cdot c\right) \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t + x \cdot y\right)\\ \end{array} \]
Alternative 12
Accuracy61.2%
Cost840
\[\begin{array}{l} \mathbf{if}\;c \leq -9.5 \cdot 10^{+58}:\\ \;\;\;\;-2 \cdot \left(c \cdot \left(\left(b \cdot c\right) \cdot i\right)\right)\\ \mathbf{elif}\;c \leq 1.06 \cdot 10^{-21}:\\ \;\;\;\;2 \cdot \left(z \cdot t + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot \left(-2 \cdot \left(c \cdot \left(b \cdot i\right)\right)\right)\\ \end{array} \]
Alternative 13
Accuracy32.1%
Cost320
\[y \cdot \left(2 \cdot x\right) \]

Error

Reproduce?

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