Average Error: 6.5 → 2.0
Time: 8.3s
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 := -i \cdot c\\ t_2 := 2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(\mathsf{fma}\left(b, c, a\right), t_1, x \cdot y\right)\right)\\ \mathbf{if}\;i \leq -1.85 \cdot 10^{-227}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;i \leq -1.38 \cdot 10^{-306}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(y, x, c \cdot \left(b \cdot t_1\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \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 (- (* i c)))
        (t_2 (* 2.0 (fma z t (fma (fma b c a) t_1 (* x y))))))
   (if (<= i -1.85e-227)
     t_2
     (if (<= i -1.38e-306) (* 2.0 (fma z t (fma y x (* c (* b t_1))))) t_2))))
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 = -(i * c);
	double t_2 = 2.0 * fma(z, t, fma(fma(b, c, a), t_1, (x * y)));
	double tmp;
	if (i <= -1.85e-227) {
		tmp = t_2;
	} else if (i <= -1.38e-306) {
		tmp = 2.0 * fma(z, t, fma(y, x, (c * (b * t_1))));
	} else {
		tmp = t_2;
	}
	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(i * c))
	t_2 = Float64(2.0 * fma(z, t, fma(fma(b, c, a), t_1, Float64(x * y))))
	tmp = 0.0
	if (i <= -1.85e-227)
		tmp = t_2;
	elseif (i <= -1.38e-306)
		tmp = Float64(2.0 * fma(z, t, fma(y, x, Float64(c * Float64(b * t_1)))));
	else
		tmp = t_2;
	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[(i * c), $MachinePrecision])}, Block[{t$95$2 = N[(2.0 * N[(z * t + N[(N[(b * c + a), $MachinePrecision] * t$95$1 + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[i, -1.85e-227], t$95$2, If[LessEqual[i, -1.38e-306], N[(2.0 * N[(z * t + N[(y * x + N[(c * N[(b * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
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 := -i \cdot c\\
t_2 := 2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(\mathsf{fma}\left(b, c, a\right), t_1, x \cdot y\right)\right)\\
\mathbf{if}\;i \leq -1.85 \cdot 10^{-227}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;i \leq -1.38 \cdot 10^{-306}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(y, x, c \cdot \left(b \cdot t_1\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\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.5
Target1.9
Herbie2.0
\[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 i < -1.84999999999999989e-227 or -1.3799999999999999e-306 < i

    1. Initial program 5.7

      \[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. Simplified1.6

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

    if -1.84999999999999989e-227 < i < -1.3799999999999999e-306

    1. Initial program 15.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. Simplified4.3

      \[\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 a around 0 14.0

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

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

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

Reproduce

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