Average Error: 7.0 → 1.1
Time: 13.2s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -5.966470809942352604280748168933341651291 \cdot 10^{-251} \lor \neg \left(\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -0.0\right) \land \frac{x \cdot 2}{y \cdot z - t \cdot z} \le 7.820034338024703644392920985462361112803 \cdot 10^{269}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{\frac{z}{2}}}{y - t}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -5.966470809942352604280748168933341651291 \cdot 10^{-251} \lor \neg \left(\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -0.0\right) \land \frac{x \cdot 2}{y \cdot z - t \cdot z} \le 7.820034338024703644392920985462361112803 \cdot 10^{269}:\\
\;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r399391 = x;
        double r399392 = 2.0;
        double r399393 = r399391 * r399392;
        double r399394 = y;
        double r399395 = z;
        double r399396 = r399394 * r399395;
        double r399397 = t;
        double r399398 = r399397 * r399395;
        double r399399 = r399396 - r399398;
        double r399400 = r399393 / r399399;
        return r399400;
}

double f(double x, double y, double z, double t) {
        double r399401 = x;
        double r399402 = 2.0;
        double r399403 = r399401 * r399402;
        double r399404 = y;
        double r399405 = z;
        double r399406 = r399404 * r399405;
        double r399407 = t;
        double r399408 = r399407 * r399405;
        double r399409 = r399406 - r399408;
        double r399410 = r399403 / r399409;
        double r399411 = -5.9664708099423526e-251;
        bool r399412 = r399410 <= r399411;
        double r399413 = -0.0;
        bool r399414 = r399410 <= r399413;
        double r399415 = !r399414;
        double r399416 = 7.820034338024704e+269;
        bool r399417 = r399410 <= r399416;
        bool r399418 = r399415 && r399417;
        bool r399419 = r399412 || r399418;
        double r399420 = r399405 / r399402;
        double r399421 = r399401 / r399420;
        double r399422 = r399404 - r399407;
        double r399423 = r399421 / r399422;
        double r399424 = r399419 ? r399410 : r399423;
        return r399424;
}

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

Original7.0
Target2.0
Herbie1.1
\[\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) (- (* y z) (* t z))) < -5.9664708099423526e-251 or -0.0 < (/ (* x 2.0) (- (* y z) (* t z))) < 7.820034338024704e+269

    1. Initial program 1.0

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

    if -5.9664708099423526e-251 < (/ (* x 2.0) (- (* y z) (* t z))) < -0.0 or 7.820034338024704e+269 < (/ (* x 2.0) (- (* y z) (* t z)))

    1. Initial program 16.4

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. Using strategy rm
    3. Applied distribute-rgt-out--13.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -5.966470809942352604280748168933341651291 \cdot 10^{-251} \lor \neg \left(\frac{x \cdot 2}{y \cdot z - t \cdot z} \le -0.0\right) \land \frac{x \cdot 2}{y \cdot z - t \cdot z} \le 7.820034338024703644392920985462361112803 \cdot 10^{269}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{\frac{z}{2}}}{y - t}\\ \end{array}\]

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(FPCore (x y z t)
  :name "Linear.Projection:infinitePerspective from linear-1.19.1.3, A"

  :herbie-target
  (if (< (/ (* x 2.0) (- (* y z) (* t z))) -2.559141628295061e-13) (* (/ x (* (- y t) z)) 2.0) (if (< (/ (* x 2.0) (- (* y z) (* t z))) 1.045027827330126e-269) (/ (* (/ x z) 2.0) (- y t)) (* (/ x (* (- y t) z)) 2.0)))

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