Average Error: 6.6 → 2.4
Time: 11.8s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.037157504084274034815349795281714872542 \cdot 10^{-36}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{elif}\;z \le 3.818366843617034597316373479678641130316 \cdot 10^{83}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -2.037157504084274034815349795281714872542 \cdot 10^{-36}:\\
\;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r392054 = x;
        double r392055 = 2.0;
        double r392056 = r392054 * r392055;
        double r392057 = y;
        double r392058 = z;
        double r392059 = r392057 * r392058;
        double r392060 = t;
        double r392061 = r392060 * r392058;
        double r392062 = r392059 - r392061;
        double r392063 = r392056 / r392062;
        return r392063;
}

double f(double x, double y, double z, double t) {
        double r392064 = z;
        double r392065 = -2.037157504084274e-36;
        bool r392066 = r392064 <= r392065;
        double r392067 = x;
        double r392068 = 2.0;
        double r392069 = r392067 * r392068;
        double r392070 = r392069 / r392064;
        double r392071 = y;
        double r392072 = t;
        double r392073 = r392071 - r392072;
        double r392074 = r392070 / r392073;
        double r392075 = 3.8183668436170346e+83;
        bool r392076 = r392064 <= r392075;
        double r392077 = r392064 * r392073;
        double r392078 = r392069 / r392077;
        double r392079 = r392068 / r392073;
        double r392080 = r392067 * r392079;
        double r392081 = r392080 / r392064;
        double r392082 = r392076 ? r392078 : r392081;
        double r392083 = r392066 ? r392074 : r392082;
        return r392083;
}

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.6
Target2.2
Herbie2.4
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \lt -2.559141628295061113708240820439530037456 \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.045027827330126029709547581125571222799 \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 < -2.037157504084274e-36

    1. Initial program 9.3

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

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

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

    if -2.037157504084274e-36 < z < 3.8183668436170346e+83

    1. Initial program 2.5

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{z \cdot \left(y - t\right)}}\]
    3. Using strategy rm
    4. Applied div-inv2.9

      \[\leadsto \color{blue}{\left(x \cdot 2\right) \cdot \frac{1}{z \cdot \left(y - t\right)}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt2.9

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

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

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

      \[\leadsto \left(x \cdot 2\right) \cdot \left(\frac{1}{z} \cdot \color{blue}{\frac{1}{y - t}}\right)\]
    10. Using strategy rm
    11. Applied frac-times2.9

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

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

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

    if 3.8183668436170346e+83 < z

    1. Initial program 12.9

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{z \cdot \left(y - t\right)}}\]
    3. Using strategy rm
    4. Applied div-inv10.3

      \[\leadsto \color{blue}{\left(x \cdot 2\right) \cdot \frac{1}{z \cdot \left(y - t\right)}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt10.3

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

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

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

      \[\leadsto \left(x \cdot 2\right) \cdot \left(\frac{1}{z} \cdot \color{blue}{\frac{1}{y - t}}\right)\]
    10. Using strategy rm
    11. Applied associate-*l/9.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -2.037157504084274034815349795281714872542 \cdot 10^{-36}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{elif}\;z \le 3.818366843617034597316373479678641130316 \cdot 10^{83}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\ \end{array}\]

Reproduce

herbie shell --seed 2019323 
(FPCore (x y z t)
  :name "Linear.Projection:infinitePerspective from linear-1.19.1.3, A"
  :precision binary64

  :herbie-target
  (if (< (/ (* x 2) (- (* y z) (* t z))) -2.559141628295061e-13) (* (/ x (* (- y t) z)) 2) (if (< (/ (* x 2) (- (* y z) (* t z))) 1.045027827330126e-269) (/ (* (/ x z) 2) (- y t)) (* (/ x (* (- y t) z)) 2)))

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