Average Error: 6.7 → 3.7
Time: 8.6s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot 2 \le -2.81976873589677169 \cdot 10^{79}:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{\frac{1}{z}}{y - t}\\ \mathbf{elif}\;x \cdot 2 \le 28.497285745122717:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{\frac{z}{\frac{x}{y - t}}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \cdot 2 \le -2.81976873589677169 \cdot 10^{79}:\\
\;\;\;\;\left(x \cdot 2\right) \cdot \frac{\frac{1}{z}}{y - t}\\

\mathbf{elif}\;x \cdot 2 \le 28.497285745122717:\\
\;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\

\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{z}{\frac{x}{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)) <= -2.8197687358967717e+79)) {
		VAR = ((double) (((double) (x * 2.0)) * ((double) (((double) (1.0 / z)) / ((double) (y - t))))));
	} else {
		double VAR_1;
		if ((((double) (x * 2.0)) <= 28.497285745122717)) {
			VAR_1 = ((double) (((double) (((double) (x * 2.0)) / z)) / ((double) (y - t))));
		} else {
			VAR_1 = ((double) (2.0 / ((double) (z / ((double) (x / ((double) (y - t))))))));
		}
		VAR = VAR_1;
	}
	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
Target1.9
Herbie3.7
\[\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 3 regimes
  2. if (* x 2.0) < -2.8197687358967717e+79

    1. Initial program 13.6

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. Using strategy rm
    3. Applied div-inv13.7

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

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

    if -2.8197687358967717e+79 < (* x 2.0) < 28.497285745122717

    1. Initial program 3.1

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

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

      \[\leadsto \left(x \cdot 2\right) \cdot \color{blue}{\frac{\frac{1}{z}}{y - t}}\]
    5. Using strategy rm
    6. Applied associate-*r/2.0

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

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

    if 28.497285745122717 < (* x 2.0)

    1. Initial program 11.2

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. Using strategy rm
    3. Applied *-commutative11.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot 2 \le -2.81976873589677169 \cdot 10^{79}:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{\frac{1}{z}}{y - t}\\ \mathbf{elif}\;x \cdot 2 \le 28.497285745122717:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{\frac{z}{\frac{x}{y - t}}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020113 +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))))