Average Error: 6.6 → 0.7
Time: 9.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 := c \cdot \left(a + b \cdot c\right)\\ \mathbf{if}\;t_1 \leq -4.6717171267697925 \cdot 10^{+293} \lor \neg \left(t_1 \leq 1.609664909872235 \cdot 10^{+302}\right):\\ \;\;\;\;2 \cdot \left(\mathsf{fma}\left(x, y, z \cdot t\right) - c \cdot \left(c \cdot \left(b \cdot i\right) + a \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\left(z \cdot t + x \cdot y\right) - t_1 \cdot i\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 := c \cdot \left(a + b \cdot c\right)\\
\mathbf{if}\;t_1 \leq -4.6717171267697925 \cdot 10^{+293} \lor \neg \left(t_1 \leq 1.609664909872235 \cdot 10^{+302}\right):\\
\;\;\;\;2 \cdot \left(\mathsf{fma}\left(x, y, z \cdot t\right) - c \cdot \left(c \cdot \left(b \cdot i\right) + a \cdot i\right)\right)\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\left(z \cdot t + x \cdot y\right) - t_1 \cdot i\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 (* c (+ a (* b c)))))
   (if (or (<= t_1 -4.6717171267697925e+293)
           (not (<= t_1 1.609664909872235e+302)))
     (* 2.0 (- (fma x y (* z t)) (* c (+ (* c (* b i)) (* a i)))))
     (* 2.0 (- (+ (* z t) (* x y)) (* t_1 i))))))
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 = c * (a + (b * c));
	double tmp;
	if ((t_1 <= -4.6717171267697925e+293) || !(t_1 <= 1.609664909872235e+302)) {
		tmp = 2.0 * (fma(x, y, (z * t)) - (c * ((c * (b * i)) + (a * i))));
	} else {
		tmp = 2.0 * (((z * t) + (x * y)) - (t_1 * i));
	}
	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.6
Target1.9
Herbie0.7
\[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 (*.f64 (+.f64 a (*.f64 b c)) c) < -4.67171712676979245e293 or 1.60966490987223503e302 < (*.f64 (+.f64 a (*.f64 b c)) c)

    1. Initial program 59.9

      \[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. Simplified59.9

      \[\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 34.6

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

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

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

    if -4.67171712676979245e293 < (*.f64 (+.f64 a (*.f64 b c)) c) < 1.60966490987223503e302

    1. Initial program 0.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) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.7

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

Reproduce

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