Average Error: 7.4 → 4.2
Time: 3.0s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;z \cdot t = -\infty:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;z \cdot t \le -3.24224747448874068 \cdot 10^{-93}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t \cdot z}{a}\\ \mathbf{elif}\;z \cdot t \le 3.8091633157323544 \cdot 10^{-199}:\\ \;\;\;\;\frac{1}{a \cdot \frac{1}{x \cdot y - z \cdot t}}\\ \mathbf{elif}\;z \cdot t \le 2.0861571477552367 \cdot 10^{-102}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{t \cdot z}{a}\\ \mathbf{elif}\;z \cdot t \le 131036.962942321014:\\ \;\;\;\;\frac{1}{a \cdot \frac{1}{x \cdot y - z \cdot t}}\\ \mathbf{elif}\;z \cdot t \le 1.6265335498807516 \cdot 10^{301}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{a} - t \cdot \frac{z}{a}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;z \cdot t = -\infty:\\
\;\;\;\;\frac{x \cdot y}{a} - \frac{t}{\frac{a}{z}}\\

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

\mathbf{elif}\;z \cdot t \le 3.8091633157323544 \cdot 10^{-199}:\\
\;\;\;\;\frac{1}{a \cdot \frac{1}{x \cdot y - z \cdot t}}\\

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

\mathbf{elif}\;z \cdot t \le 131036.962942321014:\\
\;\;\;\;\frac{1}{a \cdot \frac{1}{x \cdot y - z \cdot t}}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{a} - t \cdot \frac{z}{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 temp;
	if (((z * t) <= -inf.0)) {
		temp = (((x * y) / a) - (t / (a / z)));
	} else {
		double temp_1;
		if (((z * t) <= -3.2422474744887407e-93)) {
			temp_1 = ((x / (a / y)) - ((t * z) / a));
		} else {
			double temp_2;
			if (((z * t) <= 3.8091633157323544e-199)) {
				temp_2 = (1.0 / (a * (1.0 / ((x * y) - (z * t)))));
			} else {
				double temp_3;
				if (((z * t) <= 2.0861571477552367e-102)) {
					temp_3 = ((x * (y / a)) - ((t * z) / a));
				} else {
					double temp_4;
					if (((z * t) <= 131036.96294232101)) {
						temp_4 = (1.0 / (a * (1.0 / ((x * y) - (z * t)))));
					} else {
						double temp_5;
						if (((z * t) <= 1.6265335498807516e+301)) {
							temp_5 = ((x / (a / y)) - ((t * z) / a));
						} else {
							temp_5 = (((x * y) / a) - (t * (z / a)));
						}
						temp_4 = temp_5;
					}
					temp_3 = temp_4;
				}
				temp_2 = temp_3;
			}
			temp_1 = temp_2;
		}
		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
Target5.9
Herbie4.2
\[\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 5 regimes
  2. if (* z t) < -inf.0

    1. Initial program 64.0

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

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

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

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

    if -inf.0 < (* z t) < -3.2422474744887407e-93 or 131036.96294232101 < (* z t) < 1.6265335498807516e+301

    1. Initial program 3.7

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

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

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

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

    if -3.2422474744887407e-93 < (* z t) < 3.8091633157323544e-199 or 2.0861571477552367e-102 < (* z t) < 131036.96294232101

    1. Initial program 4.5

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{x \cdot y - z \cdot t}}}\]
    4. Using strategy rm
    5. Applied div-inv5.1

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

    if 3.8091633157323544e-199 < (* z t) < 2.0861571477552367e-102

    1. Initial program 3.3

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

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

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

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

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

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

    if 1.6265335498807516e+301 < (* z t)

    1. Initial program 58.5

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot t = -\infty:\\ \;\;\;\;\frac{x \cdot y}{a} - \frac{t}{\frac{a}{z}}\\ \mathbf{elif}\;z \cdot t \le -3.24224747448874068 \cdot 10^{-93}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t \cdot z}{a}\\ \mathbf{elif}\;z \cdot t \le 3.8091633157323544 \cdot 10^{-199}:\\ \;\;\;\;\frac{1}{a \cdot \frac{1}{x \cdot y - z \cdot t}}\\ \mathbf{elif}\;z \cdot t \le 2.0861571477552367 \cdot 10^{-102}:\\ \;\;\;\;x \cdot \frac{y}{a} - \frac{t \cdot z}{a}\\ \mathbf{elif}\;z \cdot t \le 131036.962942321014:\\ \;\;\;\;\frac{1}{a \cdot \frac{1}{x \cdot y - z \cdot t}}\\ \mathbf{elif}\;z \cdot t \le 1.6265335498807516 \cdot 10^{301}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t \cdot z}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot y}{a} - t \cdot \frac{z}{a}\\ \end{array}\]

Reproduce

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