Average Error: 6.8 → 2.6
Time: 2.0s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -6.5010644488975887 \cdot 10^{94} \lor \neg \left(x \le 3.8619926413929668 \cdot 10^{-62}\right):\\ \;\;\;\;\frac{2}{z} \cdot \frac{x}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \le -6.5010644488975887 \cdot 10^{94} \lor \neg \left(x \le 3.8619926413929668 \cdot 10^{-62}\right):\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y - t}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{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 <= -6.501064448897589e+94) || !(x <= 3.861992641392967e-62))) {
		VAR = ((2.0 / z) * (x / (y - t)));
	} else {
		VAR = (x / ((z * (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.8
Target2.1
Herbie2.6
\[\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 < -6.501064448897589e+94 or 3.861992641392967e-62 < x

    1. Initial program 10.9

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}}\]
    3. Using strategy rm
    4. Applied associate-/l*10.2

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{\frac{2}{y - t}}}}\]
    5. Applied associate-/r/10.9

      \[\leadsto \color{blue}{\frac{x}{z} \cdot \frac{2}{y - t}}\]
    6. Using strategy rm
    7. Applied clear-num11.0

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

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

      \[\leadsto \frac{\color{blue}{\frac{2}{y - t}}}{\frac{z}{x}}\]
    10. Using strategy rm
    11. Applied div-inv10.3

      \[\leadsto \frac{\frac{2}{y - t}}{\color{blue}{z \cdot \frac{1}{x}}}\]
    12. Applied div-inv10.3

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

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

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

    if -6.501064448897589e+94 < x < 3.861992641392967e-62

    1. Initial program 3.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -6.5010644488975887 \cdot 10^{94} \lor \neg \left(x \le 3.8619926413929668 \cdot 10^{-62}\right):\\ \;\;\;\;\frac{2}{z} \cdot \frac{x}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \end{array}\]

Reproduce

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