Average Error: 7.8 → 5.1
Time: 9.7s
Precision: binary64
\[[x, y]=\mathsf{sort}([x, y])\]
\[\frac{x \cdot y - z \cdot t}{a} \]
\[\begin{array}{l} \mathbf{if}\;\begin{array}{l} t_1 := \frac{x \cdot y - z \cdot t}{a}\\ t_1 \leq -\infty \lor \neg \left(t_1 \leq 5.121082684900786 \cdot 10^{+281}\right) \end{array}:\\ \;\;\;\;x \cdot \frac{y}{a}\\ \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 := \frac{x \cdot y - z \cdot t}{a}\\
t_1 \leq -\infty \lor \neg \left(t_1 \leq 5.121082684900786 \cdot 10^{+281}\right)
\end{array}:\\
\;\;\;\;x \cdot \frac{y}{a}\\

\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)) a)))
       (or (<= t_1 (- INFINITY)) (not (<= t_1 5.121082684900786e+281))))
   (* x (/ y 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)) / a;
	double tmp;
	if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 5.121082684900786e+281)) {
		tmp = x * (y / 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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.8
Target6.0
Herbie5.1
\[\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 (*.f64 x y) (*.f64 z t)) a) < -inf.0 or 5.12108268490078629e281 < (/.f64 (-.f64 (*.f64 x y) (*.f64 z t)) a)

    1. Initial program 56.4

      \[\frac{x \cdot y - z \cdot t}{a} \]
    2. Applied add-cube-cbrt_binary6456.5

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{x \cdot y - z \cdot t}{a}} \cdot \sqrt[3]{\frac{x \cdot y - z \cdot t}{a}}\right) \cdot \sqrt[3]{\frac{x \cdot y - z \cdot t}{a}}} \]
    3. Taylor expanded in x around inf 59.9

      \[\leadsto \color{blue}{\frac{y \cdot x}{a}} \]
    4. Simplified35.0

      \[\leadsto \color{blue}{\frac{y}{a} \cdot x} \]

    if -inf.0 < (/.f64 (-.f64 (*.f64 x y) (*.f64 z t)) a) < 5.12108268490078629e281

    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 simplification5.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot y - z \cdot t}{a} \leq -\infty \lor \neg \left(\frac{x \cdot y - z \cdot t}{a} \leq 5.121082684900786 \cdot 10^{+281}\right):\\ \;\;\;\;x \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{z \cdot t}{a}\\ \end{array} \]

Reproduce

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