Average Error: 7.5 → 0.8
Time: 4.3s
Precision: binary64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \leq -5.03804754410112 \cdot 10^{+227} \lor \neg \left(x \cdot y - z \cdot t \leq 2.2366251910900706 \cdot 10^{+257}\right):\\ \;\;\;\;x \cdot \frac{y}{a} - z \cdot \frac{t}{a}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y - z \cdot t\right) \cdot \frac{1}{a}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \leq -5.03804754410112 \cdot 10^{+227} \lor \neg \left(x \cdot y - z \cdot t \leq 2.2366251910900706 \cdot 10^{+257}\right):\\
\;\;\;\;x \cdot \frac{y}{a} - z \cdot \frac{t}{a}\\

\mathbf{else}:\\
\;\;\;\;\left(x \cdot y - z \cdot t\right) \cdot \frac{1}{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 (or (<= (- (* x y) (* z t)) -5.03804754410112e+227)
         (not (<= (- (* x y) (* z t)) 2.2366251910900706e+257)))
   (- (* x (/ y a)) (* z (/ t a)))
   (* (- (* x y) (* z t)) (/ 1.0 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 tmp;
	if ((((x * y) - (z * t)) <= -5.03804754410112e+227) || !(((x * y) - (z * t)) <= 2.2366251910900706e+257)) {
		tmp = (x * (y / a)) - (z * (t / a));
	} else {
		tmp = ((x * y) - (z * t)) * (1.0 / 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.5
Target6.3
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)) < -5.03804754410112e227 or 2.2366251910900706e257 < (-.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 37.7

      \[\frac{x \cdot y - z \cdot t}{a}\]
    2. Using strategy rm
    3. Applied div-sub_binary6437.7

      \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity_binary6437.7

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

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y}{a}} - \frac{z \cdot t}{a}\]
    7. Simplified18.6

      \[\leadsto \color{blue}{x} \cdot \frac{y}{a} - \frac{z \cdot t}{a}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity_binary6418.6

      \[\leadsto x \cdot \frac{y}{a} - \frac{z \cdot t}{\color{blue}{1 \cdot a}}\]
    10. Applied times-frac_binary640.5

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

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

    if -5.03804754410112e227 < (-.f64 (*.f64 x y) (*.f64 z t)) < 2.2366251910900706e257

    1. Initial program 0.8

      \[\frac{x \cdot y - z \cdot t}{a}\]
    2. Using strategy rm
    3. Applied div-inv_binary640.9

      \[\leadsto \color{blue}{\left(x \cdot y - z \cdot t\right) \cdot \frac{1}{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 -5.03804754410112 \cdot 10^{+227} \lor \neg \left(x \cdot y - z \cdot t \leq 2.2366251910900706 \cdot 10^{+257}\right):\\ \;\;\;\;x \cdot \frac{y}{a} - z \cdot \frac{t}{a}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y - z \cdot t\right) \cdot \frac{1}{a}\\ \end{array}\]

Reproduce

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