Average Error: 7.3 → 1.0
Time: 3.7s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -1.0793783359874322 \cdot 10^{147} \lor \neg \left(x \cdot y - z \cdot t \le 2.5291028804894036 \cdot 10^{255}\right):\\ \;\;\;\;x \cdot \frac{y}{a} - t \cdot \frac{z}{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 \le -1.0793783359874322 \cdot 10^{147} \lor \neg \left(x \cdot y - z \cdot t \le 2.5291028804894036 \cdot 10^{255}\right):\\
\;\;\;\;x \cdot \frac{y}{a} - t \cdot \frac{z}{a}\\

\mathbf{else}:\\
\;\;\;\;\left(x \cdot y - z \cdot t\right) \cdot \frac{1}{a}\\

\end{array}
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 VAR;
	if (((((x * y) - (z * t)) <= -1.0793783359874322e+147) || !(((x * y) - (z * t)) <= 2.5291028804894036e+255))) {
		VAR = ((x * (y / a)) - (t * (z / a)));
	} else {
		VAR = (((x * y) - (z * t)) * (1.0 / a));
	}
	return VAR;
}

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.3
Target5.9
Herbie1.0
\[\begin{array}{l} \mathbf{if}\;z \lt -2.46868496869954822 \cdot 10^{170}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{elif}\;z \lt 6.30983112197837121 \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 (- (* x y) (* z t)) < -1.0793783359874322e+147 or 2.5291028804894036e+255 < (- (* x y) (* z t))

    1. Initial program 26.9

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

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

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

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

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

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

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

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

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

    if -1.0793783359874322e+147 < (- (* x y) (* z t)) < 2.5291028804894036e+255

    1. Initial program 0.7

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

      \[\leadsto \color{blue}{\left(x \cdot y - z \cdot t\right) \cdot \frac{1}{a}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -1.0793783359874322 \cdot 10^{147} \lor \neg \left(x \cdot y - z \cdot t \le 2.5291028804894036 \cdot 10^{255}\right):\\ \;\;\;\;x \cdot \frac{y}{a} - t \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y - z \cdot t\right) \cdot \frac{1}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020105 +o rules:numerics
(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))