Average Error: 6.8 → 2.4
Time: 5.9s
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{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{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 r611328 = x;
        double r611329 = 2.0;
        double r611330 = r611328 * r611329;
        double r611331 = y;
        double r611332 = z;
        double r611333 = r611331 * r611332;
        double r611334 = t;
        double r611335 = r611334 * r611332;
        double r611336 = r611333 - r611335;
        double r611337 = r611330 / r611336;
        return r611337;
}

double f(double x, double y, double z, double t) {
        double r611338 = z;
        double r611339 = -2.7901145904076587e+45;
        bool r611340 = r611338 <= r611339;
        double r611341 = 3.071234821651189e+72;
        bool r611342 = r611338 <= r611341;
        double r611343 = !r611342;
        bool r611344 = r611340 || r611343;
        double r611345 = x;
        double r611346 = 2.0;
        double r611347 = r611345 * r611346;
        double r611348 = r611347 / r611338;
        double r611349 = 1.0;
        double r611350 = sqrt(r611349);
        double r611351 = y;
        double r611352 = t;
        double r611353 = r611351 - r611352;
        double r611354 = r611350 / r611353;
        double r611355 = r611348 * r611354;
        double r611356 = r611338 * r611353;
        double r611357 = r611347 / r611356;
        double r611358 = r611344 ? r611355 : r611357;
        return r611358;
}

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 div-inv9.8

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

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

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

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

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

    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 \frac{x \cdot 2}{\color{blue}{1 \cdot \left(z \cdot \left(y - t\right)\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{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))))