Average Error: 7.4 → 4.3
Time: 2.9s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -1.27028457940479733 \cdot 10^{287}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 2.42230842933814323 \cdot 10^{193}:\\ \;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - t \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{t}{\frac{a}{z}}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \le -1.27028457940479733 \cdot 10^{287}:\\
\;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t \cdot z}{a}\\

\mathbf{elif}\;x \cdot y - z \cdot t \le 2.42230842933814323 \cdot 10^{193}:\\
\;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - t \cdot z\right)\\

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

\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 temp;
	if ((((x * y) - (z * t)) <= -1.2702845794047973e+287)) {
		temp = ((x / (a / y)) - ((t * z) / a));
	} else {
		double temp_1;
		if ((((x * y) - (z * t)) <= 2.4223084293381432e+193)) {
			temp_1 = ((1.0 / a) * ((x * y) - (t * z)));
		} else {
			temp_1 = (((x * y) / a) - (t / (a / z)));
		}
		temp = temp_1;
	}
	return temp;
}

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.4
Target6.2
Herbie4.3
\[\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 (- (* x y) (* z t)) < -1.2702845794047973e+287

    1. Initial program 52.5

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

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

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

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

    if -1.2702845794047973e+287 < (- (* x y) (* z t)) < 2.4223084293381432e+193

    1. Initial program 0.8

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

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

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

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\left(t \cdot z\right) \cdot \frac{1}{a}}\]
    7. Applied div-inv0.9

      \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot \frac{1}{a}} - \left(t \cdot z\right) \cdot \frac{1}{a}\]
    8. Applied distribute-rgt-out--0.9

      \[\leadsto \color{blue}{\frac{1}{a} \cdot \left(x \cdot y - t \cdot z\right)}\]

    if 2.4223084293381432e+193 < (- (* x y) (* z t))

    1. Initial program 27.3

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -1.27028457940479733 \cdot 10^{287}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t \cdot z}{a}\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 2.42230842933814323 \cdot 10^{193}:\\ \;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - t \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{t}{\frac{a}{z}}\\ \end{array}\]

Reproduce

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