Average Error: 6.8 → 2.7
Time: 6.0s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot 2 \le -6.40896485227227125 \cdot 10^{-57} \lor \neg \left(x \cdot 2 \le 1.0146296550947617 \cdot 10^{-158}\right):\\ \;\;\;\;\frac{\frac{x}{y - t}}{\frac{z}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot \frac{z}{2}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \cdot 2 \le -6.40896485227227125 \cdot 10^{-57} \lor \neg \left(x \cdot 2 \le 1.0146296550947617 \cdot 10^{-158}\right):\\
\;\;\;\;\frac{\frac{x}{y - t}}{\frac{z}{2}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r469447 = x;
        double r469448 = 2.0;
        double r469449 = r469447 * r469448;
        double r469450 = y;
        double r469451 = z;
        double r469452 = r469450 * r469451;
        double r469453 = t;
        double r469454 = r469453 * r469451;
        double r469455 = r469452 - r469454;
        double r469456 = r469449 / r469455;
        return r469456;
}

double f(double x, double y, double z, double t) {
        double r469457 = x;
        double r469458 = 2.0;
        double r469459 = r469457 * r469458;
        double r469460 = -6.408964852272271e-57;
        bool r469461 = r469459 <= r469460;
        double r469462 = 1.0146296550947617e-158;
        bool r469463 = r469459 <= r469462;
        double r469464 = !r469463;
        bool r469465 = r469461 || r469464;
        double r469466 = y;
        double r469467 = t;
        double r469468 = r469466 - r469467;
        double r469469 = r469457 / r469468;
        double r469470 = z;
        double r469471 = r469470 / r469458;
        double r469472 = r469469 / r469471;
        double r469473 = r469468 * r469471;
        double r469474 = r469457 / r469473;
        double r469475 = r469465 ? r469472 : r469474;
        return r469475;
}

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.0
Herbie2.7
\[\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 (* x 2.0) < -6.408964852272271e-57 or 1.0146296550947617e-158 < (* x 2.0)

    1. Initial program 8.6

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}}\]
    5. Simplified7.7

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

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

    if -6.408964852272271e-57 < (* x 2.0) < 1.0146296550947617e-158

    1. Initial program 3.4

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

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

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

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

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

Reproduce

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