Average Error: 7.2 → 2.1
Time: 40.7s
Precision: binary64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.37468781690926404 \cdot 10^{-60}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{elif}\;z \le 1.7252484947847566 \cdot 10^{-40}:\\ \;\;\;\;\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 -3.37468781690926404 \cdot 10^{-60}:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\

\mathbf{elif}\;z \le 1.7252484947847566 \cdot 10^{-40}:\\
\;\;\;\;\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 <= -3.374687816909264e-60)) {
		VAR = ((double) (((double) (x / z)) / ((double) (((double) (y - t)) / 2.0))));
	} else {
		double VAR_1;
		if ((z <= 1.7252484947847566e-40)) {
			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.2
Target1.9
Herbie2.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 z < -3.37468781690926404e-60

    1. Initial program 9.9

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

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

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

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

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

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

    if -3.37468781690926404e-60 < z < 1.7252484947847566e-40

    1. Initial program 2.6

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

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

    if 1.7252484947847566e-40 < z

    1. Initial program 10.0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.37468781690926404 \cdot 10^{-60}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{elif}\;z \le 1.7252484947847566 \cdot 10^{-40}:\\ \;\;\;\;\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 2020147 
(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))))