?

Average Error: 6.3 → 2.1
Time: 31.3s
Precision: binary64
Cost: 2504

?

\[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 := x \cdot y + z \cdot t\\ t_2 := a + b \cdot c\\ t_3 := \left(t_2 \cdot c\right) \cdot i\\ \mathbf{if}\;t_3 \leq -\infty:\\ \;\;\;\;2 \cdot \left(t_1 - c \cdot \left(t_2 \cdot i\right)\right)\\ \mathbf{elif}\;t_3 \leq 2 \cdot 10^{+284}:\\ \;\;\;\;2 \cdot \left(t_1 - t_3\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(t_1 - c \cdot \left(c \cdot \left(i \cdot b\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 (+ (* x y) (* z t))) (t_2 (+ a (* b c))) (t_3 (* (* t_2 c) i)))
   (if (<= t_3 (- INFINITY))
     (* 2.0 (- t_1 (* c (* t_2 i))))
     (if (<= t_3 2e+284)
       (* 2.0 (- t_1 t_3))
       (* 2.0 (- t_1 (* c (* c (* i b)))))))))
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 = (x * y) + (z * t);
	double t_2 = a + (b * c);
	double t_3 = (t_2 * c) * i;
	double tmp;
	if (t_3 <= -((double) INFINITY)) {
		tmp = 2.0 * (t_1 - (c * (t_2 * i)));
	} else if (t_3 <= 2e+284) {
		tmp = 2.0 * (t_1 - t_3);
	} else {
		tmp = 2.0 * (t_1 - (c * (c * (i * b))));
	}
	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 = (x * y) + (z * t);
	double t_2 = a + (b * c);
	double t_3 = (t_2 * c) * i;
	double tmp;
	if (t_3 <= -Double.POSITIVE_INFINITY) {
		tmp = 2.0 * (t_1 - (c * (t_2 * i)));
	} else if (t_3 <= 2e+284) {
		tmp = 2.0 * (t_1 - t_3);
	} else {
		tmp = 2.0 * (t_1 - (c * (c * (i * b))));
	}
	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 = (x * y) + (z * t)
	t_2 = a + (b * c)
	t_3 = (t_2 * c) * i
	tmp = 0
	if t_3 <= -math.inf:
		tmp = 2.0 * (t_1 - (c * (t_2 * i)))
	elif t_3 <= 2e+284:
		tmp = 2.0 * (t_1 - t_3)
	else:
		tmp = 2.0 * (t_1 - (c * (c * (i * b))))
	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(Float64(x * y) + Float64(z * t))
	t_2 = Float64(a + Float64(b * c))
	t_3 = Float64(Float64(t_2 * c) * i)
	tmp = 0.0
	if (t_3 <= Float64(-Inf))
		tmp = Float64(2.0 * Float64(t_1 - Float64(c * Float64(t_2 * i))));
	elseif (t_3 <= 2e+284)
		tmp = Float64(2.0 * Float64(t_1 - t_3));
	else
		tmp = Float64(2.0 * Float64(t_1 - Float64(c * Float64(c * Float64(i * b)))));
	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 = (x * y) + (z * t);
	t_2 = a + (b * c);
	t_3 = (t_2 * c) * i;
	tmp = 0.0;
	if (t_3 <= -Inf)
		tmp = 2.0 * (t_1 - (c * (t_2 * i)));
	elseif (t_3 <= 2e+284)
		tmp = 2.0 * (t_1 - t_3);
	else
		tmp = 2.0 * (t_1 - (c * (c * (i * b))));
	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[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(t$95$2 * c), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], N[(2.0 * N[(t$95$1 - N[(c * N[(t$95$2 * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 2e+284], N[(2.0 * N[(t$95$1 - t$95$3), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(t$95$1 - N[(c * N[(c * N[(i * b), $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 := x \cdot y + z \cdot t\\
t_2 := a + b \cdot c\\
t_3 := \left(t_2 \cdot c\right) \cdot i\\
\mathbf{if}\;t_3 \leq -\infty:\\
\;\;\;\;2 \cdot \left(t_1 - c \cdot \left(t_2 \cdot i\right)\right)\\

\mathbf{elif}\;t_3 \leq 2 \cdot 10^{+284}:\\
\;\;\;\;2 \cdot \left(t_1 - t_3\right)\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.3
Target1.9
Herbie2.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. Split input into 3 regimes
  2. if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -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. Simplified12.1

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

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

      rational_best-simplify-2 [=>]64.0

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

      rational_best-simplify-2 [=>]64.0

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

      rational_best-simplify-44 [=>]12.1

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

      rational_best-simplify-2 [=>]12.1

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

    if -inf.0 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 2.00000000000000016e284

    1. Initial program 0.3

      \[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 2.00000000000000016e284 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i)

    1. Initial program 54.3

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

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

      [Start]54.3

      \[ 2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right) \]

      rational_best-simplify-2 [=>]54.3

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

      rational_best-simplify-2 [=>]54.3

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

      rational_best-simplify-44 [=>]13.1

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

      rational_best-simplify-2 [=>]13.1

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

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

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

Alternatives

Alternative 1
Error11.3
Cost2128
\[\begin{array}{l} t_1 := 2 \cdot \left(\left(x \cdot y + z \cdot t\right) - c \cdot \left(c \cdot \left(i \cdot b\right)\right)\right)\\ t_2 := 2 \cdot \left(y \cdot x - \left(a + c \cdot b\right) \cdot \left(c \cdot i\right)\right)\\ \mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+79}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \cdot t \leq -500:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \cdot t \leq -5 \cdot 10^{-142}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{-104}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error2.0
Cost2048
\[\begin{array}{l} t_1 := a + c \cdot b\\ 2 \cdot \left(\left(\left(t \cdot z + y \cdot x\right) + t_1 \cdot \left(c \cdot i\right)\right) + \left(-t_1 \cdot \left(c \cdot \left(i + i\right)\right)\right)\right) \end{array} \]
Alternative 3
Error17.6
Cost1752
\[\begin{array}{l} t_1 := 2 \cdot \left(y \cdot x - \left(a + c \cdot b\right) \cdot \left(c \cdot i\right)\right)\\ t_2 := 2 \cdot \left(t \cdot z - c \cdot \left(i \cdot \left(c \cdot b + a\right)\right)\right)\\ t_3 := 2 \cdot \left(y \cdot x + t \cdot z\right)\\ \mathbf{if}\;y \leq -4.8 \cdot 10^{-111}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 3.45 \cdot 10^{-78}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{-59}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{+43}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 6.3 \cdot 10^{+119}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{+136}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error22.3
Cost1628
\[\begin{array}{l} t_1 := \left(c \cdot b + a\right) \cdot \left(-2 \cdot \left(c \cdot i\right)\right)\\ t_2 := 2 \cdot \left(y \cdot x - \left(c \cdot b\right) \cdot \left(c \cdot i\right)\right)\\ t_3 := 2 \cdot \left(y \cdot x + t \cdot z\right)\\ \mathbf{if}\;t \leq -1 \cdot 10^{-156}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 7.2 \cdot 10^{-278}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 2.15 \cdot 10^{-229}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 1.3 \cdot 10^{-215}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.65 \cdot 10^{-208}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 2.9 \cdot 10^{-112}:\\ \;\;\;\;2 \cdot \left(y \cdot x - i \cdot \left(c \cdot a\right)\right)\\ \mathbf{elif}\;t \leq 1.55 \cdot 10^{-62}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 5
Error19.0
Cost1628
\[\begin{array}{l} t_1 := 2 \cdot \left(y \cdot x + t \cdot z\right)\\ t_2 := c \cdot b + a\\ t_3 := 2 \cdot \left(t \cdot z - c \cdot \left(i \cdot t_2\right)\right)\\ \mathbf{if}\;y \leq -9 \cdot 10^{-108}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.42 \cdot 10^{-77}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-60}:\\ \;\;\;\;2 \cdot \left(y \cdot x - i \cdot \left(c \cdot a\right)\right)\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{+46}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 5.7 \cdot 10^{+119}:\\ \;\;\;\;2 \cdot \left(y \cdot x - \left(c \cdot b\right) \cdot \left(c \cdot i\right)\right)\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{+175}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{+192}:\\ \;\;\;\;t_2 \cdot \left(-2 \cdot \left(c \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error40.8
Cost1504
\[\begin{array}{l} t_1 := 2 \cdot \left(t \cdot z\right)\\ t_2 := 2 \cdot \left(y \cdot x\right)\\ t_3 := \left(-2 \cdot a\right) \cdot \left(c \cdot i\right)\\ \mathbf{if}\;a \leq -6.8 \cdot 10^{+104}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -1.85 \cdot 10^{+70}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -365000:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -1.45 \cdot 10^{-130}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 4.7 \cdot 10^{-238}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 0.18:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 5.2 \cdot 10^{+62}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 1.6 \cdot 10^{+160}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 7
Error5.5
Cost1348
\[\begin{array}{l} \mathbf{if}\;i \leq -4.3 \cdot 10^{+158}:\\ \;\;\;\;2 \cdot \left(y \cdot x - \left(a + c \cdot b\right) \cdot \left(c \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)\right)\\ \end{array} \]
Alternative 8
Error22.7
Cost1036
\[\begin{array}{l} \mathbf{if}\;c \leq -1.42 \cdot 10^{+208}:\\ \;\;\;\;\left(i \cdot a\right) \cdot \left(c \cdot -2\right)\\ \mathbf{elif}\;c \leq -1.68 \cdot 10^{+25}:\\ \;\;\;\;2 \cdot \left(y \cdot x - i \cdot \left(c \cdot a\right)\right)\\ \mathbf{elif}\;c \leq 1.02 \cdot 10^{+138}:\\ \;\;\;\;2 \cdot \left(y \cdot x + t \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(c \cdot \left(\left(i \cdot \left(-c\right)\right) \cdot b\right)\right)\\ \end{array} \]
Alternative 9
Error20.3
Cost968
\[\begin{array}{l} t_1 := \left(c \cdot \left(i \cdot \left(a + c \cdot b\right)\right)\right) \cdot -2\\ \mathbf{if}\;c \leq -2.05 \cdot 10^{+34}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 2.35 \cdot 10^{+135}:\\ \;\;\;\;2 \cdot \left(y \cdot x + t \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error20.4
Cost968
\[\begin{array}{l} \mathbf{if}\;c \leq -2.05 \cdot 10^{+34}:\\ \;\;\;\;\left(c \cdot \left(i \cdot \left(a + c \cdot b\right)\right)\right) \cdot -2\\ \mathbf{elif}\;c \leq 1.75 \cdot 10^{+135}:\\ \;\;\;\;2 \cdot \left(y \cdot x + t \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(c \cdot b + a\right) \cdot \left(-2 \cdot \left(c \cdot i\right)\right)\\ \end{array} \]
Alternative 11
Error22.0
Cost904
\[\begin{array}{l} \mathbf{if}\;c \leq -6 \cdot 10^{+214}:\\ \;\;\;\;\left(i \cdot a\right) \cdot \left(c \cdot -2\right)\\ \mathbf{elif}\;c \leq 6.6 \cdot 10^{+136}:\\ \;\;\;\;2 \cdot \left(y \cdot x + t \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(c \cdot \left(\left(i \cdot \left(-c\right)\right) \cdot b\right)\right)\\ \end{array} \]
Alternative 12
Error22.5
Cost708
\[\begin{array}{l} \mathbf{if}\;c \leq -3.3 \cdot 10^{+221}:\\ \;\;\;\;\left(i \cdot a\right) \cdot \left(c \cdot -2\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(y \cdot x + t \cdot z\right)\\ \end{array} \]
Alternative 13
Error36.1
Cost584
\[\begin{array}{l} t_1 := 2 \cdot \left(y \cdot x\right)\\ \mathbf{if}\;y \leq -2.9 \cdot 10^{-107}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 7.8 \cdot 10^{+43}:\\ \;\;\;\;2 \cdot \left(t \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 14
Error42.1
Cost320
\[2 \cdot \left(t \cdot z\right) \]

Error

Reproduce?

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