Average Error: 7.5 → 4.3
Time: 5.9s
Precision: binary64
\[\frac{x \cdot y - z \cdot t}{a} \]
\[\begin{array}{l} t_1 := \frac{t \cdot z}{a}\\ \mathbf{if}\;x \cdot y \leq -1.5883757317364673 \cdot 10^{+177}:\\ \;\;\;\;y \cdot \frac{x}{a} - t_1\\ \mathbf{elif}\;x \cdot y \leq 4.461355465903499 \cdot 10^{+292}:\\ \;\;\;\;\frac{x \cdot y}{a} - t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{a}{x}} - t_1\\ \end{array} \]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
t_1 := \frac{t \cdot z}{a}\\
\mathbf{if}\;x \cdot y \leq -1.5883757317364673 \cdot 10^{+177}:\\
\;\;\;\;y \cdot \frac{x}{a} - t_1\\

\mathbf{elif}\;x \cdot y \leq 4.461355465903499 \cdot 10^{+292}:\\
\;\;\;\;\frac{x \cdot y}{a} - t_1\\

\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{a}{x}} - t_1\\


\end{array}
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* z t)) a))
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (/ (* t z) a)))
   (if (<= (* x y) -1.5883757317364673e+177)
     (- (* y (/ x a)) t_1)
     (if (<= (* x y) 4.461355465903499e+292)
       (- (/ (* x y) a) t_1)
       (- (/ y (/ a x)) t_1)))))
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 = (t * z) / a;
	double tmp;
	if ((x * y) <= -1.5883757317364673e+177) {
		tmp = (y * (x / a)) - t_1;
	} else if ((x * y) <= 4.461355465903499e+292) {
		tmp = ((x * y) / a) - t_1;
	} else {
		tmp = (y / (a / x)) - t_1;
	}
	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.5
Target6.3
Herbie4.3
\[\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 3 regimes
  2. if (*.f64 x y) < -1.5883757317364673e177

    1. Initial program 27.4

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

      \[\leadsto \color{blue}{\frac{y \cdot x}{a} - \frac{t \cdot z}{a}} \]
    3. Applied *-un-lft-identity_binary6427.4

      \[\leadsto \frac{y \cdot x}{\color{blue}{1 \cdot a}} - \frac{t \cdot z}{a} \]
    4. Applied times-frac_binary646.9

      \[\leadsto \color{blue}{\frac{y}{1} \cdot \frac{x}{a}} - \frac{t \cdot z}{a} \]
    5. Simplified6.9

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

    if -1.5883757317364673e177 < (*.f64 x y) < 4.461355465903499e292

    1. Initial program 3.9

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

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

    if 4.461355465903499e292 < (*.f64 x y)

    1. Initial program 54.4

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

      \[\leadsto \color{blue}{\frac{y \cdot x}{a} - \frac{t \cdot z}{a}} \]
    3. Applied associate-/l*_binary649.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -1.5883757317364673 \cdot 10^{+177}:\\ \;\;\;\;y \cdot \frac{x}{a} - \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y \leq 4.461355465903499 \cdot 10^{+292}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{a}{x}} - \frac{t \cdot z}{a}\\ \end{array} \]

Reproduce

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