Average Error: 6.1 → 1.7
Time: 31.5s
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 := 2 \cdot \left(z \cdot t - \left(c \cdot \left(b \cdot \left(c \cdot i\right)\right) + c \cdot \left(a \cdot i\right)\right)\right)\\ t_2 := \left(c \cdot \left(a + b \cdot c\right)\right) \cdot i\\ \mathbf{if}\;t_2 \leq -4 \cdot 10^{+287}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 4 \cdot 10^{+286}:\\ \;\;\;\;\left(\left(z \cdot t + x \cdot y\right) - t_2\right) \cdot 2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 (* 2.0 (- (* z t) (+ (* c (* b (* c i))) (* c (* a i))))))
        (t_2 (* (* c (+ a (* b c))) i)))
   (if (<= t_2 -4e+287)
     t_1
     (if (<= t_2 4e+286) (* (- (+ (* z t) (* x y)) t_2) 2.0) t_1))))
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 = 2.0 * ((z * t) - ((c * (b * (c * i))) + (c * (a * i))));
	double t_2 = (c * (a + (b * c))) * i;
	double tmp;
	if (t_2 <= -4e+287) {
		tmp = t_1;
	} else if (t_2 <= 4e+286) {
		tmp = (((z * t) + (x * y)) - t_2) * 2.0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: i
    code = 2.0d0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))
end function
real(8) function code(x, y, z, t, a, b, c, i)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: i
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = 2.0d0 * ((z * t) - ((c * (b * (c * i))) + (c * (a * i))))
    t_2 = (c * (a + (b * c))) * i
    if (t_2 <= (-4d+287)) then
        tmp = t_1
    else if (t_2 <= 4d+286) then
        tmp = (((z * t) + (x * y)) - t_2) * 2.0d0
    else
        tmp = t_1
    end if
    code = tmp
