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

\mathbf{elif}\;i \leq 1.4 \cdot 10^{-288}:\\
\;\;\;\;2 \cdot \left(\left(z \cdot t + x \cdot y\right) - c \cdot \left(b \cdot \left(i \cdot c\right)\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.5
Target2.0
Herbie1.9
\[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 < -7.60000000000000024e-223 or 1.4e-288 < i

    1. Initial program 5.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. 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 -7.60000000000000024e-223 < i < 1.4e-288

    1. Initial program 14.8

      \[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.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 11.4

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

      \[\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-rr5.0

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -7.6 \cdot 10^{-223}:\\ \;\;\;\;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.4 \cdot 10^{-288}:\\ \;\;\;\;2 \cdot \left(\left(z \cdot t + x \cdot y\right) - c \cdot \left(b \cdot \left(i \cdot c\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 2022165 
(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))))