Average Error: 6.3 → 1.5
Time: 9.2s
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} \mathbf{if}\;i \leq -3.5147571057147903 \cdot 10^{-28}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(i, c \cdot \left(-\mathsf{fma}\left(c, b, a\right)\right), y \cdot x\right)\right)\\ \mathbf{elif}\;i \leq 4.85756880567276 \cdot 10^{-284}:\\ \;\;\;\;2 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - c \cdot \left(i \cdot \mathsf{fma}\left(c, b, a\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(\mathsf{fma}\left(b, c, a\right), i \cdot \left(-c\right), y \cdot x\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
 (if (<= i -3.5147571057147903e-28)
   (* 2.0 (fma z t (fma i (* c (- (fma c b a))) (* y x))))
   (if (<= i 4.85756880567276e-284)
     (* 2.0 (- (fma t z (* y x)) (* c (* i (fma c b a)))))
     (* 2.0 (fma z t (fma (fma b c a) (* i (- c)) (* y x)))))))
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 tmp;
	if (i <= -3.5147571057147903e-28) {
		tmp = 2.0 * fma(z, t, fma(i, (c * -fma(c, b, a)), (y * x)));
	} else if (i <= 4.85756880567276e-284) {
		tmp = 2.0 * (fma(t, z, (y * x)) - (c * (i * fma(c, b, a))));
	} else {
		tmp = 2.0 * fma(z, t, fma(fma(b, c, a), (i * -c), (y * x)));
	}
	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)
	tmp = 0.0
	if (i <= -3.5147571057147903e-28)
		tmp = Float64(2.0 * fma(z, t, fma(i, Float64(c * Float64(-fma(c, b, a))), Float64(y * x))));
	elseif (i <= 4.85756880567276e-284)
		tmp = Float64(2.0 * Float64(fma(t, z, Float64(y * x)) - Float64(c * Float64(i * fma(c, b, a)))));
	else
		tmp = Float64(2.0 * fma(z, t, fma(fma(b, c, a), Float64(i * Float64(-c)), Float64(y * x))));
	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_] := If[LessEqual[i, -3.5147571057147903e-28], N[(2.0 * N[(z * t + N[(i * N[(c * (-N[(c * b + a), $MachinePrecision])), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 4.85756880567276e-284], N[(2.0 * N[(N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision] - N[(c * N[(i * N[(c * b + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(z * t + N[(N[(b * c + a), $MachinePrecision] * N[(i * (-c)), $MachinePrecision] + N[(y * x), $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}
\mathbf{if}\;i \leq -3.5147571057147903 \cdot 10^{-28}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(i, c \cdot \left(-\mathsf{fma}\left(c, b, a\right)\right), y \cdot x\right)\right)\\

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

\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(z, t, \mathsf{fma}\left(\mathsf{fma}\left(b, c, a\right), i \cdot \left(-c\right), y \cdot x\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.3
Target1.8
Herbie1.5
\[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 < -3.5147571057147903e-28

    1. Initial program 1.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. 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)} \]
    3. Taylor expanded in b around 0 18.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. Simplified1.0

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

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

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

    if -3.5147571057147903e-28 < i < 4.85756880567276e-284

    1. Initial program 10.6

      \[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. Simplified2.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 z around 0 9.2

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

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

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

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

    if 4.85756880567276e-284 < i

    1. Initial program 6.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. Simplified1.5

      \[\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. Recombined 3 regimes into one program.
  4. Final simplification1.5

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

Reproduce

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