Average Error: 6.8 → 3.0
Time: 12.0s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot 2 \le -7.239284083966433340971141087068091802766 \cdot 10^{62} \lor \neg \left(x \cdot 2 \le 3.757552955654937149870253387206513889626 \cdot 10^{-155}\right):\\ \;\;\;\;\frac{\frac{2 \cdot x}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\left(y - t\right) \cdot z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \cdot 2 \le -7.239284083966433340971141087068091802766 \cdot 10^{62} \lor \neg \left(x \cdot 2 \le 3.757552955654937149870253387206513889626 \cdot 10^{-155}\right):\\
\;\;\;\;\frac{\frac{2 \cdot x}{y - t}}{z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r299439 = x;
        double r299440 = 2.0;
        double r299441 = r299439 * r299440;
        double r299442 = y;
        double r299443 = z;
        double r299444 = r299442 * r299443;
        double r299445 = t;
        double r299446 = r299445 * r299443;
        double r299447 = r299444 - r299446;
        double r299448 = r299441 / r299447;
        return r299448;
}

double f(double x, double y, double z, double t) {
        double r299449 = x;
        double r299450 = 2.0;
        double r299451 = r299449 * r299450;
        double r299452 = -7.239284083966433e+62;
        bool r299453 = r299451 <= r299452;
        double r299454 = 3.757552955654937e-155;
        bool r299455 = r299451 <= r299454;
        double r299456 = !r299455;
        bool r299457 = r299453 || r299456;
        double r299458 = r299450 * r299449;
        double r299459 = y;
        double r299460 = t;
        double r299461 = r299459 - r299460;
        double r299462 = r299458 / r299461;
        double r299463 = z;
        double r299464 = r299462 / r299463;
        double r299465 = r299461 * r299463;
        double r299466 = r299451 / r299465;
        double r299467 = r299457 ? r299464 : r299466;
        return r299467;
}

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.1
Herbie3.0
\[\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 (* x 2.0) < -7.239284083966433e+62 or 3.757552955654937e-155 < (* x 2.0)

    1. Initial program 9.3

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

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

      \[\leadsto \color{blue}{\frac{\frac{x \cdot 2}{z}}{y - t}}\]
    5. Using strategy rm
    6. Applied clear-num9.5

      \[\leadsto \color{blue}{\frac{1}{\frac{y - t}{\frac{x \cdot 2}{z}}}}\]
    7. Using strategy rm
    8. Applied associate-/r/3.9

      \[\leadsto \frac{1}{\color{blue}{\frac{y - t}{x \cdot 2} \cdot z}}\]
    9. Applied associate-/r*3.8

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

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

    if -7.239284083966433e+62 < (* x 2.0) < 3.757552955654937e-155

    1. Initial program 3.9

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

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

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

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

Reproduce

herbie shell --seed 2019325 +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))))