Average Error: 6.8 → 3.0
Time: 9.4s
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{x \cdot 2}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \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{x \cdot 2}{y - t}}{z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r342856 = x;
        double r342857 = 2.0;
        double r342858 = r342856 * r342857;
        double r342859 = y;
        double r342860 = z;
        double r342861 = r342859 * r342860;
        double r342862 = t;
        double r342863 = r342862 * r342860;
        double r342864 = r342861 - r342863;
        double r342865 = r342858 / r342864;
        return r342865;
}

double f(double x, double y, double z, double t) {
        double r342866 = x;
        double r342867 = 2.0;
        double r342868 = r342866 * r342867;
        double r342869 = -7.239284083966433e+62;
        bool r342870 = r342868 <= r342869;
        double r342871 = 3.757552955654937e-155;
        bool r342872 = r342868 <= r342871;
        double r342873 = !r342872;
        bool r342874 = r342870 || r342873;
        double r342875 = y;
        double r342876 = t;
        double r342877 = r342875 - r342876;
        double r342878 = r342868 / r342877;
        double r342879 = z;
        double r342880 = r342878 / r342879;
        double r342881 = r342879 * r342877;
        double r342882 = r342868 / r342881;
        double r342883 = r342874 ? r342880 : r342882;
        return r342883;
}

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 div-inv9.2

      \[\leadsto \color{blue}{\frac{x \cdot 2}{z} \cdot \frac{1}{y - t}}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity9.2

      \[\leadsto \color{blue}{\left(1 \cdot \frac{x \cdot 2}{z}\right)} \cdot \frac{1}{y - t}\]
    9. Applied associate-*l*9.2

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

      \[\leadsto 1 \cdot \color{blue}{\frac{\frac{x \cdot 2}{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 associate-/r*2.5

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{z} \cdot \frac{1}{y - t}}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity2.5

      \[\leadsto \color{blue}{\left(1 \cdot \frac{x \cdot 2}{z}\right)} \cdot \frac{1}{y - t}\]
    9. Applied associate-*l*2.5

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

      \[\leadsto 1 \cdot \color{blue}{\frac{\frac{x \cdot 2}{y - t}}{z}}\]
    11. Using strategy rm
    12. Applied div-inv7.4

      \[\leadsto 1 \cdot \frac{\color{blue}{\left(x \cdot 2\right) \cdot \frac{1}{y - t}}}{z}\]
    13. Applied associate-/l*2.3

      \[\leadsto 1 \cdot \color{blue}{\frac{x \cdot 2}{\frac{z}{\frac{1}{y - t}}}}\]
    14. Simplified2.3

      \[\leadsto 1 \cdot \frac{x \cdot 2}{\color{blue}{z \cdot \left(y - t\right)}}\]
  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{x \cdot 2}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\ \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))))