Average Error: 6.7 → 0.8
Time: 6.6s
Precision: binary64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - z \cdot t} \leq -2.9495719056722 \cdot 10^{-321} \lor \neg \left(\frac{x \cdot 2}{y \cdot z - z \cdot t} \leq 0\right) \land \frac{x \cdot 2}{y \cdot z - z \cdot t} \leq 1.468395727102597 \cdot 10^{+278}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot \frac{2}{y - t}\right) \cdot \frac{1}{z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot 2}{y \cdot z - z \cdot t} \leq -2.9495719056722 \cdot 10^{-321} \lor \neg \left(\frac{x \cdot 2}{y \cdot z - z \cdot t} \leq 0\right) \land \frac{x \cdot 2}{y \cdot z - z \cdot t} \leq 1.468395727102597 \cdot 10^{+278}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\

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

\end{array}
(FPCore (x y z t) :precision binary64 (/ (* x 2.0) (- (* y z) (* t z))))
(FPCore (x y z t)
 :precision binary64
 (if (or (<= (/ (* x 2.0) (- (* y z) (* z t))) -2.9495719056722e-321)
         (and (not (<= (/ (* x 2.0) (- (* y z) (* z t))) 0.0))
              (<= (/ (* x 2.0) (- (* y z) (* z t))) 1.468395727102597e+278)))
   (/ (* x 2.0) (- (* y z) (* z t)))
   (* (* x (/ 2.0 (- y t))) (/ 1.0 z))))
double code(double x, double y, double z, double t) {
	return (x * 2.0) / ((y * z) - (t * z));
}
double code(double x, double y, double z, double t) {
	double tmp;
	if ((((x * 2.0) / ((y * z) - (z * t))) <= -2.9495719056722e-321) || (!(((x * 2.0) / ((y * z) - (z * t))) <= 0.0) && (((x * 2.0) / ((y * z) - (z * t))) <= 1.468395727102597e+278))) {
		tmp = (x * 2.0) / ((y * z) - (z * t));
	} else {
		tmp = (x * (2.0 / (y - t))) * (1.0 / z);
	}
	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.2
Herbie0.8
\[\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 2 regimes
  2. if (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z))) < -2.94957e-321 or 0.0 < (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z))) < 1.468395727102597e278

    1. Initial program 1.1

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

    if -2.94957e-321 < (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z))) < 0.0 or 1.468395727102597e278 < (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z)))

    1. Initial program 17.5

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

      \[\leadsto \color{blue}{x \cdot \frac{\frac{2}{y - t}}{z}}\]
    3. Using strategy rm
    4. Applied div-inv_binary6413.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - z \cdot t} \leq -2.9495719056722 \cdot 10^{-321} \lor \neg \left(\frac{x \cdot 2}{y \cdot z - z \cdot t} \leq 0\right) \land \frac{x \cdot 2}{y \cdot z - z \cdot t} \leq 1.468395727102597 \cdot 10^{+278}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot \frac{2}{y - t}\right) \cdot \frac{1}{z}\\ \end{array}\]

Reproduce

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