Average Error: 6.7 → 2.4
Time: 7.1s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -6.3098383512066379 \cdot 10^{121} \lor \neg \left(z \le 8624013021746182490000\right):\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{2}{z}}{y - t}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -6.3098383512066379 \cdot 10^{121} \lor \neg \left(z \le 8624013021746182490000\right):\\
\;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r307288 = x;
        double r307289 = 2.0;
        double r307290 = r307288 * r307289;
        double r307291 = y;
        double r307292 = z;
        double r307293 = r307291 * r307292;
        double r307294 = t;
        double r307295 = r307294 * r307292;
        double r307296 = r307293 - r307295;
        double r307297 = r307290 / r307296;
        return r307297;
}

double f(double x, double y, double z, double t) {
        double r307298 = z;
        double r307299 = -6.309838351206638e+121;
        bool r307300 = r307298 <= r307299;
        double r307301 = 8.624013021746182e+21;
        bool r307302 = r307298 <= r307301;
        double r307303 = !r307302;
        bool r307304 = r307300 || r307303;
        double r307305 = x;
        double r307306 = 2.0;
        double r307307 = r307305 * r307306;
        double r307308 = r307307 / r307298;
        double r307309 = y;
        double r307310 = t;
        double r307311 = r307309 - r307310;
        double r307312 = r307308 / r307311;
        double r307313 = r307306 / r307298;
        double r307314 = r307313 / r307311;
        double r307315 = r307305 * r307314;
        double r307316 = r307304 ? r307312 : r307315;
        return r307316;
}

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.7
Target1.9
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 < -6.309838351206638e+121 or 8.624013021746182e+21 < z

    1. Initial program 12.4

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

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

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

    if -6.309838351206638e+121 < z < 8.624013021746182e+21

    1. Initial program 2.8

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

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

      \[\leadsto \color{blue}{\frac{\frac{x \cdot 2}{z}}{y - t}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity8.7

      \[\leadsto \frac{\frac{x \cdot 2}{z}}{\color{blue}{1 \cdot \left(y - t\right)}}\]
    7. Applied *-un-lft-identity8.7

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

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

      \[\leadsto \color{blue}{\frac{\frac{x}{1}}{1} \cdot \frac{\frac{2}{z}}{y - t}}\]
    10. Simplified2.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -6.3098383512066379 \cdot 10^{121} \lor \neg \left(z \le 8624013021746182490000\right):\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{\frac{2}{z}}{y - t}\\ \end{array}\]

Reproduce

herbie shell --seed 2020043 +o rules:numerics
(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))))