Average Error: 7.7 → 5.5
Time: 2.9s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;z \cdot t \le -8.0070948443668391 \cdot 10^{300}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;z \cdot t \le -8.6807024211344991 \cdot 10^{-183}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t \cdot z}{a}\\ \mathbf{elif}\;z \cdot t \le 8.56722134275957997 \cdot 10^{-146}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{t \cdot z}{a}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;z \cdot t \le -8.0070948443668391 \cdot 10^{300}:\\
\;\;\;\;\frac{x \cdot y}{a} - \frac{t}{\frac{a}{z}}\\

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

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

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

\end{array}
double code(double x, double y, double z, double t, double a) {
	return ((double) (((double) (((double) (x * y)) - ((double) (z * t)))) / a));
}
double code(double x, double y, double z, double t, double a) {
	double VAR;
	if ((((double) (z * t)) <= -8.007094844366839e+300)) {
		VAR = ((double) (((double) (((double) (x * y)) / a)) - ((double) (t / ((double) (a / z))))));
	} else {
		double VAR_1;
		if ((((double) (z * t)) <= -8.680702421134499e-183)) {
			VAR_1 = ((double) (((double) (x / ((double) (a / y)))) - ((double) (((double) (t * z)) / a))));
		} else {
			double VAR_2;
			if ((((double) (z * t)) <= 8.56722134275958e-146)) {
				VAR_2 = ((double) (((double) (((double) (x * y)) / a)) - ((double) (t / ((double) (a / z))))));
			} else {
				VAR_2 = ((double) (((double) (x * ((double) (y / a)))) - ((double) (((double) (t * z)) / a))));
			}
			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.7
Target5.8
Herbie5.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 3 regimes
  2. if (* z t) < -8.007094844366839e+300 or -8.680702421134499e-183 < (* z t) < 8.56722134275958e-146

    1. Initial program 10.4

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

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

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

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

    if -8.007094844366839e+300 < (* z t) < -8.680702421134499e-183

    1. Initial program 3.9

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

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

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

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

    if 8.56722134275958e-146 < (* z t)

    1. Initial program 8.8

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot t \le -8.0070948443668391 \cdot 10^{300}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;z \cdot t \le -8.6807024211344991 \cdot 10^{-183}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t \cdot z}{a}\\ \mathbf{elif}\;z \cdot t \le 8.56722134275957997 \cdot 10^{-146}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{t \cdot z}{a}\\ \end{array}\]

Reproduce

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