Average Error: 7.1 → 2.4
Time: 14.0s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -4.00904334297314605 \cdot 10^{-54} \lor \neg \left(z \le 35899075.9933054224\right):\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \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}\;z \le -4.00904334297314605 \cdot 10^{-54} \lor \neg \left(z \le 35899075.9933054224\right):\\
\;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\

\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 r427897 = x;
        double r427898 = 2.0;
        double r427899 = r427897 * r427898;
        double r427900 = y;
        double r427901 = z;
        double r427902 = r427900 * r427901;
        double r427903 = t;
        double r427904 = r427903 * r427901;
        double r427905 = r427902 - r427904;
        double r427906 = r427899 / r427905;
        return r427906;
}

double f(double x, double y, double z, double t) {
        double r427907 = z;
        double r427908 = -4.009043342973146e-54;
        bool r427909 = r427907 <= r427908;
        double r427910 = 35899075.99330542;
        bool r427911 = r427907 <= r427910;
        double r427912 = !r427911;
        bool r427913 = r427909 || r427912;
        double r427914 = x;
        double r427915 = 2.0;
        double r427916 = r427914 * r427915;
        double r427917 = r427916 / r427907;
        double r427918 = y;
        double r427919 = t;
        double r427920 = r427918 - r427919;
        double r427921 = r427917 / r427920;
        double r427922 = r427907 * r427920;
        double r427923 = r427916 / r427922;
        double r427924 = r427913 ? r427921 : r427923;
        return r427924;
}

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
Herbie2.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.045027827330126 \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 < -4.009043342973146e-54 or 35899075.99330542 < z

    1. Initial program 10.3

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

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

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

    if -4.009043342973146e-54 < z < 35899075.99330542

    1. Initial program 2.8

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

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

      \[\leadsto \color{blue}{\left(x \cdot 2\right) \cdot \frac{1}{z \cdot \left(y - t\right)}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt3.1

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

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

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

      \[\leadsto \left(x \cdot 2\right) \cdot \left(\frac{1}{z} \cdot \color{blue}{\frac{1}{y - t}}\right)\]
    10. Using strategy rm
    11. Applied frac-times3.1

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

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

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

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

Reproduce

herbie shell --seed 2019199 +o rules:numerics
(FPCore (x y z t)
  :name "Linear.Projection:infinitePerspective from linear-1.19.1.3, A"

  :herbie-target
  (if (< (/ (* x 2.0) (- (* y z) (* t z))) -2.559141628295061e-13) (* (/ x (* (- y t) z)) 2.0) (if (< (/ (* x 2.0) (- (* y z) (* t z))) 1.045027827330126e-269) (/ (* (/ x z) 2.0) (- y t)) (* (/ x (* (- y t) z)) 2.0)))

  (/ (* x 2.0) (- (* y z) (* t z))))