Average Error: 6.8 → 1.4
Time: 9.6min
Precision: binary64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -3.3845513883943168 \cdot 10^{205}:\\ \;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 4.94822690605444123 \cdot 10^{203}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \cdot z - t \cdot z \le -3.3845513883943168 \cdot 10^{205}:\\
\;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\

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

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

\end{array}
double code(double x, double y, double z, double t) {
	return (((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)))) <= -3.384551388394317e+205)) {
		VAR = (((double) (x * (2.0 / ((double) (y - t))))) / z);
	} else {
		double VAR_1;
		if ((((double) (((double) (y * z)) - ((double) (t * z)))) <= 4.948226906054441e+203)) {
			VAR_1 = (((double) (x * 2.0)) / ((double) (((double) (y * z)) - ((double) (t * z)))));
		} else {
			VAR_1 = ((double) ((x / z) * (2.0 / ((double) (y - t)))));
		}
		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.2
Herbie1.4
\[\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)) < -3.3845513883943168e205

    1. Initial program 11.7

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

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

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

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

    if -3.3845513883943168e205 < (- (* y z) (* t z)) < 4.94822690605444123e203

    1. Initial program 1.9

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

    if 4.94822690605444123e203 < (- (* y z) (* t z))

    1. Initial program 17.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -3.3845513883943168 \cdot 10^{205}:\\ \;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 4.94822690605444123 \cdot 10^{203}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\ \end{array}\]

Reproduce

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