Average Error: 7.1 → 0.4
Time: 38.6s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z = -\infty \lor \neg \left(y \cdot z - t \cdot z \le -1.1621051041344287 \cdot 10^{-259} \lor \neg \left(y \cdot z - t \cdot z \le 5.0899252137800039 \cdot 10^{-179} \lor \neg \left(y \cdot z - t \cdot z \le 1.7881153538091119 \cdot 10^{170}\right)\right)\right):\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \cdot z - t \cdot z = -\infty \lor \neg \left(y \cdot z - t \cdot z \le -1.1621051041344287 \cdot 10^{-259} \lor \neg \left(y \cdot z - t \cdot z \le 5.0899252137800039 \cdot 10^{-179} \lor \neg \left(y \cdot z - t \cdot z \le 1.7881153538091119 \cdot 10^{170}\right)\right)\right):\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r640502 = x;
        double r640503 = 2.0;
        double r640504 = r640502 * r640503;
        double r640505 = y;
        double r640506 = z;
        double r640507 = r640505 * r640506;
        double r640508 = t;
        double r640509 = r640508 * r640506;
        double r640510 = r640507 - r640509;
        double r640511 = r640504 / r640510;
        return r640511;
}

double f(double x, double y, double z, double t) {
        double r640512 = y;
        double r640513 = z;
        double r640514 = r640512 * r640513;
        double r640515 = t;
        double r640516 = r640515 * r640513;
        double r640517 = r640514 - r640516;
        double r640518 = -inf.0;
        bool r640519 = r640517 <= r640518;
        double r640520 = -1.1621051041344287e-259;
        bool r640521 = r640517 <= r640520;
        double r640522 = 5.089925213780004e-179;
        bool r640523 = r640517 <= r640522;
        double r640524 = 1.788115353809112e+170;
        bool r640525 = r640517 <= r640524;
        double r640526 = !r640525;
        bool r640527 = r640523 || r640526;
        double r640528 = !r640527;
        bool r640529 = r640521 || r640528;
        double r640530 = !r640529;
        bool r640531 = r640519 || r640530;
        double r640532 = x;
        double r640533 = r640532 / r640513;
        double r640534 = r640512 - r640515;
        double r640535 = 2.0;
        double r640536 = r640534 / r640535;
        double r640537 = r640533 / r640536;
        double r640538 = r640532 * r640535;
        double r640539 = r640538 / r640517;
        double r640540 = r640531 ? r640537 : r640539;
        return r640540;
}

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.1
Target2.2
Herbie0.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 (- (* y z) (* t z)) < -inf.0 or -1.1621051041344287e-259 < (- (* y z) (* t z)) < 5.089925213780004e-179 or 1.788115353809112e+170 < (- (* y z) (* t z))

    1. Initial program 17.8

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{x}{\frac{z}{1}}}{\frac{y - t}{2}}}\]
    7. Simplified0.7

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

    if -inf.0 < (- (* y z) (* t z)) < -1.1621051041344287e-259 or 5.089925213780004e-179 < (- (* y z) (* t z)) < 1.788115353809112e+170

    1. Initial program 0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z = -\infty \lor \neg \left(y \cdot z - t \cdot z \le -1.1621051041344287 \cdot 10^{-259} \lor \neg \left(y \cdot z - t \cdot z \le 5.0899252137800039 \cdot 10^{-179} \lor \neg \left(y \cdot z - t \cdot z \le 1.7881153538091119 \cdot 10^{170}\right)\right)\right):\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \end{array}\]

Reproduce

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