?

Average Error: 6.3 → 2.8
Time: 20.3s
Precision: binary64
Cost: 2248

?

\[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \]
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := c \cdot t_1\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;\left(c \cdot \left(t_1 \cdot i\right)\right) \cdot -2\\ \mathbf{elif}\;t_2 \leq 10^{+297}:\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - i \cdot t_2\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(x \cdot y - c \cdot \left(c \cdot \left(b \cdot i\right)\right)\right)\\ \end{array} \]
(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
 (let* ((t_1 (+ a (* b c))) (t_2 (* c t_1)))
   (if (<= t_2 (- INFINITY))
     (* (* c (* t_1 i)) -2.0)
     (if (<= t_2 1e+297)
       (* 2.0 (- (+ (* x y) (* z t)) (* i t_2)))
       (* 2.0 (- (* x y) (* c (* c (* b 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) {
	double t_1 = a + (b * c);
	double t_2 = c * t_1;
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = (c * (t_1 * i)) * -2.0;
	} else if (t_2 <= 1e+297) {
		tmp = 2.0 * (((x * y) + (z * t)) - (i * t_2));
	} else {
		tmp = 2.0 * ((x * y) - (c * (c * (b * i))));
	}
	return tmp;
}
public static 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));
}
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = a + (b * c);
	double t_2 = c * t_1;
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = (c * (t_1 * i)) * -2.0;
	} else if (t_2 <= 1e+297) {
		tmp = 2.0 * (((x * y) + (z * t)) - (i * t_2));
	} else {
		tmp = 2.0 * ((x * y) - (c * (c * (b * i))));
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))
def code(x, y, z, t, a, b, c, i):
	t_1 = a + (b * c)
	t_2 = c * t_1
	tmp = 0
	if t_2 <= -math.inf:
		tmp = (c * (t_1 * i)) * -2.0
	elif t_2 <= 1e+297:
		tmp = 2.0 * (((x * y) + (z * t)) - (i * t_2))
	else:
		tmp = 2.0 * ((x * y) - (c * (c * (b * i))))
	return tmp
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)
	t_1 = Float64(a + Float64(b * c))
	t_2 = Float64(c * t_1)
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = Float64(Float64(c * Float64(t_1 * i)) * -2.0);
	elseif (t_2 <= 1e+297)
		tmp = Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(i * t_2)));
	else
		tmp = Float64(2.0 * Float64(Float64(x * y) - Float64(c * Float64(c * Float64(b * i)))));
	end
	return tmp
end
function tmp = code(x, y, z, t, a, b, c, i)
	tmp = 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
