Average Error: 7.0 → 0.7
Time: 3.2s
Precision: binary64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - z \cdot t \le -7.26168499596656202 \cdot 10^{163}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \mathbf{elif}\;y \cdot z - z \cdot t \le -1.10808632511487916 \cdot 10^{-99}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{elif}\;y \cdot z - z \cdot t \le 2.2261687342694704 \cdot 10^{-174}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \mathbf{elif}\;y \cdot z - z \cdot t \le 5.3233307638701136 \cdot 10^{293}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot \frac{2}{y - t}\right) \cdot \frac{1}{z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \cdot z - z \cdot t \le -7.26168499596656202 \cdot 10^{163}:\\
\;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\

\mathbf{elif}\;y \cdot z - z \cdot t \le -1.10808632511487916 \cdot 10^{-99}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\

\mathbf{elif}\;y \cdot z - z \cdot t \le 2.2261687342694704 \cdot 10^{-174}:\\
\;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\

\mathbf{elif}\;y \cdot z - z \cdot t \le 5.3233307638701136 \cdot 10^{293}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\

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

\end{array}
double code(double x, double y, double z, double t) {
	return ((double) (((double) (x * 2.0)) / ((double) (((double) (y * z)) - ((double) (t * z))))));
}
double code(double x, double y, double z, double t) {
	double VAR;
	if ((((double) (((double) (y * z)) - ((double) (z * t)))) <= -7.261684995966562e+163)) {
		VAR = ((double) (((double) (((double) (x * 2.0)) / ((double) (y - t)))) / z));
	} else {
		double VAR_1;
		if ((((double) (((double) (y * z)) - ((double) (z * t)))) <= -1.1080863251148792e-99)) {
			VAR_1 = ((double) (((double) (x * 2.0)) / ((double) (((double) (y * z)) - ((double) (z * t))))));
		} else {
			double VAR_2;
			if ((((double) (((double) (y * z)) - ((double) (z * t)))) <= 2.2261687342694704e-174)) {
				VAR_2 = ((double) (((double) (((double) (x * 2.0)) / ((double) (y - t)))) / z));
			} else {
				double VAR_3;
				if ((((double) (((double) (y * z)) - ((double) (z * t)))) <= 5.3233307638701136e+293)) {
					VAR_3 = ((double) (((double) (x * 2.0)) / ((double) (((double) (y * z)) - ((double) (z * t))))));
				} else {
					VAR_3 = ((double) (((double) (x * ((double) (2.0 / ((double) (y - t)))))) * ((double) (1.0 / z))));
				}
				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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.0
Target2.1
Herbie0.7
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \lt -2.559141628295061 \cdot 10^{-13}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2\\ \mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \lt 1.04502782733012586 \cdot 10^{-269}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot 2}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (- (* y z) (* t z)) < -7.26168499596656202e163 or -1.10808632511487916e-99 < (- (* y z) (* t z)) < 2.2261687342694704e-174

    1. Initial program 10.0

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. Simplified10.5

      \[\leadsto \color{blue}{x \cdot \frac{2}{z \cdot \left(y - t\right)}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity10.5

      \[\leadsto x \cdot \frac{\color{blue}{1 \cdot 2}}{z \cdot \left(y - t\right)}\]
    5. Applied times-frac9.8

      \[\leadsto x \cdot \color{blue}{\left(\frac{1}{z} \cdot \frac{2}{y - t}\right)}\]
    6. Applied associate-*r*1.7

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

      \[\leadsto \color{blue}{\frac{x}{z}} \cdot \frac{2}{y - t}\]
    8. Using strategy rm
    9. Applied associate-*l/1.8

      \[\leadsto \color{blue}{\frac{x \cdot \frac{2}{y - t}}{z}}\]
    10. Using strategy rm
    11. Applied associate-*r/1.8

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

    if -7.26168499596656202e163 < (- (* y z) (* t z)) < -1.10808632511487916e-99 or 2.2261687342694704e-174 < (- (* y z) (* t z)) < 5.3233307638701136e293

    1. Initial program 0.3

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]

    if 5.3233307638701136e293 < (- (* y z) (* t z))

    1. Initial program 26.4

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. Simplified18.0

      \[\leadsto \color{blue}{x \cdot \frac{2}{z \cdot \left(y - t\right)}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity18.0

      \[\leadsto x \cdot \frac{\color{blue}{1 \cdot 2}}{z \cdot \left(y - t\right)}\]
    5. Applied times-frac16.6

      \[\leadsto x \cdot \color{blue}{\left(\frac{1}{z} \cdot \frac{2}{y - t}\right)}\]
    6. Applied associate-*r*0.1

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

      \[\leadsto \color{blue}{\frac{x}{z}} \cdot \frac{2}{y - t}\]
    8. Using strategy rm
    9. Applied associate-*l/0.1

      \[\leadsto \color{blue}{\frac{x \cdot \frac{2}{y - t}}{z}}\]
    10. Using strategy rm
    11. Applied div-inv0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - z \cdot t \le -7.26168499596656202 \cdot 10^{163}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \mathbf{elif}\;y \cdot z - z \cdot t \le -1.10808632511487916 \cdot 10^{-99}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{elif}\;y \cdot z - z \cdot t \le 2.2261687342694704 \cdot 10^{-174}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \mathbf{elif}\;y \cdot z - z \cdot t \le 5.3233307638701136 \cdot 10^{293}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot \frac{2}{y - t}\right) \cdot \frac{1}{z}\\ \end{array}\]

Reproduce

herbie shell --seed 2020184 
(FPCore (x y z t)
  :name "Linear.Projection:infinitePerspective from linear-1.19.1.3, A"
  :precision binary64

  :herbie-target
  (if (< (/ (* x 2.0) (- (* y z) (* t z))) -2.559141628295061e-13) (* (/ x (* (- y t) z)) 2.0) (if (< (/ (* x 2.0) (- (* y z) (* t z))) 1.0450278273301259e-269) (/ (* (/ x z) 2.0) (- y t)) (* (/ x (* (- y t) z)) 2.0)))

  (/ (* x 2.0) (- (* y z) (* t z))))