Average Error: 6.8 → 2.6
Time: 3.4s
Precision: binary64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.17849036859476826 \cdot 10^{26}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\ \mathbf{elif}\;z \le 8.30947769597875437 \cdot 10^{-100}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot \frac{\sqrt{2}}{\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}}\right) \cdot \frac{\frac{\sqrt{2}}{z}}{\sqrt[3]{y - t}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -1.17849036859476826 \cdot 10^{26}:\\
\;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\

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

\mathbf{else}:\\
\;\;\;\;\left(x \cdot \frac{\sqrt{2}}{\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}}\right) \cdot \frac{\frac{\sqrt{2}}{z}}{\sqrt[3]{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 ((z <= -1.1784903685947683e+26)) {
		VAR = ((double) (((double) (x / z)) * ((double) (2.0 / ((double) (y - t))))));
	} else {
		double VAR_1;
		if ((z <= 8.309477695978754e-100)) {
			VAR_1 = ((double) (((double) (x * 2.0)) / ((double) (z * ((double) (y - t))))));
		} else {
			VAR_1 = ((double) (((double) (x * ((double) (((double) sqrt(2.0)) / ((double) (((double) cbrt(((double) (y - t)))) * ((double) cbrt(((double) (y - t)))))))))) * ((double) (((double) (((double) sqrt(2.0)) / z)) / ((double) cbrt(((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.8
Target2.0
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 3 regimes
  2. if z < -1.17849036859476826e26

    1. Initial program 11.7

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

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

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

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

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

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

    if -1.17849036859476826e26 < z < 8.30947769597875437e-100

    1. Initial program 2.6

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

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

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

    if 8.30947769597875437e-100 < z

    1. Initial program 8.4

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

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

      \[\leadsto x \cdot \color{blue}{\frac{\frac{2}{z}}{y - t}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt6.7

      \[\leadsto x \cdot \frac{\frac{2}{z}}{\color{blue}{\left(\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}\right) \cdot \sqrt[3]{y - t}}}\]
    7. Applied *-un-lft-identity6.7

      \[\leadsto x \cdot \frac{\frac{2}{\color{blue}{1 \cdot z}}}{\left(\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}\right) \cdot \sqrt[3]{y - t}}\]
    8. Applied add-sqr-sqrt6.8

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.17849036859476826 \cdot 10^{26}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\ \mathbf{elif}\;z \le 8.30947769597875437 \cdot 10^{-100}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot \frac{\sqrt{2}}{\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}}\right) \cdot \frac{\frac{\sqrt{2}}{z}}{\sqrt[3]{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))))