Average Error: 6.8 → 3.5
Time: 15.7s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -4.056384552955598447356844013649481058099 \cdot 10^{88}:\\ \;\;\;\;\frac{2}{z} \cdot \left(x \cdot \frac{1}{y - t}\right)\\ \mathbf{elif}\;x \le 3.288774290230586596963631347037002842634 \cdot 10^{-245}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot 2}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{z} \cdot \left(x \cdot \frac{1}{y - t}\right)\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \le -4.056384552955598447356844013649481058099 \cdot 10^{88}:\\
\;\;\;\;\frac{2}{z} \cdot \left(x \cdot \frac{1}{y - t}\right)\\

\mathbf{elif}\;x \le 3.288774290230586596963631347037002842634 \cdot 10^{-245}:\\
\;\;\;\;\frac{\frac{x}{z} \cdot 2}{y - t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r22873887 = x;
        double r22873888 = 2.0;
        double r22873889 = r22873887 * r22873888;
        double r22873890 = y;
        double r22873891 = z;
        double r22873892 = r22873890 * r22873891;
        double r22873893 = t;
        double r22873894 = r22873893 * r22873891;
        double r22873895 = r22873892 - r22873894;
        double r22873896 = r22873889 / r22873895;
        return r22873896;
}

double f(double x, double y, double z, double t) {
        double r22873897 = x;
        double r22873898 = -4.0563845529555984e+88;
        bool r22873899 = r22873897 <= r22873898;
        double r22873900 = 2.0;
        double r22873901 = z;
        double r22873902 = r22873900 / r22873901;
        double r22873903 = 1.0;
        double r22873904 = y;
        double r22873905 = t;
        double r22873906 = r22873904 - r22873905;
        double r22873907 = r22873903 / r22873906;
        double r22873908 = r22873897 * r22873907;
        double r22873909 = r22873902 * r22873908;
        double r22873910 = 3.2887742902305866e-245;
        bool r22873911 = r22873897 <= r22873910;
        double r22873912 = r22873897 / r22873901;
        double r22873913 = r22873912 * r22873900;
        double r22873914 = r22873913 / r22873906;
        double r22873915 = r22873911 ? r22873914 : r22873909;
        double r22873916 = r22873899 ? r22873909 : r22873915;
        return r22873916;
}

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.5
\[\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 < -4.0563845529555984e+88 or 3.2887742902305866e-245 < x

    1. Initial program 8.9

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

      \[\leadsto \color{blue}{\frac{\frac{2}{\frac{z}{x}}}{y - t}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity8.2

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

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

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

      \[\leadsto \color{blue}{\frac{2}{z}} \cdot \frac{x}{y - t}\]
    8. Using strategy rm
    9. Applied div-inv4.4

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

    if -4.0563845529555984e+88 < x < 3.2887742902305866e-245

    1. Initial program 3.6

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

      \[\leadsto \color{blue}{\frac{\frac{2}{\frac{z}{x}}}{y - t}}\]
    3. Taylor expanded around 0 2.0

      \[\leadsto \frac{\color{blue}{2 \cdot \frac{x}{z}}}{y - t}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification3.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -4.056384552955598447356844013649481058099 \cdot 10^{88}:\\ \;\;\;\;\frac{2}{z} \cdot \left(x \cdot \frac{1}{y - t}\right)\\ \mathbf{elif}\;x \le 3.288774290230586596963631347037002842634 \cdot 10^{-245}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot 2}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{z} \cdot \left(x \cdot \frac{1}{y - t}\right)\\ \end{array}\]

Reproduce

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