Average Error: 6.6 → 0.6
Time: 14.7s
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 := x \cdot y + z \cdot t\\ \mathbf{if}\;i \leq -1.052379155071738 \cdot 10^{+64}:\\ \;\;\;\;2 \cdot \left(t_1 - \left(\left(i \cdot c\right) \cdot \left(c \cdot b\right) + \left(i \cdot c\right) \cdot a\right)\right)\\ \mathbf{elif}\;i \leq 9.250348944498564 \cdot 10^{+30}:\\ \;\;\;\;2 \cdot \left(t_1 - c \cdot \mathsf{fma}\left(i \cdot c, b, i \cdot a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(1, \mathsf{fma}\left(x, y, z \cdot t\right), -i \cdot \left(c \cdot \mathsf{fma}\left(b, c, a\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))))
   (if (<= i -1.052379155071738e+64)
     (* 2.0 (- t_1 (+ (* (* i c) (* c b)) (* (* i c) a))))
     (if (<= i 9.250348944498564e+30)
       (* 2.0 (- t_1 (* c (fma (* i c) b (* i a)))))
       (* 2.0 (fma 1.0 (fma x y (* z t)) (- (* i (* c (fma b c a))))))))))
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 tmp;
	if (i <= -1.052379155071738e+64) {
		tmp = 2.0 * (t_1 - (((i * c) * (c * b)) + ((i * c) * a)));
	} else if (i <= 9.250348944498564e+30) {
		tmp = 2.0 * (t_1 - (c * fma((i * c), b, (i * a))));
	} else {
		tmp = 2.0 * fma(1.0, fma(x, y, (z * t)), -(i * (c * fma(b, c, a))));
	}
	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))
	tmp = 0.0
	if (i <= -1.052379155071738e+64)
		tmp = Float64(2.0 * Float64(t_1 - Float64(Float64(Float64(i * c) * Float64(c * b)) + Float64(Float64(i * c) * a))));
	elseif (i <= 9.250348944498564e+30)
		tmp = Float64(2.0 * Float64(t_1 - Float64(c * fma(Float64(i * c), b, Float64(i * a)))));
	else
		tmp = Float64(2.0 * fma(1.0, fma(x, y, Float64(z * t)), Float64(-Float64(i * Float64(c * fma(b, c, a))))));
	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[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[i, -1.052379155071738e+64], N[(2.0 * N[(t$95$1 - N[(N[(N[(i * c), $MachinePrecision] * N[(c * b), $MachinePrecision]), $MachinePrecision] + N[(N[(i * c), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 9.250348944498564e+30], N[(2.0 * N[(t$95$1 - N[(c * N[(N[(i * c), $MachinePrecision] * b + N[(i * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(1.0 * N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision] + (-N[(i * N[(c * N[(b * c + a), $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\\
\mathbf{if}\;i \leq -1.052379155071738 \cdot 10^{+64}:\\
\;\;\;\;2 \cdot \left(t_1 - \left(\left(i \cdot c\right) \cdot \left(c \cdot b\right) + \left(i \cdot c\right) \cdot a\right)\right)\\

\mathbf{elif}\;i \leq 9.250348944498564 \cdot 10^{+30}:\\
\;\;\;\;2 \cdot \left(t_1 - c \cdot \mathsf{fma}\left(i \cdot c, b, i \cdot a\right)\right)\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(1, \mathsf{fma}\left(x, y, z \cdot t\right), -i \cdot \left(c \cdot \mathsf{fma}\left(b, c, a\right)\right)\right)\\


\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.6
Target1.9
Herbie0.6
\[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 i < -1.052379155071738e64

    1. Initial program 1.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. Taylor expanded in a around 0 23.9

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

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

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

    if -1.052379155071738e64 < i < 9.250348944498564e30

    1. Initial program 9.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) \]
    2. Taylor expanded in a around 0 8.7

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

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

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

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

    if 9.250348944498564e30 < i

    1. Initial program 0.5

      \[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. Applied egg-rr0.5

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

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

Reproduce

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