Average Error: 6.7 → 1.0
Time: 8.3s
Precision: binary64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z} \]
\[\begin{array}{l} t_1 := y \cdot z - z \cdot t\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;\frac{x \cdot 2}{y - t} \cdot \frac{1}{z}\\ \mathbf{elif}\;t_1 \leq -6.918565620220263 \cdot 10^{-290}:\\ \;\;\;\;\frac{x \cdot 2}{t_1}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_2 := \sqrt[3]{y - t}\\ \left(x \cdot \frac{\frac{1}{t_2 \cdot t_2}}{\sqrt[3]{z} \cdot \sqrt[3]{z}}\right) \cdot \frac{\frac{2}{t_2}}{\sqrt[3]{z}} \end{array}\\ \end{array} \]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
t_1 := y \cdot z - z \cdot t\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\frac{x \cdot 2}{y - t} \cdot \frac{1}{z}\\

\mathbf{elif}\;t_1 \leq -6.918565620220263 \cdot 10^{-290}:\\
\;\;\;\;\frac{x \cdot 2}{t_1}\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_2 := \sqrt[3]{y - t}\\
\left(x \cdot \frac{\frac{1}{t_2 \cdot t_2}}{\sqrt[3]{z} \cdot \sqrt[3]{z}}\right) \cdot \frac{\frac{2}{t_2}}{\sqrt[3]{z}}
\end{array}\\


\end{array}
(FPCore (x y z t) :precision binary64 (/ (* x 2.0) (- (* y z) (* t z))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (* y z) (* z t))))
   (if (<= t_1 (- INFINITY))
     (* (/ (* x 2.0) (- y t)) (/ 1.0 z))
     (if (<= t_1 -6.918565620220263e-290)
       (/ (* x 2.0) t_1)
       (let* ((t_2 (cbrt (- y t))))
         (*
          (* x (/ (/ 1.0 (* t_2 t_2)) (* (cbrt z) (cbrt z))))
          (/ (/ 2.0 t_2) (cbrt z))))))))
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 t_1 = (y * z) - (z * t);
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = ((x * 2.0) / (y - t)) * (1.0 / z);
	} else if (t_1 <= -6.918565620220263e-290) {
		tmp = (x * 2.0) / t_1;
	} else {
		double t_2 = cbrt(y - t);
		tmp = (x * ((1.0 / (t_2 * t_2)) / (cbrt(z) * cbrt(z)))) * ((2.0 / t_2) / cbrt(z));
	}
	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.1
Herbie1.0
\[\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.045027827330126 \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

    1. Initial program 20.7

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

      \[\leadsto \color{blue}{x \cdot \frac{\frac{2}{y - t}}{z}} \]
    3. Applied *-un-lft-identity_binary6418.9

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

      \[\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} \]
    5. Applied *-un-lft-identity_binary6418.9

      \[\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} \]
    6. Applied times-frac_binary6418.9

      \[\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} \]
    7. Applied times-frac_binary6418.9

      \[\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)} \]
    8. Applied associate-*r*_binary643.3

      \[\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}} \]
    9. Simplified3.3

      \[\leadsto \color{blue}{\frac{x}{\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}}} \cdot \frac{\frac{2}{\sqrt[3]{y - t}}}{z} \]
    10. Applied div-inv_binary643.3

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

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

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

    if -inf.0 < (-.f64 (*.f64 y z) (*.f64 t z)) < -6.91856562022026286e-290

    1. Initial program 0.2

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

    if -6.91856562022026286e-290 < (-.f64 (*.f64 y z) (*.f64 t z))

    1. Initial program 8.6

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

      \[\leadsto \color{blue}{x \cdot \frac{\frac{2}{y - t}}{z}} \]
    3. Applied add-cube-cbrt_binary647.0

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - z \cdot t \leq -\infty:\\ \;\;\;\;\frac{x \cdot 2}{y - t} \cdot \frac{1}{z}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq -6.918565620220263 \cdot 10^{-290}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot \frac{\frac{1}{\sqrt[3]{y - t} \cdot \sqrt[3]{y - t}}}{\sqrt[3]{z} \cdot \sqrt[3]{z}}\right) \cdot \frac{\frac{2}{\sqrt[3]{y - t}}}{\sqrt[3]{z}}\\ \end{array} \]

Reproduce

herbie shell --seed 2021313 
(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.045027827330126e-269) (/ (* (/ x z) 2.0) (- y t)) (* (/ x (* (- y t) z)) 2.0)))

  (/ (* x 2.0) (- (* y z) (* t z))))