Average Error: 6.4 → 2.3
Time: 7.0s
Precision: binary64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - z \cdot t} \leq -6.483783439194355 \cdot 10^{+17} \lor \neg \left(\frac{x \cdot 2}{y \cdot z - z \cdot t} \leq 3.592456861058638 \cdot 10^{+144}\right):\\ \;\;\;\;\left(x \cdot \frac{\sqrt[3]{\frac{2}{y - t}} \cdot \sqrt[3]{\frac{2}{y - t}}}{\sqrt[3]{z} \cdot \sqrt[3]{z}}\right) \cdot \frac{\sqrt[3]{\frac{2}{y - t}}}{\sqrt[3]{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{\frac{z}{2}}}{y - t}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot 2}{y \cdot z - z \cdot t} \leq -6.483783439194355 \cdot 10^{+17} \lor \neg \left(\frac{x \cdot 2}{y \cdot z - z \cdot t} \leq 3.592456861058638 \cdot 10^{+144}\right):\\
\;\;\;\;\left(x \cdot \frac{\sqrt[3]{\frac{2}{y - t}} \cdot \sqrt[3]{\frac{2}{y - t}}}{\sqrt[3]{z} \cdot \sqrt[3]{z}}\right) \cdot \frac{\sqrt[3]{\frac{2}{y - t}}}{\sqrt[3]{z}}\\

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

\end{array}
(FPCore (x y z t) :precision binary64 (/ (* x 2.0) (- (* y z) (* t z))))
(FPCore (x y z t)
 :precision binary64
 (if (or (<= (/ (* x 2.0) (- (* y z) (* z t))) -6.483783439194355e+17)
         (not (<= (/ (* x 2.0) (- (* y z) (* z t))) 3.592456861058638e+144)))
   (*
    (*
     x
     (/
      (* (cbrt (/ 2.0 (- y t))) (cbrt (/ 2.0 (- y t))))
      (* (cbrt z) (cbrt z))))
    (/ (cbrt (/ 2.0 (- y t))) (cbrt z)))
   (/ (/ x (/ z 2.0)) (- y t))))
double code(double x, double y, double z, double t) {
	return (x * 2.0) / ((y * z) - (t * z));
}
double code(double x, double y, double z, double t) {
	double tmp;
	if ((((x * 2.0) / ((y * z) - (z * t))) <= -6.483783439194355e+17) || !(((x * 2.0) / ((y * z) - (z * t))) <= 3.592456861058638e+144)) {
		tmp = (x * ((cbrt(2.0 / (y - t)) * cbrt(2.0 / (y - t))) / (cbrt(z) * cbrt(z)))) * (cbrt(2.0 / (y - t)) / cbrt(z));
	} else {
		tmp = (x / (z / 2.0)) / (y - t);
	}
	return tmp;
}

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.4
Target2.0
Herbie2.3
\[\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 2 regimes
  2. if (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z))) < -648378343919435520 or 3.5924568610586377e144 < (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z)))

    1. Initial program 10.3

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

      \[\leadsto \color{blue}{x \cdot \frac{\frac{2}{y - t}}{z}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt_binary64_130716.9

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

      \[\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}}}}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}\]
    6. Applied times-frac_binary64_130427.1

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

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

    if -648378343919435520 < (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z))) < 3.5924568610586377e144

    1. Initial program 5.3

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \frac{2}{y - t}}{z}}\]
    5. Using strategy rm
    6. Applied clear-num_binary64_130356.4

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

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

      \[\leadsto \frac{1}{\frac{z}{\color{blue}{\frac{2 \cdot x}{y - t}}}}\]
    10. Applied associate-/r/_binary64_129822.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - z \cdot t} \leq -6.483783439194355 \cdot 10^{+17} \lor \neg \left(\frac{x \cdot 2}{y \cdot z - z \cdot t} \leq 3.592456861058638 \cdot 10^{+144}\right):\\ \;\;\;\;\left(x \cdot \frac{\sqrt[3]{\frac{2}{y - t}} \cdot \sqrt[3]{\frac{2}{y - t}}}{\sqrt[3]{z} \cdot \sqrt[3]{z}}\right) \cdot \frac{\sqrt[3]{\frac{2}{y - t}}}{\sqrt[3]{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{\frac{z}{2}}}{y - t}\\ \end{array}\]

Reproduce

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