Average Error: 6.7 → 2.9
Time: 11.7s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.021762082410781549036184893167115988887 \cdot 10^{147} \lor \neg \left(z \le 2.635494250498725666564973693616699303691 \cdot 10^{-102}\right):\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot y + \left(-t \cdot z\right)}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -3.021762082410781549036184893167115988887 \cdot 10^{147} \lor \neg \left(z \le 2.635494250498725666564973693616699303691 \cdot 10^{-102}\right):\\
\;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r293621 = x;
        double r293622 = 2.0;
        double r293623 = r293621 * r293622;
        double r293624 = y;
        double r293625 = z;
        double r293626 = r293624 * r293625;
        double r293627 = t;
        double r293628 = r293627 * r293625;
        double r293629 = r293626 - r293628;
        double r293630 = r293623 / r293629;
        return r293630;
}

double f(double x, double y, double z, double t) {
        double r293631 = z;
        double r293632 = -3.0217620824107815e+147;
        bool r293633 = r293631 <= r293632;
        double r293634 = 2.6354942504987257e-102;
        bool r293635 = r293631 <= r293634;
        double r293636 = !r293635;
        bool r293637 = r293633 || r293636;
        double r293638 = x;
        double r293639 = 2.0;
        double r293640 = r293638 * r293639;
        double r293641 = r293640 / r293631;
        double r293642 = y;
        double r293643 = t;
        double r293644 = r293642 - r293643;
        double r293645 = r293641 / r293644;
        double r293646 = r293631 * r293642;
        double r293647 = r293643 * r293631;
        double r293648 = -r293647;
        double r293649 = r293646 + r293648;
        double r293650 = r293640 / r293649;
        double r293651 = r293637 ? r293645 : r293650;
        return r293651;
}

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.7
Target2.0
Herbie2.9
\[\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 < -3.0217620824107815e+147 or 2.6354942504987257e-102 < z

    1. Initial program 10.2

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

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

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

    if -3.0217620824107815e+147 < z < 2.6354942504987257e-102

    1. Initial program 3.3

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

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

      \[\leadsto \frac{x \cdot 2}{z \cdot \color{blue}{\left(y + \left(-t\right)\right)}}\]
    5. Applied distribute-lft-in3.3

      \[\leadsto \frac{x \cdot 2}{\color{blue}{z \cdot y + z \cdot \left(-t\right)}}\]
    6. Simplified3.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.021762082410781549036184893167115988887 \cdot 10^{147} \lor \neg \left(z \le 2.635494250498725666564973693616699303691 \cdot 10^{-102}\right):\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot y + \left(-t \cdot z\right)}\\ \end{array}\]

Reproduce

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