Average Error: 7.7 → 0.8
Time: 13.1s
Precision: binary64
\[[x, y]=\mathsf{sort}([x, y])\]
\[[z, t]=\mathsf{sort}([z, t])\]
\[\frac{x \cdot y - z \cdot t}{a} \]
\[\begin{array}{l} \mathbf{if}\;\begin{array}{l} t_1 := x \cdot y - z \cdot t\\ t_1 \leq -\infty \lor \neg \left(t_1 \leq 6.780440120066643 \cdot 10^{+296}\right) \end{array}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{\sqrt[3]{a} \cdot \sqrt[3]{a}}, \frac{x}{\sqrt[3]{a}}, t \cdot \left(z \cdot \frac{-1}{a}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{z \cdot t}{a}\\ \end{array} \]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;\begin{array}{l}
t_1 := x \cdot y - z \cdot t\\
t_1 \leq -\infty \lor \neg \left(t_1 \leq 6.780440120066643 \cdot 10^{+296}\right)
\end{array}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{\sqrt[3]{a} \cdot \sqrt[3]{a}}, \frac{x}{\sqrt[3]{a}}, t \cdot \left(z \cdot \frac{-1}{a}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{a} - \frac{z \cdot t}{a}\\


\end{array}
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
(FPCore (x y z t a)
 :precision binary64
 (if (let* ((t_1 (- (* x y) (* z t))))
       (or (<= t_1 (- INFINITY)) (not (<= t_1 6.780440120066643e+296))))
   (fma (/ y (* (cbrt a) (cbrt a))) (/ x (cbrt a)) (* t (* z (/ -1.0 a))))
   (- (/ (* x y) a) (/ (* z t) a))))
double code(double x, double y, double z, double t, double a) {
	return ((x * y) - (z * t)) / a;
}
double code(double x, double y, double z, double t, double a) {
	double t_1 = (x * y) - (z * t);
	double tmp;
	if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 6.780440120066643e+296)) {
		tmp = fma((y / (cbrt(a) * cbrt(a))), (x / cbrt(a)), (t * (z * (-1.0 / a))));
	} else {
		tmp = ((x * y) / a) - ((z * t) / a);
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original7.7
Target5.8
Herbie0.8
\[\begin{array}{l} \mathbf{if}\;z < -2.468684968699548 \cdot 10^{+170}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{elif}\;z < 6.309831121978371 \cdot 10^{-71}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \end{array} \]

Derivation

  1. Split input into 2 regimes
  2. if (-.f64 (*.f64 x y) (*.f64 z t)) < -inf.0 or 6.7804401200666435e296 < (-.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 60.7

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Taylor expanded in x around 0 60.7

      \[\leadsto \color{blue}{\frac{y \cdot x}{a} - \frac{t \cdot z}{a}} \]
    3. Applied add-cube-cbrt_binary6460.7

      \[\leadsto \frac{y \cdot x}{a} - \frac{t \cdot z}{\color{blue}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}} \]
    4. Applied times-frac_binary6433.0

      \[\leadsto \frac{y \cdot x}{a} - \color{blue}{\frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{z}{\sqrt[3]{a}}} \]
    5. Applied add-cube-cbrt_binary6433.0

      \[\leadsto \frac{y \cdot x}{\color{blue}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}} - \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{z}{\sqrt[3]{a}} \]
    6. Applied times-frac_binary641.3

      \[\leadsto \color{blue}{\frac{y}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{x}{\sqrt[3]{a}}} - \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{z}{\sqrt[3]{a}} \]
    7. Applied prod-diff_binary641.3

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{\sqrt[3]{a} \cdot \sqrt[3]{a}}, \frac{x}{\sqrt[3]{a}}, -\frac{z}{\sqrt[3]{a}} \cdot \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}\right) + \mathsf{fma}\left(-\frac{z}{\sqrt[3]{a}}, \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}, \frac{z}{\sqrt[3]{a}} \cdot \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}\right)} \]
    8. Simplified1.3

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{\sqrt[3]{a} \cdot \sqrt[3]{a}}, \frac{x}{\sqrt[3]{a}}, -\frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{z}{\sqrt[3]{a}}\right)} + \mathsf{fma}\left(-\frac{z}{\sqrt[3]{a}}, \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}, \frac{z}{\sqrt[3]{a}} \cdot \frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}}\right) \]
    9. Simplified1.3

      \[\leadsto \mathsf{fma}\left(\frac{y}{\sqrt[3]{a} \cdot \sqrt[3]{a}}, \frac{x}{\sqrt[3]{a}}, -\frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{z}{\sqrt[3]{a}}\right) + \color{blue}{0} \]
    10. Applied div-inv_binary641.3

      \[\leadsto \mathsf{fma}\left(\frac{y}{\sqrt[3]{a} \cdot \sqrt[3]{a}}, \frac{x}{\sqrt[3]{a}}, -\color{blue}{\left(t \cdot \frac{1}{\sqrt[3]{a} \cdot \sqrt[3]{a}}\right)} \cdot \frac{z}{\sqrt[3]{a}}\right) + 0 \]
    11. Applied associate-*l*_binary641.3

      \[\leadsto \mathsf{fma}\left(\frac{y}{\sqrt[3]{a} \cdot \sqrt[3]{a}}, \frac{x}{\sqrt[3]{a}}, -\color{blue}{t \cdot \left(\frac{1}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{z}{\sqrt[3]{a}}\right)}\right) + 0 \]
    12. Simplified0.8

      \[\leadsto \mathsf{fma}\left(\frac{y}{\sqrt[3]{a} \cdot \sqrt[3]{a}}, \frac{x}{\sqrt[3]{a}}, -t \cdot \color{blue}{\left(\frac{1}{a} \cdot z\right)}\right) + 0 \]

    if -inf.0 < (-.f64 (*.f64 x y) (*.f64 z t)) < 6.7804401200666435e296

    1. Initial program 0.8

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Taylor expanded in x around 0 0.8

      \[\leadsto \color{blue}{\frac{y \cdot x}{a} - \frac{t \cdot z}{a}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \leq -\infty \lor \neg \left(x \cdot y - z \cdot t \leq 6.780440120066643 \cdot 10^{+296}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{\sqrt[3]{a} \cdot \sqrt[3]{a}}, \frac{x}{\sqrt[3]{a}}, t \cdot \left(z \cdot \frac{-1}{a}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{z \cdot t}{a}\\ \end{array} \]

Reproduce

herbie shell --seed 2021310 
(FPCore (x y z t a)
  :name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
  :precision binary64

  :herbie-target
  (if (< z -2.468684968699548e+170) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z))))

  (/ (- (* x y) (* z t)) a))