Average Error: 6.5 → 3.2
Time: 8.0s
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 := \mathsf{fma}\left(x, y, z \cdot t\right)\\ \mathbf{if}\;i \leq -2.6378528681345606 \cdot 10^{-9} \lor \neg \left(i \leq 7.385109817341934 \cdot 10^{-75}\right):\\ \;\;\;\;2 \cdot \left(t_1 - i \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(t_1 - c \cdot \left(i \cdot \left(a + c \cdot b\right)\right)\right)\\ \end{array} \]
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 := \mathsf{fma}\left(x, y, z \cdot t\right)\\
\mathbf{if}\;i \leq -2.6378528681345606 \cdot 10^{-9} \lor \neg \left(i \leq 7.385109817341934 \cdot 10^{-75}\right):\\
\;\;\;\;2 \cdot \left(t_1 - i \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \left(t_1 - c \cdot \left(i \cdot \left(a + c \cdot b\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 (fma x y (* z t))))
   (if (or (<= i -2.6378528681345606e-9) (not (<= i 7.385109817341934e-75)))
     (* 2.0 (- t_1 (* i (* c (fma c b a)))))
     (* 2.0 (- t_1 (* c (* i (+ a (* c b)))))))))
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 = fma(x, y, (z * t));
	double tmp;
	if ((i <= -2.6378528681345606e-9) || !(i <= 7.385109817341934e-75)) {
		tmp = 2.0 * (t_1 - (i * (c * fma(c, b, a))));
	} else {
		tmp = 2.0 * (t_1 - (c * (i * (a + (c * b)))));
	}
	return tmp;
}

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
Target3.6
Herbie3.2
\[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 < -2.6378528681345606e-9 or 7.3851098173419336e-75 < i

    1. Initial program 4.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. Simplified3.8

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

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

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

    if -2.6378528681345606e-9 < i < 7.3851098173419336e-75

    1. Initial program 9.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. Simplified9.4

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

      \[\leadsto 2 \cdot \left(\mathsf{fma}\left(x, y, z \cdot t\right) - \left(c \cdot \mathsf{fma}\left(b, c, a\right)\right) \cdot \color{blue}{\left(\left(\sqrt[3]{i} \cdot \sqrt[3]{i}\right) \cdot \sqrt[3]{i}\right)}\right) \]
    4. Applied associate-*r*_binary649.5

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

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

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

Reproduce

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