Average Error: 6.7 → 0.9
Time: 9.6s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -4.94066 \cdot 10^{-324} \lor \neg \left(\frac{x \cdot 2}{y \cdot z - t \cdot z} \le 0.0 \lor \neg \left(\frac{x \cdot 2}{y \cdot z - t \cdot z} \le 1.6145410396546016 \cdot 10^{223}\right)\right):\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z} \cdot \frac{x}{\frac{y - t}{2}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -4.94066 \cdot 10^{-324} \lor \neg \left(\frac{x \cdot 2}{y \cdot z - t \cdot z} \le 0.0 \lor \neg \left(\frac{x \cdot 2}{y \cdot z - t \cdot z} \le 1.6145410396546016 \cdot 10^{223}\right)\right):\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\

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

\end{array}
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 VAR;
	if (((((x * 2.0) / ((y * z) - (t * z))) <= -4.9406564584125e-324) || !((((x * 2.0) / ((y * z) - (t * z))) <= 0.0) || !(((x * 2.0) / ((y * z) - (t * z))) <= 1.6145410396546016e+223)))) {
		VAR = ((x * 2.0) / ((y * z) - (t * z)));
	} else {
		VAR = ((1.0 / z) * (x / ((y - t) / 2.0)));
	}
	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

Original6.7
Target2.2
Herbie0.9
\[\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 2 regimes
  2. if (/ (* x 2.0) (- (* y z) (* t z))) < -4.9406564584125e-324 or 0.0 < (/ (* x 2.0) (- (* y z) (* t z))) < 1.6145410396546016e+223

    1. Initial program 1.1

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

    if -4.9406564584125e-324 < (/ (* x 2.0) (- (* y z) (* t z))) < 0.0 or 1.6145410396546016e+223 < (/ (* x 2.0) (- (* y z) (* t z)))

    1. Initial program 16.4

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -4.94066 \cdot 10^{-324} \lor \neg \left(\frac{x \cdot 2}{y \cdot z - t \cdot z} \le 0.0 \lor \neg \left(\frac{x \cdot 2}{y \cdot z - t \cdot z} \le 1.6145410396546016 \cdot 10^{223}\right)\right):\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{z} \cdot \frac{x}{\frac{y - t}{2}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020079 +o rules:numerics
(FPCore (x y z t)
  :name "Linear.Projection:infinitePerspective from linear-1.19.1.3, A"
  :precision binary64

  :herbie-target
  (if (< (/ (* x 2) (- (* y z) (* t z))) -2.559141628295061e-13) (* (/ x (* (- y t) z)) 2) (if (< (/ (* x 2) (- (* y z) (* t z))) 1.0450278273301259e-269) (/ (* (/ x z) 2) (- y t)) (* (/ x (* (- y t) z)) 2)))

  (/ (* x 2) (- (* y z) (* t z))))