Average Error: 7.9 → 4.5
Time: 4.3min
Precision: binary64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y \le -5.2828115117487552 \cdot 10^{303}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{z \cdot t}{a}\\ \mathbf{elif}\;x \cdot y \le -6.9946011831095517 \cdot 10^{-46}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{z}{\frac{a}{t}}\\ \mathbf{elif}\;x \cdot y \le 6.2149165236231926 \cdot 10^{-167}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z \cdot t}{a}\\ \mathbf{elif}\;x \cdot y \le 1.3766120352725514 \cdot 10^{262}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{z}{a} \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{z \cdot t}{a}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y \le -5.2828115117487552 \cdot 10^{303}:\\
\;\;\;\;x \cdot \frac{y}{a} - \frac{z \cdot t}{a}\\

\mathbf{elif}\;x \cdot y \le -6.9946011831095517 \cdot 10^{-46}:\\
\;\;\;\;\frac{x \cdot y}{a} - \frac{z}{\frac{a}{t}}\\

\mathbf{elif}\;x \cdot y \le 6.2149165236231926 \cdot 10^{-167}:\\
\;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z \cdot t}{a}\\

\mathbf{elif}\;x \cdot y \le 1.3766120352725514 \cdot 10^{262}:\\
\;\;\;\;\frac{x \cdot y}{a} - \frac{z}{a} \cdot t\\

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

\end{array}
double code(double x, double y, double z, double t, double a) {
	return (((double) (((double) (x * y)) - ((double) (z * t)))) / a);
}
double code(double x, double y, double z, double t, double a) {
	double VAR;
	if ((((double) (x * y)) <= -5.282811511748755e+303)) {
		VAR = ((double) (((double) (x * (y / a))) - (((double) (z * t)) / a)));
	} else {
		double VAR_1;
		if ((((double) (x * y)) <= -6.994601183109552e-46)) {
			VAR_1 = ((double) ((((double) (x * y)) / a) - (z / (a / t))));
		} else {
			double VAR_2;
			if ((((double) (x * y)) <= 6.2149165236231926e-167)) {
				VAR_2 = ((double) ((x / (a / y)) - (((double) (z * t)) / a)));
			} else {
				double VAR_3;
				if ((((double) (x * y)) <= 1.3766120352725514e+262)) {
					VAR_3 = ((double) ((((double) (x * y)) / a) - ((double) ((z / a) * t))));
				} else {
					VAR_3 = ((double) (((double) (x * (y / a))) - (((double) (z * t)) / a)));
				}
				VAR_2 = VAR_3;
			}
			VAR_1 = VAR_2;
		}
		VAR = VAR_1;
	}
	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.9
Target6.4
Herbie4.5
\[\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 4 regimes
  2. if (* x y) < -5.2828115117487552e303 or 1.3766120352725514e262 < (* x y)

    1. Initial program 51.4

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

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

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

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

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

    if -5.2828115117487552e303 < (* x y) < -6.9946011831095517e-46

    1. Initial program 4.2

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}}\]
    4. Using strategy rm
    5. Applied associate-/l*2.7

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

    if -6.9946011831095517e-46 < (* x y) < 6.2149165236231926e-167

    1. Initial program 4.7

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}}\]
    4. Using strategy rm
    5. Applied associate-/l*5.6

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

    if 6.2149165236231926e-167 < (* x y) < 1.3766120352725514e262

    1. Initial program 3.6

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}}\]
    4. Using strategy rm
    5. Applied associate-/l*4.0

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{z}{\frac{a}{t}}}\]
    6. Using strategy rm
    7. Applied associate-/r/4.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \le -5.2828115117487552 \cdot 10^{303}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{z \cdot t}{a}\\ \mathbf{elif}\;x \cdot y \le -6.9946011831095517 \cdot 10^{-46}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{z}{\frac{a}{t}}\\ \mathbf{elif}\;x \cdot y \le 6.2149165236231926 \cdot 10^{-167}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{z \cdot t}{a}\\ \mathbf{elif}\;x \cdot y \le 1.3766120352725514 \cdot 10^{262}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{z}{a} \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{z \cdot t}{a}\\ \end{array}\]

Reproduce

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