Average Error: 6.8 → 1.2
Time: 6.4s
Precision: binary64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - z \cdot t \leq -7.2415019695736645 \cdot 10^{+267}:\\ \;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq -2.8170692500824498 \cdot 10^{-263}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\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}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \cdot z - z \cdot t \leq -7.2415019695736645 \cdot 10^{+267}:\\
\;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\

\mathbf{elif}\;y \cdot z - z \cdot t \leq -2.8170692500824498 \cdot 10^{-263}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\

\mathbf{else}:\\
\;\;\;\;\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}}\\

\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)) -7.2415019695736645e+267)
   (/ (* x (/ 2.0 (- y t))) z)
   (if (<= (- (* y z) (* z t)) -2.8170692500824498e-263)
     (/ (* x 2.0) (- (* y z) (* z t)))
     (*
      (*
       x
       (/
        (* (cbrt (/ 2.0 (- y t))) (cbrt (/ 2.0 (- y t))))
        (* (cbrt z) (cbrt z))))
      (/ (cbrt (/ 2.0 (- y t))) (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 tmp;
	if (((y * z) - (z * t)) <= -7.2415019695736645e+267) {
		tmp = (x * (2.0 / (y - t))) / z;
	} else if (((y * z) - (z * t)) <= -2.8170692500824498e-263) {
		tmp = (x * 2.0) / ((y * z) - (z * t));
	} else {
		tmp = (x * ((cbrt(2.0 / (y - t)) * cbrt(2.0 / (y - t))) / (cbrt(z) * cbrt(z)))) * (cbrt(2.0 / (y - t)) / 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.8
Target2.2
Herbie1.2
\[\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)) < -7.2415019695736645e267

    1. Initial program 15.7

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

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

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

    if -7.2415019695736645e267 < (-.f64 (*.f64 y z) (*.f64 t z)) < -2.8170692500824498e-263

    1. Initial program 0.2

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

    if -2.8170692500824498e-263 < (-.f64 (*.f64 y z) (*.f64 t z))

    1. Initial program 9.0

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

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

      \[\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_162827.6

      \[\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_162537.6

      \[\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_161872.0

      \[\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}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - z \cdot t \leq -7.2415019695736645 \cdot 10^{+267}:\\ \;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\ \mathbf{elif}\;y \cdot z - z \cdot t \leq -2.8170692500824498 \cdot 10^{-263}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - z \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\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}}\\ \end{array}\]

Reproduce

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