Average Error: 6.5 → 1.8
Time: 4.5s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -4.3968922741746257 \cdot 10^{-265}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le 1.49793710351535303 \cdot 10^{-107}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{1}{\frac{y - t}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{\frac{y - t}{2}}}{z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -4.3968922741746257 \cdot 10^{-265}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\

\mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le 1.49793710351535303 \cdot 10^{-107}:\\
\;\;\;\;\frac{x}{z} \cdot \frac{1}{\frac{y - t}{2}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{\frac{y - t}{2}}}{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) (x * 2.0)) / ((double) (((double) (y * z)) - ((double) (t * z)))))) <= -4.3968922741746257e-265)) {
		VAR = ((double) (((double) (x * 2.0)) / ((double) (((double) (y * z)) - ((double) (t * z))))));
	} else {
		double VAR_1;
		if ((((double) (((double) (x * 2.0)) / ((double) (((double) (y * z)) - ((double) (t * z)))))) <= 1.497937103515353e-107)) {
			VAR_1 = ((double) (((double) (x / z)) * ((double) (1.0 / ((double) (((double) (y - t)) / 2.0))))));
		} else {
			VAR_1 = ((double) (((double) (x / ((double) (((double) (y - t)) / 2.0)))) / z));
		}
		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

Original6.5
Target1.9
Herbie1.8
\[\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 (/ (* x 2.0) (- (* y z) (* t z))) < -4.3968922741746257e-265

    1. Initial program 1.2

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

    if -4.3968922741746257e-265 < (/ (* x 2.0) (- (* y z) (* t z))) < 1.497937103515353e-107

    1. Initial program 9.4

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{y - t}{2}}}\]
    6. Applied *-un-lft-identity9.4

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

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

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

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

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

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

    if 1.497937103515353e-107 < (/ (* x 2.0) (- (* y z) (* t z)))

    1. Initial program 8.1

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{y - t}{2}}}\]
    6. Applied *-un-lft-identity3.8

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

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

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

      \[\leadsto \color{blue}{\frac{1 \cdot \frac{x}{\frac{y - t}{2}}}{z}}\]
    11. Simplified3.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -4.3968922741746257 \cdot 10^{-265}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{elif}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le 1.49793710351535303 \cdot 10^{-107}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{1}{\frac{y - t}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{\frac{y - t}{2}}}{z}\\ \end{array}\]

Reproduce

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