Average Error: 6.8 → 3.0
Time: 3.6s
Precision: binary64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot 2 \le -1.58093999559816937 \cdot 10^{78} \lor \neg \left(x \cdot 2 \le 1.4938831530347273 \cdot 10^{125}\right):\\ \;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \frac{2}{z}}{y - t}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \cdot 2 \le -1.58093999559816937 \cdot 10^{78} \lor \neg \left(x \cdot 2 \le 1.4938831530347273 \cdot 10^{125}\right):\\
\;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\

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

\end{array}
double code(double x, double y, double z, double t) {
	return ((double) (((double) (x * 2.0)) / ((double) (((double) (y * z)) - ((double) (t * z))))));
}
double code(double x, double y, double z, double t) {
	double VAR;
	if (((((double) (x * 2.0)) <= -1.5809399955981694e+78) || !(((double) (x * 2.0)) <= 1.4938831530347273e+125))) {
		VAR = ((double) (((double) (x * ((double) (2.0 / ((double) (y - t)))))) / z));
	} else {
		VAR = ((double) (((double) (x * ((double) (2.0 / z)))) / ((double) (y - t))));
	}
	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.3
Herbie3.0
\[\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) < -1.58093999559816937e78 or 1.4938831530347273e125 < (* x 2.0)

    1. Initial program 13.8

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{z}} \cdot \frac{2}{y - t}\]
    8. Using strategy rm
    9. Applied associate-*l/3.6

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

    if -1.58093999559816937e78 < (* x 2.0) < 1.4938831530347273e125

    1. Initial program 3.9

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{x}{z} \cdot 2}{y - t}}\]
    10. Using strategy rm
    11. Applied *-un-lft-identity2.7

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

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

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

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

Reproduce

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