Average Error: 6.7 → 0.5
Time: 9.5s
Precision: binary64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - z \cdot t \leq -\infty:\\ \;\;\;\;\frac{2 \cdot \frac{x}{y - t}}{z}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq -1.7542876780262188 \cdot 10^{-189}:\\ \;\;\;\;2 \cdot \frac{x}{z \cdot \left(y - t\right)}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq 1.494963151258016 \cdot 10^{-125} \lor \neg \left(y \cdot z - z \cdot t \leq 2.0363037439895763 \cdot 10^{+189}\right):\\ \;\;\;\;\frac{2 \cdot \frac{x}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot x}{y \cdot z - z \cdot 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 -\infty:\\
\;\;\;\;\frac{2 \cdot \frac{x}{y - t}}{z}\\

\mathbf{elif}\;y \cdot z - z \cdot t \leq -1.7542876780262188 \cdot 10^{-189}:\\
\;\;\;\;2 \cdot \frac{x}{z \cdot \left(y - t\right)}\\

\mathbf{elif}\;y \cdot z - z \cdot t \leq 1.494963151258016 \cdot 10^{-125} \lor \neg \left(y \cdot z - z \cdot t \leq 2.0363037439895763 \cdot 10^{+189}\right):\\
\;\;\;\;\frac{2 \cdot \frac{x}{y - t}}{z}\\

\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot x}{y \cdot z - z \cdot 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 (<= (- (* y z) (* z t)) (- INFINITY))
   (/ (* 2.0 (/ x (- y t))) z)
   (if (<= (- (* y z) (* z t)) -1.7542876780262188e-189)
     (* 2.0 (/ x (* z (- y t))))
     (if (or (<= (- (* y z) (* z t)) 1.494963151258016e-125)
             (not (<= (- (* y z) (* z t)) 2.0363037439895763e+189)))
       (/ (* 2.0 (/ x (- y t))) z)
       (/ (* 2.0 x) (- (* y z) (* z 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 (((y * z) - (z * t)) <= -((double) INFINITY)) {
		tmp = (2.0 * (x / (y - t))) / z;
	} else if (((y * z) - (z * t)) <= -1.7542876780262188e-189) {
		tmp = 2.0 * (x / (z * (y - t)));
	} else if ((((y * z) - (z * t)) <= 1.494963151258016e-125) || !(((y * z) - (z * t)) <= 2.0363037439895763e+189)) {
		tmp = (2.0 * (x / (y - t))) / z;
	} else {
		tmp = (2.0 * x) / ((y * z) - (z * 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.7
Target2.3
Herbie0.5
\[\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 (-.f64 (*.f64 y z) (*.f64 t z)) < -inf.0 or -1.7542876780262188e-189 < (-.f64 (*.f64 y z) (*.f64 t z)) < 1.4949631512580159e-125 or 2.03630374398957635e189 < (-.f64 (*.f64 y z) (*.f64 t z))

    1. Initial program 16.7

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

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

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

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

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

      \[\leadsto x \cdot \frac{\color{blue}{\frac{1}{\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}} \cdot \frac{2}{\sqrt[3]{y - t}}}}{1 \cdot z}\]
    8. Applied times-frac_binary64_1338313.5

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

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

      \[\leadsto \color{blue}{\frac{x}{\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}}} \cdot \frac{\frac{2}{\sqrt[3]{y - t}}}{z}\]
    11. Using strategy rm
    12. Applied pow1_binary64_134383.5

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

      \[\leadsto \color{blue}{{\left(\frac{x}{\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}}\right)}^{1}} \cdot {\left(\frac{\frac{2}{\sqrt[3]{y - t}}}{z}\right)}^{1}\]
    14. Applied pow-prod-down_binary64_134483.5

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

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

    if -inf.0 < (-.f64 (*.f64 y z) (*.f64 t z)) < -1.7542876780262188e-189

    1. Initial program 0.2

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

      \[\leadsto \color{blue}{x \cdot \frac{\frac{2}{y - t}}{z}}\]
    3. Taylor expanded around 0 0.2

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

    if 1.4949631512580159e-125 < (-.f64 (*.f64 y z) (*.f64 t z)) < 2.03630374398957635e189

    1. Initial program 0.3

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - z \cdot t \leq -\infty:\\ \;\;\;\;\frac{2 \cdot \frac{x}{y - t}}{z}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq -1.7542876780262188 \cdot 10^{-189}:\\ \;\;\;\;2 \cdot \frac{x}{z \cdot \left(y - t\right)}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq 1.494963151258016 \cdot 10^{-125} \lor \neg \left(y \cdot z - z \cdot t \leq 2.0363037439895763 \cdot 10^{+189}\right):\\ \;\;\;\;\frac{2 \cdot \frac{x}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot x}{y \cdot z - z \cdot t}\\ \end{array}\]

Reproduce

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