Average Error: 6.8 → 2.4
Time: 6.1s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.79011459040765873 \cdot 10^{45} \lor \neg \left(z \le 3.0712348216511889 \cdot 10^{72}\right):\\ \;\;\;\;\frac{x \cdot 2}{z} \cdot \frac{\sqrt[3]{1}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -2.79011459040765873 \cdot 10^{45} \lor \neg \left(z \le 3.0712348216511889 \cdot 10^{72}\right):\\
\;\;\;\;\frac{x \cdot 2}{z} \cdot \frac{\sqrt[3]{1}}{y - t}\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r661049 = x;
        double r661050 = 2.0;
        double r661051 = r661049 * r661050;
        double r661052 = y;
        double r661053 = z;
        double r661054 = r661052 * r661053;
        double r661055 = t;
        double r661056 = r661055 * r661053;
        double r661057 = r661054 - r661056;
        double r661058 = r661051 / r661057;
        return r661058;
}

double f(double x, double y, double z, double t) {
        double r661059 = z;
        double r661060 = -2.7901145904076587e+45;
        bool r661061 = r661059 <= r661060;
        double r661062 = 3.071234821651189e+72;
        bool r661063 = r661059 <= r661062;
        double r661064 = !r661063;
        bool r661065 = r661061 || r661064;
        double r661066 = x;
        double r661067 = 2.0;
        double r661068 = r661066 * r661067;
        double r661069 = r661068 / r661059;
        double r661070 = 1.0;
        double r661071 = cbrt(r661070);
        double r661072 = y;
        double r661073 = t;
        double r661074 = r661072 - r661073;
        double r661075 = r661071 / r661074;
        double r661076 = r661069 * r661075;
        double r661077 = r661059 * r661074;
        double r661078 = r661068 / r661077;
        double r661079 = r661065 ? r661076 : r661078;
        return r661079;
}

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
Herbie2.4
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \lt -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} \lt 1.04502782733012586 \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 2 regimes
  2. if z < -2.7901145904076587e+45 or 3.071234821651189e+72 < z

    1. Initial program 12.0

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{z \cdot \left(y - t\right)}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity9.8

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

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

      \[\leadsto 1 \cdot \left(\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)}\right)\]
    9. Applied times-frac9.1

      \[\leadsto 1 \cdot \left(\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)}\right)\]
    10. Applied associate-*r*2.0

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

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

    if -2.7901145904076587e+45 < z < 3.071234821651189e+72

    1. Initial program 2.7

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{z \cdot \left(y - t\right)}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity2.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -2.79011459040765873 \cdot 10^{45} \lor \neg \left(z \le 3.0712348216511889 \cdot 10^{72}\right):\\ \;\;\;\;\frac{x \cdot 2}{z} \cdot \frac{\sqrt[3]{1}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2020042 
(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.0450278273301259e-269) (/ (* (/ x z) 2) (- y t)) (* (/ x (* (- y t) z)) 2)))

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