end
function tmp_2 = code(x, y, z, t, a, b, c, i)
	t_1 = a + (b * c);
	t_2 = c * t_1;
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = (c * (t_1 * i)) * -2.0;
	elseif (t_2 <= 1e+297)
		tmp = 2.0 * (((x * y) + (z * t)) - (i * t_2));
	else
		tmp = 2.0 * ((x * y) - (c * (c * (b * i))));
	end
	tmp_2 = tmp;
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_] := Block[{t$95$1 = N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(c * t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(c * N[(t$95$1 * i), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision], If[LessEqual[t$95$2, 1e+297], N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(i * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[(x * y), $MachinePrecision] - N[(c * N[(c * N[(b * i), $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)
\begin{array}{l}
t_1 := a + b \cdot c\\
t_2 := c \cdot t_1\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;\left(c \cdot \left(t_1 \cdot i\right)\right) \cdot -2\\

\mathbf{elif}\;t_2 \leq 10^{+297}:\\
\;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - i \cdot t_2\right)\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \left(x \cdot y - c \cdot \left(c \cdot \left(b \cdot i\right)\right)\right)\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.3
Target2.0
Herbie2.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. Split input into 3 regimes
  2. if (*.f64 (+.f64 a (*.f64 b c)) c) < -inf.0

    1. Initial program 64.0

      \[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. Taylor expanded in i around inf 24.1

      \[\leadsto 2 \cdot \color{blue}{\left(-1 \cdot \left(c \cdot \left(i \cdot \left(c \cdot b + a\right)\right)\right)\right)} \]

    if -inf.0 < (*.f64 (+.f64 a (*.f64 b c)) c) < 1e297

    1. Initial program 0.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) \]

    if 1e297 < (*.f64 (+.f64 a (*.f64 b c)) c)

    1. Initial program 58.6

      \[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. Taylor expanded in x around inf 59.5

      \[\leadsto 2 \cdot \left(\color{blue}{y \cdot x} - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \]
    3. Taylor expanded in a around 0 44.8

      \[\leadsto 2 \cdot \color{blue}{\left(y \cdot x - {c}^{2} \cdot \left(i \cdot b\right)\right)} \]
    4. Simplified25.8

      \[\leadsto 2 \cdot \color{blue}{\left(y \cdot x - c \cdot \left(c \cdot \left(i \cdot b\right)\right)\right)} \]
      Proof

      [Start]44.8

      \[ 2 \cdot \left(y \cdot x - {c}^{2} \cdot \left(i \cdot b\right)\right) \]

      unpow2 [=>]44.8

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

      associate-*l* [=>]25.8

      \[ 2 \cdot \left(y \cdot x - \color{blue}{c \cdot \left(c \cdot \left(i \cdot b\right)\right)}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \cdot \left(a + b \cdot c\right) \leq -\infty:\\ \;\;\;\;\left(c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)\right) \cdot -2\\ \mathbf{elif}\;c \cdot \left(a + b \cdot c\right) \leq 10^{+297}:\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - i \cdot \left(c \cdot \left(a + b \cdot c\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(x \cdot y - c \cdot \left(c \cdot \left(b \cdot i\right)\right)\right)\\ \end{array} \]

Alternatives

Alternative 1
Error2.0
Cost7488
\[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) \]
Alternative 2
Error12.3
Cost2893
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := i \cdot \left(c \cdot t_1\right)\\ \mathbf{if}\;t_2 \leq -5 \cdot 10^{+298}:\\ \;\;\;\;\left(c \cdot \left(t_1 \cdot i\right)\right) \cdot -2\\ \mathbf{elif}\;t_2 \leq -5 \cdot 10^{-44} \lor \neg \left(t_2 \leq 5 \cdot 10^{-16}\right):\\ \;\;\;\;2 \cdot \left(x \cdot y - t_2\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(x \cdot y + z \cdot t\right)\\ \end{array} \]
Alternative 3
Error9.6
Cost2893
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := i \cdot \left(c \cdot t_1\right)\\ \mathbf{if}\;t_2 \leq -5 \cdot 10^{+298}:\\ \;\;\;\;\left(c \cdot \left(t_1 \cdot i\right)\right) \cdot -2\\ \mathbf{elif}\;t_2 \leq -2 \cdot 10^{+102} \lor \neg \left(t_2 \leq 5 \cdot 10^{+28}\right):\\ \;\;\;\;2 \cdot \left(x \cdot y - t_2\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - c \cdot \left(a \cdot i\right)\right)\\ \end{array} \]
Alternative 4
Error10.5
Cost2248
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := i \cdot \left(c \cdot t_1\right)\\ \mathbf{if}\;t_2 \leq -5 \cdot 10^{+298}:\\ \;\;\;\;\left(c \cdot \left(t_1 \cdot i\right)\right) \cdot -2\\ \mathbf{elif}\;t_2 \leq 1.7 \cdot 10^{+109}:\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - i \cdot \left(a \cdot c\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(x \cdot y - t_2\right)\\ \end{array} \]
Alternative 5
Error9.9
Cost2248
\[\begin{array}{l} t_1 := i \cdot \left(c \cdot \left(a + b \cdot c\right)\right)\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+194}:\\ \;\;\;\;\left(\left(c \cdot i\right) \cdot \left(b \cdot c\right) + a \cdot \left(c \cdot i\right)\right) \cdot -2\\ \mathbf{elif}\;t_1 \leq 1.7 \cdot 10^{+109}:\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - i \cdot \left(a \cdot c\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(x \cdot y - t_1\right)\\ \end{array} \]
Alternative 6
Error22.9
Cost1756
\[\begin{array}{l} t_1 := 2 \cdot \left(z \cdot t - i \cdot \left(a \cdot c\right)\right)\\ t_2 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ t_3 := 2 \cdot \left(x \cdot y - c \cdot \left(c \cdot \left(b \cdot i\right)\right)\right)\\ \mathbf{if}\;x \leq -4 \cdot 10^{+67}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.46 \cdot 10^{+38}:\\ \;\;\;\;\left(c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)\right) \cdot -2\\ \mathbf{elif}\;x \leq -3.05 \cdot 10^{-176}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-155}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.25 \cdot 10^{-119}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-70}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{-54}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error21.8
Cost1234
\[\begin{array}{l} \mathbf{if}\;x \leq -1.45 \cdot 10^{+71} \lor \neg \left(x \leq -1.18 \cdot 10^{+38} \lor \neg \left(x \leq -2.85 \cdot 10^{-176}\right) \land x \leq 3.6 \cdot 10^{-169}\right):\\ \;\;\;\;2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t - i \cdot \left(a \cdot c\right)\right)\\ \end{array} \]
Alternative 8
Error22.2
Cost1233
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{if}\;x \leq -4 \cdot 10^{+67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.05 \cdot 10^{+38}:\\ \;\;\;\;\left(c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)\right) \cdot -2\\ \mathbf{elif}\;x \leq -3.3 \cdot 10^{-176} \lor \neg \left(x \leq 6.6 \cdot 10^{-174}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t - i \cdot \left(a \cdot c\right)\right)\\ \end{array} \]
Alternative 9
Error2.0
Cost1216
\[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(a + b \cdot c\right) \cdot \left(c \cdot i\right)\right) \]
Alternative 10
Error37.0
Cost1114
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y\right)\\ \mathbf{if}\;x \leq -3.1 \cdot 10^{+68}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.46 \cdot 10^{+38}:\\ \;\;\;\;i \cdot \left(\left(a \cdot c\right) \cdot -2\right)\\ \mathbf{elif}\;x \leq -0.018 \lor \neg \left(x \leq -1.26 \cdot 10^{-142} \lor \neg \left(x \leq -3.3 \cdot 10^{-176}\right) \land x \leq 4 \cdot 10^{-67}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t\right)\\ \end{array} \]
Alternative 11
Error36.4
Cost850
\[\begin{array}{l} \mathbf{if}\;x \leq -0.0055 \lor \neg \left(x \leq -1.36 \cdot 10^{-145} \lor \neg \left(x \leq -3.3 \cdot 10^{-176}\right) \land x \leq 4 \cdot 10^{-67}\right):\\ \;\;\;\;2 \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t\right)\\ \end{array} \]
Alternative 12
Error23.7
Cost841
\[\begin{array}{l} \mathbf{if}\;c \leq -5500 \lor \neg \left(c \leq -2.6 \cdot 10^{-32}\right):\\ \;\;\;\;2 \cdot \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;i \cdot \left(\left(a \cdot c\right) \cdot -2\right)\\ \end{array} \]
Alternative 13
Error42.6
Cost320
\[2 \cdot \left(z \cdot t\right) \]

Error

Reproduce?

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