Average Error: 7.4 → 2.8
Time: 5.3s
Precision: binary64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -2.2106545227979478 \cdot 10^{-08} \lor \neg \left(z \leq 7.416951298675344 \cdot 10^{+123}\right):\\ \;\;\;\;\left(x \cdot \frac{2}{y - t}\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{2}{y - t}}{z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \leq -2.2106545227979478 \cdot 10^{-08} \lor \neg \left(z \leq 7.416951298675344 \cdot 10^{+123}\right):\\
\;\;\;\;\left(x \cdot \frac{2}{y - t}\right) \cdot \frac{1}{z}\\

\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{2}{y - t}}{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 (<= z -2.2106545227979478e-08) (not (<= z 7.416951298675344e+123)))
   (* (* x (/ 2.0 (- y t))) (/ 1.0 z))
   (* x (/ (/ 2.0 (- y t)) 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 ((z <= -2.2106545227979478e-08) || !(z <= 7.416951298675344e+123)) {
		tmp = (x * (2.0 / (y - t))) * (1.0 / z);
	} else {
		tmp = x * ((2.0 / (y - t)) / 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

Original7.4
Target2.2
Herbie2.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 z < -2.2106545227979478e-8 or 7.41695129867534437e123 < z

    1. Initial program 12.7

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

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

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

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

    if -2.2106545227979478e-8 < z < 7.41695129867534437e123

    1. Initial program 3.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.2106545227979478 \cdot 10^{-08} \lor \neg \left(z \leq 7.416951298675344 \cdot 10^{+123}\right):\\ \;\;\;\;\left(x \cdot \frac{2}{y - t}\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{2}{y - t}}{z}\\ \end{array}\]

Reproduce

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