Average Error: 6.8 → 2.8
Time: 3.1s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.51847795867609119 \cdot 10^{-57} \lor \neg \left(x \le 3.501200984228306 \cdot 10^{-154}\right):\\ \;\;\;\;1 \cdot \frac{x \cdot \frac{2}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \le -1.51847795867609119 \cdot 10^{-57} \lor \neg \left(x \le 3.501200984228306 \cdot 10^{-154}\right):\\
\;\;\;\;1 \cdot \frac{x \cdot \frac{2}{y - t}}{z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r504824 = x;
        double r504825 = 2.0;
        double r504826 = r504824 * r504825;
        double r504827 = y;
        double r504828 = z;
        double r504829 = r504827 * r504828;
        double r504830 = t;
        double r504831 = r504830 * r504828;
        double r504832 = r504829 - r504831;
        double r504833 = r504826 / r504832;
        return r504833;
}

double f(double x, double y, double z, double t) {
        double r504834 = x;
        double r504835 = -1.5184779586760912e-57;
        bool r504836 = r504834 <= r504835;
        double r504837 = 3.501200984228306e-154;
        bool r504838 = r504834 <= r504837;
        double r504839 = !r504838;
        bool r504840 = r504836 || r504839;
        double r504841 = 1.0;
        double r504842 = 2.0;
        double r504843 = y;
        double r504844 = t;
        double r504845 = r504843 - r504844;
        double r504846 = r504842 / r504845;
        double r504847 = r504834 * r504846;
        double r504848 = z;
        double r504849 = r504847 / r504848;
        double r504850 = r504841 * r504849;
        double r504851 = r504848 * r504845;
        double r504852 = r504851 / r504842;
        double r504853 = r504834 / r504852;
        double r504854 = r504841 * r504853;
        double r504855 = r504840 ? r504850 : r504854;
        return r504855;
}

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.8
\[\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 < -1.5184779586760912e-57 or 3.501200984228306e-154 < x

    1. Initial program 8.6

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

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

      \[\leadsto \frac{x}{\color{blue}{1 \cdot \frac{z \cdot \left(y - t\right)}{2}}}\]
    5. Applied *-un-lft-identity7.7

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

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

      \[\leadsto \color{blue}{1} \cdot \frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\]
    8. Using strategy rm
    9. Applied div-inv7.9

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

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

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

    if -1.5184779586760912e-57 < x < 3.501200984228306e-154

    1. Initial program 3.5

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

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

      \[\leadsto \frac{x}{\color{blue}{1 \cdot \frac{z \cdot \left(y - t\right)}{2}}}\]
    5. Applied *-un-lft-identity2.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.51847795867609119 \cdot 10^{-57} \lor \neg \left(x \le 3.501200984228306 \cdot 10^{-154}\right):\\ \;\;\;\;1 \cdot \frac{x \cdot \frac{2}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \frac{x}{\frac{z \cdot \left(y - t\right)}{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))))