Average Error: 6.7 → 3.4
Time: 4.5s
Precision: binary64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot 2 \leq -2.4530713635096856 \cdot 10^{-36}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \mathbf{elif}\;x \cdot 2 \leq 2.956819744716004 \cdot 10^{+227} \lor \neg \left(x \cdot 2 \leq 1.122968697172558 \cdot 10^{+289}\right):\\ \;\;\;\;\frac{x \cdot 2}{\left(y - t\right) \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{z}{x \cdot \frac{2}{y - t}}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \cdot 2 \leq -2.4530713635096856 \cdot 10^{-36}:\\
\;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\

\mathbf{elif}\;x \cdot 2 \leq 2.956819744716004 \cdot 10^{+227} \lor \neg \left(x \cdot 2 \leq 1.122968697172558 \cdot 10^{+289}\right):\\
\;\;\;\;\frac{x \cdot 2}{\left(y - t\right) \cdot z}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{z}{x \cdot \frac{2}{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 (<= (* x 2.0) -2.4530713635096856e-36)
   (/ (/ (* x 2.0) (- y t)) z)
   (if (or (<= (* x 2.0) 2.956819744716004e+227)
           (not (<= (* x 2.0) 1.122968697172558e+289)))
     (/ (* x 2.0) (* (- y t) z))
     (/ 1.0 (/ z (* x (/ 2.0 (- 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) (x * 2.0)) <= -2.4530713635096856e-36)) {
		tmp = ((((double) (x * 2.0)) / ((double) (y - t))) / z);
	} else {
		double tmp_1;
		if (((((double) (x * 2.0)) <= 2.956819744716004e+227) || !(((double) (x * 2.0)) <= 1.122968697172558e+289))) {
			tmp_1 = (((double) (x * 2.0)) / ((double) (((double) (y - t)) * z)));
		} else {
			tmp_1 = (1.0 / (z / ((double) (x * (2.0 / ((double) (y - t)))))));
		}
		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

Original6.7
Target2.1
Herbie3.4
\[\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 (*.f64 x 2.0) < -2.4530713635096856e-36

    1. Initial program 9.7

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

      \[\leadsto \color{blue}{x \cdot \frac{\frac{2}{y - t}}{z}}\]
    3. Using strategy rm
    4. Applied associate-*r/_binary642.1

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

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

    if -2.4530713635096856e-36 < (*.f64 x 2.0) < 2.95681974471600386e227 or 1.122968697172558e289 < (*.f64 x 2.0)

    1. Initial program 5.0

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

      \[\leadsto \color{blue}{x \cdot \frac{\frac{2}{y - t}}{z}}\]
    3. Using strategy rm
    4. Applied associate-*r/_binary646.5

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

      \[\leadsto \frac{\color{blue}{\frac{x \cdot 2}{y - t}}}{z}\]
    7. Applied associate-/l/_binary643.8

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

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

    if 2.95681974471600386e227 < (*.f64 x 2.0) < 1.122968697172558e289

    1. Initial program 17.8

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

      \[\leadsto \color{blue}{x \cdot \frac{\frac{2}{y - t}}{z}}\]
    3. Using strategy rm
    4. Applied associate-*r/_binary644.1

      \[\leadsto \color{blue}{\frac{x \cdot \frac{2}{y - t}}{z}}\]
    5. Using strategy rm
    6. Applied clear-num_binary644.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot 2 \leq -2.4530713635096856 \cdot 10^{-36}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \mathbf{elif}\;x \cdot 2 \leq 2.956819744716004 \cdot 10^{+227} \lor \neg \left(x \cdot 2 \leq 1.122968697172558 \cdot 10^{+289}\right):\\ \;\;\;\;\frac{x \cdot 2}{\left(y - t\right) \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{z}{x \cdot \frac{2}{y - t}}}\\ \end{array}\]

Reproduce

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