?

Average Error: 9.88% → 2.84%
Time: 21.7s
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

Original9.88%
Target2.85%
Herbie2.84%
\[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 9.88

    \[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. Simplified2.84

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

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

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

    \[ 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 simplification2.84

    \[\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
Error3.58%
Cost2505
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := i \cdot \left(c \cdot t_1\right)\\ \mathbf{if}\;t_2 \leq -4 \cdot 10^{+272} \lor \neg \left(t_2 \leq 2 \cdot 10^{+189}\right):\\ \;\;\;\;2 \cdot \left(z \cdot t - t_1 \cdot \left(c \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\left(z \cdot t + x \cdot y\right) - t_2\right)\\ \end{array} \]
Alternative 2
Error15.22%
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^{-73} \lor \neg \left(t_2 \leq 10^{+17}\right):\\ \;\;\;\;2 \cdot \left(z \cdot t - t_1 \cdot \left(c \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t + x \cdot y\right)\\ \end{array} \]
Alternative 3
Error34.8%
Cost1497
\[\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.8 \cdot 10^{+56}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -9 \cdot 10^{-53}:\\ \;\;\;\;2 \cdot \left(z \cdot t - \left(c \cdot i\right) \cdot \left(b \cdot c\right)\right)\\ \mathbf{elif}\;c \leq -6.2 \cdot 10^{-86}:\\ \;\;\;\;2 \cdot \left(x \cdot y - i \cdot \left(a \cdot c\right)\right)\\ \mathbf{elif}\;c \leq 4.9 \cdot 10^{-48} \lor \neg \left(c \leq 7.6 \cdot 10^{+77}\right) \land c \leq 1.15 \cdot 10^{+205}:\\ \;\;\;\;2 \cdot \left(z \cdot t + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error33.7%
Cost1234
\[\begin{array}{l} \mathbf{if}\;c \leq -3.8 \cdot 10^{+52} \lor \neg \left(c \leq 2.8 \cdot 10^{-48} \lor \neg \left(c \leq 6 \cdot 10^{+77}\right) \land c \leq 1.1 \cdot 10^{+206}\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 5
Error58.21%
Cost1112
\[\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}\;x \leq -1.42 \cdot 10^{+60}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -6.6 \cdot 10^{+37}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -6 \cdot 10^{-7}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -8 \cdot 10^{-198}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -4.1 \cdot 10^{-234}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 0.00021:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 6
Error59.66%
Cost1112
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y\right)\\ t_2 := 2 \cdot \left(z \cdot t\right)\\ \mathbf{if}\;z \leq -1 \cdot 10^{-8}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.2 \cdot 10^{-78}:\\ \;\;\;\;-2 \cdot \left(c \cdot \left(a \cdot i\right)\right)\\ \mathbf{elif}\;z \leq -9.8 \cdot 10^{-111}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{-154}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3 \cdot 10^{-198}:\\ \;\;\;\;-2 \cdot \left(a \cdot \left(c \cdot i\right)\right)\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{-179}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error39.24%
Cost1106
\[\begin{array}{l} \mathbf{if}\;i \leq -2.9 \cdot 10^{+173} \lor \neg \left(i \leq 4.4 \cdot 10^{+37}\right) \land \left(i \leq 4.3 \cdot 10^{+105} \lor \neg \left(i \leq 7.2 \cdot 10^{+148}\right)\right):\\ \;\;\;\;-2 \cdot \left(a \cdot \left(c \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t + x \cdot y\right)\\ \end{array} \]
Alternative 8
Error60.25%
Cost850
\[\begin{array}{l} \mathbf{if}\;t \leq -5 \cdot 10^{-242} \lor \neg \left(t \leq 1.1 \cdot 10^{-29} \lor \neg \left(t \leq 7 \cdot 10^{+170}\right) \land t \leq 3.05 \cdot 10^{+212}\right):\\ \;\;\;\;2 \cdot \left(z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 9
Error67.21%
Cost320
\[2 \cdot \left(z \cdot t\right) \]

Error

Reproduce?

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