Average Error: 7.0 → 2.7
Time: 4.7s
Precision: binary64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.4073254993549903 \cdot 10^{154}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\ \mathbf{elif}\;z \le 6731197093309.67871:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{z}} \cdot \left(\frac{2}{y - t} \cdot \frac{x}{\sqrt{z}}\right)\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -1.4073254993549903 \cdot 10^{154}:\\
\;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{z}} \cdot \left(\frac{2}{y - t} \cdot \frac{x}{\sqrt{z}}\right)\\

\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 <= -1.4073254993549903e+154)) {
		VAR = ((double) (((double) (x / z)) * ((double) (2.0 / ((double) (y - t))))));
	} else {
		double VAR_1;
		if ((z <= 6731197093309.679)) {
			VAR_1 = ((double) (((double) (x * 2.0)) / ((double) (z * ((double) (y - t))))));
		} else {
			VAR_1 = ((double) (((double) (1.0 / ((double) sqrt(z)))) * ((double) (((double) (2.0 / ((double) (y - t)))) * ((double) (x / ((double) sqrt(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

Original7.0
Target2.4
Herbie2.7
\[\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 < -1.4073254993549903e154

    1. Initial program 15.2

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

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

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

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

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

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

    if -1.4073254993549903e154 < z < 6731197093309.67871

    1. Initial program 3.3

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

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

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

    if 6731197093309.67871 < z

    1. Initial program 11.1

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{z}} \cdot \frac{2}{y - t}\]
    8. Using strategy rm
    9. Applied add-sqr-sqrt1.9

      \[\leadsto \frac{x}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}} \cdot \frac{2}{y - t}\]
    10. Applied *-un-lft-identity1.9

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{\sqrt{z} \cdot \sqrt{z}} \cdot \frac{2}{y - t}\]
    11. Applied times-frac1.9

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

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

      \[\leadsto \frac{1}{\sqrt{z}} \cdot \color{blue}{\left(\frac{2}{y - t} \cdot \frac{x}{\sqrt{z}}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.4073254993549903 \cdot 10^{154}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\ \mathbf{elif}\;z \le 6731197093309.67871:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{z}} \cdot \left(\frac{2}{y - t} \cdot \frac{x}{\sqrt{z}}\right)\\ \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))))