Average Error: 6.9 → 0.4
Time: 4.0s
Precision: binary64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - z \cdot t \leq -2.6959315728345433 \cdot 10^{+279}:\\ \;\;\;\;\frac{x \cdot \frac{2}{z}}{y - t}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq -6.506340873445863 \cdot 10^{-142}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq 1.1600846731921496 \cdot 10^{-273}:\\ \;\;\;\;\frac{1}{z \cdot \frac{y - t}{x \cdot 2}}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq 1.0796196230071177 \cdot 10^{+249}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \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}\;y \cdot z - z \cdot t \leq -2.6959315728345433 \cdot 10^{+279}:\\
\;\;\;\;\frac{x \cdot \frac{2}{z}}{y - t}\\

\mathbf{elif}\;y \cdot z - z \cdot t \leq -6.506340873445863 \cdot 10^{-142}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\

\mathbf{elif}\;y \cdot z - z \cdot t \leq 1.1600846731921496 \cdot 10^{-273}:\\
\;\;\;\;\frac{1}{z \cdot \frac{y - t}{x \cdot 2}}\\

\mathbf{elif}\;y \cdot z - z \cdot t \leq 1.0796196230071177 \cdot 10^{+249}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\

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

\end{array}
double code(double x, double y, double z, double t) {
	return (((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) (((double) (y * z)) - ((double) (z * t)))) <= -2.6959315728345433e+279)) {
		VAR = (((double) (x * (2.0 / z))) / ((double) (y - t)));
	} else {
		double VAR_1;
		if ((((double) (((double) (y * z)) - ((double) (z * t)))) <= -6.506340873445863e-142)) {
			VAR_1 = (((double) (x * 2.0)) / ((double) (((double) (y * z)) - ((double) (z * t)))));
		} else {
			double VAR_2;
			if ((((double) (((double) (y * z)) - ((double) (z * t)))) <= 1.1600846731921496e-273)) {
				VAR_2 = (1.0 / ((double) (z * (((double) (y - t)) / ((double) (x * 2.0))))));
			} else {
				double VAR_3;
				if ((((double) (((double) (y * z)) - ((double) (z * t)))) <= 1.0796196230071177e+249)) {
					VAR_3 = (((double) (x * 2.0)) / ((double) (((double) (y * z)) - ((double) (z * t)))));
				} else {
					VAR_3 = (((double) (x * (2.0 / z))) / ((double) (y - t)));
				}
				VAR_2 = VAR_3;
			}
			VAR_1 = VAR_2;
		}
		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.9
Target2.2
Herbie0.4
\[\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 3 regimes
  2. if (- (* y z) (* t z)) < -2.6959315728345433e279 or 1.0796196230071177e249 < (- (* y z) (* t z))

    1. Initial program Error: 19.8 bits

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. SimplifiedError: 16.1 bits

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

      \[\leadsto x \cdot \color{blue}{\frac{\frac{2}{z}}{y - t}}\]
    5. Using strategy rm
    6. Applied associate-*r/Error: 0.2 bits

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

    if -2.6959315728345433e279 < (- (* y z) (* t z)) < -6.5063408734458633e-142 or 1.1600846731921496e-273 < (- (* y z) (* t z)) < 1.0796196230071177e249

    1. Initial program Error: 0.3 bits

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

    if -6.5063408734458633e-142 < (- (* y z) (* t z)) < 1.1600846731921496e-273

    1. Initial program Error: 17.1 bits

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. SimplifiedError: 18.7 bits

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

      \[\leadsto x \cdot \color{blue}{\frac{\frac{2}{z}}{y - t}}\]
    5. Using strategy rm
    6. Applied associate-*r/Error: 2.5 bits

      \[\leadsto \color{blue}{\frac{x \cdot \frac{2}{z}}{y - t}}\]
    7. Using strategy rm
    8. Applied clear-numError: 2.6 bits

      \[\leadsto \color{blue}{\frac{1}{\frac{y - t}{x \cdot \frac{2}{z}}}}\]
    9. SimplifiedError: 3.4 bits

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - z \cdot t \leq -2.6959315728345433 \cdot 10^{+279}:\\ \;\;\;\;\frac{x \cdot \frac{2}{z}}{y - t}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq -6.506340873445863 \cdot 10^{-142}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq 1.1600846731921496 \cdot 10^{-273}:\\ \;\;\;\;\frac{1}{z \cdot \frac{y - t}{x \cdot 2}}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq 1.0796196230071177 \cdot 10^{+249}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \frac{2}{z}}{y - t}\\ \end{array}\]

Reproduce

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