Average Error: 6.7 → 0.5
Time: 39.3s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -1.0469421249112056 \cdot 10^{303} \lor \neg \left(y \cdot z - t \cdot z \le -2.8965784899222717 \cdot 10^{-173} \lor \neg \left(y \cdot z - t \cdot z \le 3.243376985 \cdot 10^{-316} \lor \neg \left(y \cdot z - t \cdot z \le 2.31023158370294189 \cdot 10^{161}\right)\right)\right):\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \cdot z - t \cdot z \le -1.0469421249112056 \cdot 10^{303} \lor \neg \left(y \cdot z - t \cdot z \le -2.8965784899222717 \cdot 10^{-173} \lor \neg \left(y \cdot z - t \cdot z \le 3.243376985 \cdot 10^{-316} \lor \neg \left(y \cdot z - t \cdot z \le 2.31023158370294189 \cdot 10^{161}\right)\right)\right):\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\

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

\end{array}
double code(double x, double y, double z, double t) {
	return ((x * 2.0) / ((y * z) - (t * z)));
}
double code(double x, double y, double z, double t) {
	double VAR;
	if (((((y * z) - (t * z)) <= -1.0469421249112056e+303) || !((((y * z) - (t * z)) <= -2.8965784899222717e-173) || !((((y * z) - (t * z)) <= 3.2433769845599e-316) || !(((y * z) - (t * z)) <= 2.310231583702942e+161))))) {
		VAR = ((x / z) / ((y - t) / 2.0));
	} else {
		VAR = ((x * 2.0) / ((y * z) - (t * z)));
	}
	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.7
Target2.2
Herbie0.5
\[\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 2 regimes
  2. if (- (* y z) (* t z)) < -1.0469421249112056e+303 or -2.8965784899222717e-173 < (- (* y z) (* t z)) < 3.2433769845599e-316 or 2.310231583702942e+161 < (- (* y z) (* t z))

    1. Initial program 16.5

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{y - t}{2}}}\]
    6. Applied associate-/r*0.8

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

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

    if -1.0469421249112056e+303 < (- (* y z) (* t z)) < -2.8965784899222717e-173 or 3.2433769845599e-316 < (- (* y z) (* t z)) < 2.310231583702942e+161

    1. Initial program 0.3

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -1.0469421249112056 \cdot 10^{303} \lor \neg \left(y \cdot z - t \cdot z \le -2.8965784899222717 \cdot 10^{-173} \lor \neg \left(y \cdot z - t \cdot z \le 3.243376985 \cdot 10^{-316} \lor \neg \left(y \cdot z - t \cdot z \le 2.31023158370294189 \cdot 10^{161}\right)\right)\right):\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \end{array}\]

Reproduce

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

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

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