Average Error: 6.8 → 3.5
Time: 15.3s
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 r19614975 = x;
        double r19614976 = 2.0;
        double r19614977 = r19614975 * r19614976;
        double r19614978 = y;
        double r19614979 = z;
        double r19614980 = r19614978 * r19614979;
        double r19614981 = t;
        double r19614982 = r19614981 * r19614979;
        double r19614983 = r19614980 - r19614982;
        double r19614984 = r19614977 / r19614983;
        return r19614984;
}

double f(double x, double y, double z, double t) {
        double r19614985 = x;
        double r19614986 = -4.0563845529555984e+88;
        bool r19614987 = r19614985 <= r19614986;
        double r19614988 = 2.0;
        double r19614989 = z;
        double r19614990 = r19614988 / r19614989;
        double r19614991 = 1.0;
        double r19614992 = y;
        double r19614993 = t;
        double r19614994 = r19614992 - r19614993;
        double r19614995 = r19614991 / r19614994;
        double r19614996 = r19614985 * r19614995;
        double r19614997 = r19614990 * r19614996;
        double r19614998 = 3.2887742902305866e-245;
        bool r19614999 = r19614985 <= r19614998;
        double r19615000 = r19614985 / r19614989;
        double r19615001 = r19615000 * r19614988;
        double r19615002 = r19615001 / r19614994;
        double r19615003 = r19614999 ? r19615002 : r19614997;
        double r19615004 = r19614987 ? r19614997 : r19615003;
        return r19615004;
}

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))))