Average Error: 6.8 → 2.8
Time: 6.9s
Precision: binary64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -5.31684019028634685 \cdot 10^{113}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{elif}\;z \le 1.193046430717286 \cdot 10^{-177}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \mathbf{elif}\;z \le 1.42402060742132382 \cdot 10^{236}:\\ \;\;\;\;\left(\left(\sqrt[3]{\frac{2}{y - t}} \cdot \sqrt[3]{\frac{2}{y - t}}\right) \cdot x\right) \cdot \frac{\sqrt[3]{\frac{2}{y - t}}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -5.31684019028634685 \cdot 10^{113}:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\

\mathbf{elif}\;z \le 1.193046430717286 \cdot 10^{-177}:\\
\;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\

\mathbf{elif}\;z \le 1.42402060742132382 \cdot 10^{236}:\\
\;\;\;\;\left(\left(\sqrt[3]{\frac{2}{y - t}} \cdot \sqrt[3]{\frac{2}{y - t}}\right) \cdot x\right) \cdot \frac{\sqrt[3]{\frac{2}{y - t}}}{z}\\

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

\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 ((z <= -5.316840190286347e+113)) {
		VAR = ((double) (((double) (x / z)) / ((double) (((double) (y - t)) / 2.0))));
	} else {
		double VAR_1;
		if ((z <= 1.193046430717286e-177)) {
			VAR_1 = ((double) (x / ((double) (((double) (z * ((double) (y - t)))) / 2.0))));
		} else {
			double VAR_2;
			if ((z <= 1.4240206074213238e+236)) {
				VAR_2 = ((double) (((double) (((double) (((double) cbrt(((double) (2.0 / ((double) (y - t)))))) * ((double) cbrt(((double) (2.0 / ((double) (y - t)))))))) * x)) * ((double) (((double) cbrt(((double) (2.0 / ((double) (y - t)))))) / z))));
			} else {
				VAR_2 = ((double) (((double) (x / z)) / ((double) (((double) (y - t)) / 2.0))));
			}
			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.8
Target2.0
Herbie2.8
\[\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 z < -5.31684019028634685e113 or 1.42402060742132382e236 < z

    1. Initial program 14.7

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{y - t}{2}}}\]
    6. Applied associate-/r*2.3

      \[\leadsto \color{blue}{\frac{\frac{x}{\frac{z}{1}}}{\frac{y - t}{2}}}\]
    7. Simplified2.3

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

    if -5.31684019028634685e113 < z < 1.193046430717286e-177

    1. Initial program 3.4

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

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

    if 1.193046430717286e-177 < z < 1.42402060742132382e236

    1. Initial program 5.6

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}}\]
    3. Using strategy rm
    4. Applied div-inv5.2

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

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

      \[\leadsto x \cdot \frac{\frac{2}{y - t}}{\color{blue}{1 \cdot z}}\]
    8. Applied add-cube-cbrt5.5

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.31684019028634685 \cdot 10^{113}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{elif}\;z \le 1.193046430717286 \cdot 10^{-177}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \mathbf{elif}\;z \le 1.42402060742132382 \cdot 10^{236}:\\ \;\;\;\;\left(\left(\sqrt[3]{\frac{2}{y - t}} \cdot \sqrt[3]{\frac{2}{y - t}}\right) \cdot x\right) \cdot \frac{\sqrt[3]{\frac{2}{y - t}}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \end{array}\]

Reproduce

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