Average Error: 6.8 → 1.1
Time: 4.6s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z = -\infty:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le -5.56798412025792813 \cdot 10^{-130}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 4.411181918490247 \cdot 10^{-232}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 4.78150012576369608 \cdot 10^{77}:\\ \;\;\;\;x \cdot \frac{\frac{2}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \cdot z - t \cdot z = -\infty:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\

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

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

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

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

\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) (t * z)))) <= -inf.0)) {
		VAR = ((double) (((double) (x / z)) / ((double) (((double) (y - t)) / 2.0))));
	} else {
		double VAR_1;
		if ((((double) (((double) (y * z)) - ((double) (t * z)))) <= -5.567984120257928e-130)) {
			VAR_1 = ((double) (((double) (x * 2.0)) / ((double) (((double) (y * z)) - ((double) (t * z))))));
		} else {
			double VAR_2;
			if ((((double) (((double) (y * z)) - ((double) (t * z)))) <= 4.411181918490247e-232)) {
				VAR_2 = ((double) (((double) (x / z)) / ((double) (((double) (y - t)) / 2.0))));
			} else {
				double VAR_3;
				if ((((double) (((double) (y * z)) - ((double) (t * z)))) <= 4.781500125763696e+77)) {
					VAR_3 = ((double) (x * ((double) (((double) (2.0 / ((double) (y - t)))) / z))));
				} else {
					VAR_3 = ((double) (((double) (x / z)) / ((double) (((double) (y - t)) / 2.0))));
				}
				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

Original6.8
Target2.1
Herbie1.1
\[\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)) < -inf.0 or -5.567984120257928e-130 < (- (* y z) (* t z)) < 4.411181918490247e-232 or 4.781500125763696e+77 < (- (* y z) (* t z))

    1. Initial program 13.5

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

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

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

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

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

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

    if -inf.0 < (- (* y z) (* t z)) < -5.567984120257928e-130

    1. Initial program 0.2

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

    if 4.411181918490247e-232 < (- (* y z) (* t z)) < 4.781500125763696e+77

    1. Initial program 0.3

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z = -\infty:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le -5.56798412025792813 \cdot 10^{-130}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 4.411181918490247 \cdot 10^{-232}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 4.78150012576369608 \cdot 10^{77}:\\ \;\;\;\;x \cdot \frac{\frac{2}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \end{array}\]

Reproduce

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