Average Error: 6.6 → 2.3
Time: 10.2s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -6.609155278402763732806859387072657101859 \cdot 10^{88} \lor \neg \left(z \le 3.754300225841495466963599715283041562844 \cdot 10^{-51}\right):\\ \;\;\;\;\frac{\frac{2 \cdot x}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot y - t \cdot z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -6.609155278402763732806859387072657101859 \cdot 10^{88} \lor \neg \left(z \le 3.754300225841495466963599715283041562844 \cdot 10^{-51}\right):\\
\;\;\;\;\frac{\frac{2 \cdot x}{z}}{y - t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r282399 = x;
        double r282400 = 2.0;
        double r282401 = r282399 * r282400;
        double r282402 = y;
        double r282403 = z;
        double r282404 = r282402 * r282403;
        double r282405 = t;
        double r282406 = r282405 * r282403;
        double r282407 = r282404 - r282406;
        double r282408 = r282401 / r282407;
        return r282408;
}

double f(double x, double y, double z, double t) {
        double r282409 = z;
        double r282410 = -6.609155278402764e+88;
        bool r282411 = r282409 <= r282410;
        double r282412 = 3.7543002258414955e-51;
        bool r282413 = r282409 <= r282412;
        double r282414 = !r282413;
        bool r282415 = r282411 || r282414;
        double r282416 = 2.0;
        double r282417 = x;
        double r282418 = r282416 * r282417;
        double r282419 = r282418 / r282409;
        double r282420 = y;
        double r282421 = t;
        double r282422 = r282420 - r282421;
        double r282423 = r282419 / r282422;
        double r282424 = r282417 * r282416;
        double r282425 = r282409 * r282420;
        double r282426 = r282421 * r282409;
        double r282427 = r282425 - r282426;
        double r282428 = r282424 / r282427;
        double r282429 = r282415 ? r282423 : r282428;
        return r282429;
}

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.1
Herbie2.3
\[\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 2 regimes
  2. if z < -6.609155278402764e+88 or 3.7543002258414955e-51 < z

    1. Initial program 10.2

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

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

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

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

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

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

    if -6.609155278402764e+88 < z < 3.7543002258414955e-51

    1. Initial program 2.8

      \[\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. Taylor expanded around 0 2.8

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

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

Reproduce

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

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