Average Error: 6.1 → 0.7
Time: 8.9s
Precision: binary64
\[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 \mathsf{fma}\left(z, t, \mathsf{fma}\left(y, x, c \cdot \left(c \cdot \left(i \cdot \left(-b\right)\right) - a \cdot i\right)\right)\right)\\ t_2 := c \cdot \left(a + b \cdot c\right)\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+282}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(-i, c \cdot \mathsf{fma}\left(c, b, a\right), y \cdot x\right)\right)\\ \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 (fma z t (fma y x (* c (- (* c (* i (- b))) (* a i)))))))
        (t_2 (* c (+ a (* b c)))))
   (if (<= t_2 (- INFINITY))
     t_1
     (if (<= t_2 2e+282)
       (* 2.0 (fma z t (fma (- i) (* c (fma c b a)) (* y x))))
       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 * fma(z, t, fma(y, x, (c * ((c * (i * -b)) - (a * i)))));
	double t_2 = c * (a + (b * c));
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_2 <= 2e+282) {
		tmp = 2.0 * fma(z, t, fma(-i, (c * fma(c, b, a)), (y * x)));
	} 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 * fma(z, t, fma(y, x, Float64(c * Float64(Float64(c * Float64(i * Float64(-b))) - Float64(a * i))))))
	t_2 = Float64(c * Float64(a + Float64(b * c)))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_2 <= 2e+282)
		tmp = Float64(2.0 * fma(z, t, fma(Float64(-i), Float64(c * fma(c, b, a)), Float64(y * x))));
	else
		tmp = t_1;
	end
	return 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[(z * t + N[(y * x + N[(c * N[(N[(c * N[(i * (-b)), $MachinePrecision]), $MachinePrecision] - N[(a * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(c * N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 2e+282], N[(2.0 * N[(z * t + N[((-i) * N[(c * N[(c * b + a), $MachinePrecision]), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 \mathsf{fma}\left(z, t, \mathsf{fma}\left(y, x, c \cdot \left(c \cdot \left(i \cdot \left(-b\right)\right) - a \cdot i\right)\right)\right)\\
t_2 := c \cdot \left(a + b \cdot c\right)\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+282}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(-i, c \cdot \mathsf{fma}\left(c, b, a\right), y \cdot x\right)\right)\\

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


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus i

Target

Original6.1
Target1.8
Herbie0.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 a (*.f64 b c)) c) < -inf.0 or 2.00000000000000007e282 < (*.f64 (+.f64 a (*.f64 b c)) c)

    1. Initial program 57.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) \]
    2. Simplified9.8

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

      \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, \color{blue}{-1 \cdot \left(c \cdot \left(i \cdot a\right)\right) + \left(y \cdot x + -1 \cdot \left({c}^{2} \cdot \left(i \cdot b\right)\right)\right)}\right) \]
    4. Simplified57.4

      \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, \color{blue}{y \cdot x - i \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)}\right) \]
    5. Applied egg-rr57.4

      \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, \color{blue}{\mathsf{fma}\left(y, x, \mathsf{fma}\left(i, \mathsf{fma}\left(c, b, a\right) \cdot \left(-c\right), \mathsf{fma}\left(i, \mathsf{fma}\left(c, b, a\right) \cdot \left(-c\right), \mathsf{fma}\left(c, b, a\right) \cdot \left(i \cdot c\right)\right)\right)\right)}\right) \]
    6. Taylor expanded in i around 0 57.6

      \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(y, x, \color{blue}{\left(c \cdot \left(c \cdot b + a\right) + -2 \cdot \left(c \cdot \left(c \cdot b + a\right)\right)\right) \cdot i}\right)\right) \]
    7. Simplified9.8

      \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(y, x, \color{blue}{c \cdot \left(-i \cdot \mathsf{fma}\left(c, b, a\right)\right)}\right)\right) \]
    8. Taylor expanded in c around 0 4.1

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

    if -inf.0 < (*.f64 (+.f64 a (*.f64 b c)) c) < 2.00000000000000007e282

    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) \]
    2. Simplified0.9

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

      \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, \color{blue}{-1 \cdot \left(c \cdot \left(i \cdot a\right)\right) + \left(y \cdot x + -1 \cdot \left({c}^{2} \cdot \left(i \cdot b\right)\right)\right)}\right) \]
    4. Simplified0.3

      \[\leadsto 2 \cdot \mathsf{fma}\left(z, t, \color{blue}{y \cdot x - i \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)}\right) \]
    5. Applied egg-rr0.3

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

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

Reproduce

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