Average Error: 7.0 → 0.6
Time: 3.7s
Precision: binary64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - z \cdot t \leq -2.2887889102874485 \cdot 10^{+227}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq -1.0002813918728466 \cdot 10^{-176}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq 2.9226969921444667 \cdot 10^{-241}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq 5.059772897437438 \cdot 10^{+137}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{x}{z}}{y - t}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \cdot z - z \cdot t \leq -2.2887889102874485 \cdot 10^{+227}:\\
\;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\

\mathbf{elif}\;y \cdot z - z \cdot t \leq -1.0002813918728466 \cdot 10^{-176}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\

\mathbf{elif}\;y \cdot z - z \cdot t \leq 2.9226969921444667 \cdot 10^{-241}:\\
\;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\

\mathbf{elif}\;y \cdot z - z \cdot t \leq 5.059772897437438 \cdot 10^{+137}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\

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

\end{array}
(FPCore (x y z t) :precision binary64 (/ (* x 2.0) (- (* y z) (* t z))))
(FPCore (x y z t)
 :precision binary64
 (if (<= (- (* y z) (* z t)) -2.2887889102874485e+227)
   (/ (/ (* x 2.0) (- y t)) z)
   (if (<= (- (* y z) (* z t)) -1.0002813918728466e-176)
     (/ (* x 2.0) (- (* y z) (* z t)))
     (if (<= (- (* y z) (* z t)) 2.9226969921444667e-241)
       (/ (/ (* x 2.0) (- y t)) z)
       (if (<= (- (* y z) (* z t)) 5.059772897437438e+137)
         (/ (* x 2.0) (- (* y z) (* z t)))
         (/ (* 2.0 (/ x z)) (- y t)))))))
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 tmp;
	if ((((double) (((double) (y * z)) - ((double) (z * t)))) <= -2.2887889102874485e+227)) {
		tmp = ((((double) (x * 2.0)) / ((double) (y - t))) / z);
	} else {
		double tmp_1;
		if ((((double) (((double) (y * z)) - ((double) (z * t)))) <= -1.0002813918728466e-176)) {
			tmp_1 = (((double) (x * 2.0)) / ((double) (((double) (y * z)) - ((double) (z * t)))));
		} else {
			double tmp_2;
			if ((((double) (((double) (y * z)) - ((double) (z * t)))) <= 2.9226969921444667e-241)) {
				tmp_2 = ((((double) (x * 2.0)) / ((double) (y - t))) / z);
			} else {
				double tmp_3;
				if ((((double) (((double) (y * z)) - ((double) (z * t)))) <= 5.059772897437438e+137)) {
					tmp_3 = (((double) (x * 2.0)) / ((double) (((double) (y * z)) - ((double) (z * t)))));
				} else {
					tmp_3 = (((double) (2.0 * (x / z))) / ((double) (y - t)));
				}
				tmp_2 = tmp_3;
			}
			tmp_1 = tmp_2;
		}
		tmp = tmp_1;
	}
	return tmp;
}

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.1
Herbie0.6
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} < -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} < 1.0450278273301259 \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)) < -2.28878891028744855e227 or -1.0002813918728466e-176 < (- (* y z) (* t z)) < 2.9226969921444667e-241

    1. Initial program Error: 14.7 bits

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. SimplifiedError: 15.2 bits

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{z}} \cdot \frac{2}{y - t}\]
    8. Using strategy rm
    9. Applied associate-*l/Error: 0.7 bits

      \[\leadsto \color{blue}{\frac{x \cdot \frac{2}{y - t}}{z}}\]
    10. Using strategy rm
    11. Applied associate-*r/Error: 0.6 bits

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

    if -2.28878891028744855e227 < (- (* y z) (* t z)) < -1.0002813918728466e-176 or 2.9226969921444667e-241 < (- (* y z) (* t z)) < 5.0597728974374384e137

    1. Initial program Error: 0.3 bits

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

    if 5.0597728974374384e137 < (- (* y z) (* t z))

    1. Initial program Error: 14.1 bits

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. SimplifiedError: 10.1 bits

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{z}} \cdot \frac{2}{y - t}\]
    8. Using strategy rm
    9. Applied associate-*r/Error: 1.3 bits

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - z \cdot t \leq -2.2887889102874485 \cdot 10^{+227}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq -1.0002813918728466 \cdot 10^{-176}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq 2.9226969921444667 \cdot 10^{-241}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq 5.059772897437438 \cdot 10^{+137}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{x}{z}}{y - t}\\ \end{array}\]

Reproduce

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