Average Error: 7.1 → 2.8
Time: 4.3s
Precision: binary64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -7.9850072123113333 \cdot 10^{125}:\\ \;\;\;\;\frac{1}{z} \cdot \frac{x}{\frac{y - t}{2}}\\ \mathbf{elif}\;z \le 3.0780072195534592 \cdot 10^{-7}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y - t}}{\frac{\frac{z}{x}}{2}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -7.9850072123113333 \cdot 10^{125}:\\
\;\;\;\;\frac{1}{z} \cdot \frac{x}{\frac{y - t}{2}}\\

\mathbf{elif}\;z \le 3.0780072195534592 \cdot 10^{-7}:\\
\;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{y - t}}{\frac{\frac{z}{x}}{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 ((z <= -7.985007212311333e+125)) {
		VAR = ((double) (((double) (1.0 / z)) * ((double) (x / ((double) (((double) (y - t)) / 2.0))))));
	} else {
		double VAR_1;
		if ((z <= 3.078007219553459e-07)) {
			VAR_1 = ((double) (x / ((double) (((double) (z * ((double) (y - t)))) / 2.0))));
		} else {
			VAR_1 = ((double) (((double) (1.0 / ((double) (y - t)))) / ((double) (((double) (z / x)) / 2.0))));
		}
		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.1
Target2.2
Herbie2.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 z < -7.9850072123113333e125

    1. Initial program 14.2

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

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

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

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

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

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

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

    if -7.9850072123113333e125 < z < 3.0780072195534592e-7

    1. Initial program 3.2

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

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

    if 3.0780072195534592e-7 < z

    1. Initial program 10.6

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{x}{\frac{y - t}{2}}}}{z}\]
    12. Using strategy rm
    13. Applied div-inv2.0

      \[\leadsto \frac{\frac{x}{\color{blue}{\left(y - t\right) \cdot \frac{1}{2}}}}{z}\]
    14. Applied *-un-lft-identity2.0

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -7.9850072123113333 \cdot 10^{125}:\\ \;\;\;\;\frac{1}{z} \cdot \frac{x}{\frac{y - t}{2}}\\ \mathbf{elif}\;z \le 3.0780072195534592 \cdot 10^{-7}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y - t}}{\frac{\frac{z}{x}}{2}}\\ \end{array}\]

Reproduce

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