Average Error: 6.6 → 2.4
Time: 12.3s
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 r334787 = x;
        double r334788 = 2.0;
        double r334789 = r334787 * r334788;
        double r334790 = y;
        double r334791 = z;
        double r334792 = r334790 * r334791;
        double r334793 = t;
        double r334794 = r334793 * r334791;
        double r334795 = r334792 - r334794;
        double r334796 = r334789 / r334795;
        return r334796;
}

double f(double x, double y, double z, double t) {
        double r334797 = z;
        double r334798 = -2.037157504084274e-36;
        bool r334799 = r334797 <= r334798;
        double r334800 = x;
        double r334801 = 2.0;
        double r334802 = r334800 * r334801;
        double r334803 = r334802 / r334797;
        double r334804 = y;
        double r334805 = t;
        double r334806 = r334804 - r334805;
        double r334807 = r334803 / r334806;
        double r334808 = 3.8183668436170346e+83;
        bool r334809 = r334797 <= r334808;
        double r334810 = r334797 * r334806;
        double r334811 = r334802 / r334810;
        double r334812 = r334801 / r334806;
        double r334813 = r334800 * r334812;
        double r334814 = r334813 / r334797;
        double r334815 = r334809 ? r334811 : r334814;
        double r334816 = r334799 ? r334807 : r334815;
        return r334816;
}

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))))