Average Error: 6.9 → 1.3
Time: 9.6s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -9.273314603309376889681662019627055692394 \cdot 10^{266} \lor \neg \left(y \cdot z - t \cdot z \le 1.268801158713574240994335795238287543437 \cdot 10^{165}\right):\\ \;\;\;\;\frac{\frac{2 \cdot x}{y - t}}{z}\\ \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 \le -9.273314603309376889681662019627055692394 \cdot 10^{266} \lor \neg \left(y \cdot z - t \cdot z \le 1.268801158713574240994335795238287543437 \cdot 10^{165}\right):\\
\;\;\;\;\frac{\frac{2 \cdot x}{y - t}}{z}\\

\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 r445888 = x;
        double r445889 = 2.0;
        double r445890 = r445888 * r445889;
        double r445891 = y;
        double r445892 = z;
        double r445893 = r445891 * r445892;
        double r445894 = t;
        double r445895 = r445894 * r445892;
        double r445896 = r445893 - r445895;
        double r445897 = r445890 / r445896;
        return r445897;
}

double f(double x, double y, double z, double t) {
        double r445898 = y;
        double r445899 = z;
        double r445900 = r445898 * r445899;
        double r445901 = t;
        double r445902 = r445901 * r445899;
        double r445903 = r445900 - r445902;
        double r445904 = -9.273314603309377e+266;
        bool r445905 = r445903 <= r445904;
        double r445906 = 1.2688011587135742e+165;
        bool r445907 = r445903 <= r445906;
        double r445908 = !r445907;
        bool r445909 = r445905 || r445908;
        double r445910 = 2.0;
        double r445911 = x;
        double r445912 = r445910 * r445911;
        double r445913 = r445898 - r445901;
        double r445914 = r445912 / r445913;
        double r445915 = r445914 / r445899;
        double r445916 = r445911 * r445910;
        double r445917 = r445916 / r445903;
        double r445918 = r445909 ? r445915 : r445917;
        return r445918;
}

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.9
Target2.2
Herbie1.3
\[\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 (- (* y z) (* t z)) < -9.273314603309377e+266 or 1.2688011587135742e+165 < (- (* y z) (* t z))

    1. Initial program 16.3

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{y - t}{\frac{x \cdot 2}{z}}}}\]
    7. Using strategy rm
    8. Applied associate-/r/1.4

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

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

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

    if -9.273314603309377e+266 < (- (* y z) (* t z)) < 1.2688011587135742e+165

    1. Initial program 1.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -9.273314603309376889681662019627055692394 \cdot 10^{266} \lor \neg \left(y \cdot z - t \cdot z \le 1.268801158713574240994335795238287543437 \cdot 10^{165}\right):\\ \;\;\;\;\frac{\frac{2 \cdot x}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \end{array}\]

Reproduce

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