end function
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 = 2.0 * ((z * t) - ((c * (b * (c * i))) + (c * (a * i))));
	double t_2 = (c * (a + (b * c))) * i;
	double tmp;
	if (t_2 <= -4e+287) {
		tmp = t_1;
	} else if (t_2 <= 4e+286) {
		tmp = (((z * t) + (x * y)) - t_2) * 2.0;
	} else {
		tmp = t_1;
	}
	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 = 2.0 * ((z * t) - ((c * (b * (c * i))) + (c * (a * i))))
	t_2 = (c * (a + (b * c))) * i
	tmp = 0
	if t_2 <= -4e+287:
		tmp = t_1
	elif t_2 <= 4e+286:
		tmp = (((z * t) + (x * y)) - t_2) * 2.0
	else:
		tmp = t_1
	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(2.0 * Float64(Float64(z * t) - Float64(Float64(c * Float64(b * Float64(c * i))) + Float64(c * Float64(a * i)))))
	t_2 = Float64(Float64(c * Float64(a + Float64(b * c))) * i)
	tmp = 0.0
	if (t_2 <= -4e+287)
		tmp = t_1;
	elseif (t_2 <= 4e+286)
		tmp = Float64(Float64(Float64(Float64(z * t) + Float64(x * y)) - t_2) * 2.0);
	else
		tmp = t_1;
	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 = 2.0 * ((z * t) - ((c * (b * (c * i))) + (c * (a * i))));
	t_2 = (c * (a + (b * c))) * i;
	tmp = 0.0;
	if (t_2 <= -4e+287)
		tmp = t_1;
	elseif (t_2 <= 4e+286)
		tmp = (((z * t) + (x * y)) - t_2) * 2.0;
	else
		tmp = t_1;
	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[(2.0 * N[(N[(z * t), $MachinePrecision] - N[(N[(c * N[(b * N[(c * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c * N[(a * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[t$95$2, -4e+287], t$95$1, If[LessEqual[t$95$2, 4e+286], N[(N[(N[(N[(z * t), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision] * 2.0), $MachinePrecision], t$95$1]]]]
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 := 2 \cdot \left(z \cdot t - \left(c \cdot \left(b \cdot \left(c \cdot i\right)\right) + c \cdot \left(a \cdot i\right)\right)\right)\\
t_2 := \left(c \cdot \left(a + b \cdot c\right)\right) \cdot i\\
\mathbf{if}\;t_2 \leq -4 \cdot 10^{+287}:\\
\;\;\;\;t_1\\

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

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.1
Target1.8
Herbie1.7
\[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 2 regimes
  2. if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -4.0000000000000003e287 or 4.00000000000000013e286 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i)

    1. Initial program 53.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 x around 0 19.4

      \[\leadsto 2 \cdot \color{blue}{\left(t \cdot z - c \cdot \left(i \cdot \left(c \cdot b + a\right)\right)\right)} \]
    3. Applied egg-rr12.4

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

    if -4.0000000000000003e287 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 4.00000000000000013e286

    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) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.7

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

Alternatives

Alternative 1
Error2.1
Cost8644
\[\begin{array}{l} t_1 := a + b \cdot c\\ \mathbf{if}\;\left(z \cdot t + x \cdot y\right) - \left(c \cdot t_1\right) \cdot i \leq 2 \cdot 10^{+299}:\\ \;\;\;\;2 \cdot \left(\mathsf{fma}\left(x, y, z \cdot t\right) - t_1 \cdot \left(c \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t - \left(c \cdot \left(b \cdot \left(c \cdot i\right)\right) + c \cdot \left(a \cdot i\right)\right)\right)\\ \end{array} \]
Alternative 2
Error10.5
Cost3536
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := \left(c \cdot t_1\right) \cdot i\\ t_3 := 2 \cdot \left(z \cdot t - t_2\right)\\ \mathbf{if}\;t_2 \leq -4 \cdot 10^{+287}:\\ \;\;\;\;2 \cdot \left(z \cdot t - b \cdot \left(c \cdot \left(c \cdot i\right)\right)\right)\\ \mathbf{elif}\;t_2 \leq -2 \cdot 10^{-10}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq 4000000000000:\\ \;\;\;\;2 \cdot \left(z \cdot t + x \cdot y\right)\\ \mathbf{elif}\;t_2 \leq 4 \cdot 10^{+286}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t - c \cdot \left(t_1 \cdot i\right)\right)\\ \end{array} \]
Alternative 3
Error10.2
Cost2892
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := 2 \cdot \left(z \cdot t - t_1 \cdot \left(c \cdot i\right)\right)\\ t_3 := \left(c \cdot t_1\right) \cdot i\\ \mathbf{if}\;t_3 \leq -\infty:\\ \;\;\;\;2 \cdot \left(z \cdot t - b \cdot \left(c \cdot \left(c \cdot i\right)\right)\right)\\ \mathbf{elif}\;t_3 \leq -2 \cdot 10^{-10}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_3 \leq 4000000000000:\\ \;\;\;\;2 \cdot \left(z \cdot t + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error7.8
Cost2892
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := \left(c \cdot t_1\right) \cdot i\\ \mathbf{if}\;t_2 \leq -4 \cdot 10^{+287}:\\ \;\;\;\;2 \cdot \left(z \cdot t - b \cdot \left(c \cdot \left(c \cdot i\right)\right)\right)\\ \mathbf{elif}\;t_2 \leq -2 \cdot 10^{+115}:\\ \;\;\;\;2 \cdot \left(x \cdot y - t_2\right)\\ \mathbf{elif}\;t_2 \leq 4000000000000:\\ \;\;\;\;2 \cdot \left(\left(z \cdot t + x \cdot y\right) - i \cdot \left(a \cdot c\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t - t_1 \cdot \left(c \cdot i\right)\right)\\ \end{array} \]
Alternative 5
Error6.6
Cost2892
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := \left(c \cdot t_1\right) \cdot i\\ \mathbf{if}\;t_2 \leq -4 \cdot 10^{+287}:\\ \;\;\;\;2 \cdot \left(z \cdot t - \left(c \cdot \left(b \cdot \left(c \cdot i\right)\right) + c \cdot \left(a \cdot i\right)\right)\right)\\ \mathbf{elif}\;t_2 \leq -2 \cdot 10^{+115}:\\ \;\;\;\;2 \cdot \left(x \cdot y - t_2\right)\\ \mathbf{elif}\;t_2 \leq 4000000000000:\\ \;\;\;\;2 \cdot \left(\left(z \cdot t + x \cdot y\right) - i \cdot \left(a \cdot c\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t - t_1 \cdot \left(c \cdot i\right)\right)\\ \end{array} \]
Alternative 6
Error2.1
Cost2372
\[\begin{array}{l} t_1 := a + b \cdot c\\ t_2 := z \cdot t + x \cdot y\\ \mathbf{if}\;t_2 - \left(c \cdot t_1\right) \cdot i \leq 2 \cdot 10^{+299}:\\ \;\;\;\;2 \cdot \left(t_2 - t_1 \cdot \left(c \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(z \cdot t - \left(c \cdot \left(b \cdot \left(c \cdot i\right)\right) + c \cdot \left(a \cdot i\right)\right)\right)\\ \end{array} \]
Alternative 7
Error21.9
Cost1496
\[\begin{array}{l} t_1 := a \cdot \left(c \cdot i\right)\\ t_2 := 2 \cdot \left(z \cdot t + x \cdot y\right)\\ t_3 := 2 \cdot \left(x \cdot y - t_1\right)\\ t_4 := 2 \cdot \left(z \cdot t - t_1\right)\\ \mathbf{if}\;t \leq -7.5 \cdot 10^{-267}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 2 \cdot 10^{-90}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 1.46 \cdot 10^{-18}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 5 \cdot 10^{+17}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 5.2 \cdot 10^{+67}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq 9.6 \cdot 10^{+214}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_4\\ \end{array} \]
Alternative 8
Error37.1
Cost1244
\[\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 -5.5 \cdot 10^{+121}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2.4 \cdot 10^{+99}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.3 \cdot 10^{+45}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{+30}:\\ \;\;\;\;a \cdot \left(\left(c \cdot i\right) \cdot -2\right)\\ \mathbf{elif}\;z \leq -5.8 \cdot 10^{-217}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.6 \cdot 10^{-244}:\\ \;\;\;\;i \cdot \left(a \cdot \left(c \cdot -2\right)\right)\\ \mathbf{elif}\;z \leq 9.8 \cdot 10^{-129}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Error17.0
Cost1224
\[\begin{array}{l} t_1 := 2 \cdot \left(z \cdot t + x \cdot y\right)\\ \mathbf{if}\;y \leq -2 \cdot 10^{-124}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 7 \cdot 10^{-41}:\\ \;\;\;\;2 \cdot \left(z \cdot t - c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error23.3
Cost1104
\[\begin{array}{l} t_1 := 2 \cdot \left(z \cdot t + x \cdot y\right)\\ \mathbf{if}\;z \leq -1.3 \cdot 10^{+45}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{+30}:\\ \;\;\;\;a \cdot \left(\left(c \cdot i\right) \cdot -2\right)\\ \mathbf{elif}\;z \leq -5.8 \cdot 10^{-217}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.6 \cdot 10^{-244}:\\ \;\;\;\;i \cdot \left(a \cdot \left(c \cdot -2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error21.3
Cost1100
\[\begin{array}{l} t_1 := 2 \cdot \left(z \cdot t + x \cdot y\right)\\ t_2 := \left(c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)\right) \cdot -2\\ \mathbf{if}\;c \leq -5.6 \cdot 10^{+35}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.1 \cdot 10^{-78}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 6 \cdot 10^{-65}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error36.7
Cost980
\[\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 -5.5 \cdot 10^{+121}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{+100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.3 \cdot 10^{+45}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{+30}:\\ \;\;\;\;a \cdot \left(\left(c \cdot i\right) \cdot -2\right)\\ \mathbf{elif}\;z \leq 9.8 \cdot 10^{-129}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 13
Error20.5
Cost968
\[\begin{array}{l} t_1 := 2 \cdot \left(z \cdot t + x \cdot y\right)\\ \mathbf{if}\;y \leq -5.4 \cdot 10^{-144}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-19}:\\ \;\;\;\;2 \cdot \left(z \cdot t - a \cdot \left(c \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 14
Error36.4
Cost848
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot y\right)\\ t_2 := 2 \cdot \left(z \cdot t\right)\\ \mathbf{if}\;t \leq -7 \cdot 10^{-39}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 102000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.3 \cdot 10^{+77}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 7.2 \cdot 10^{+160}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 15
Error42.3
Cost320
\[2 \cdot \left(z \cdot t\right) \]

Error

Reproduce

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