Average Error: 6.8 → 3.0
Time: 10.6s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot 2 \le -7.239284083966433340971141087068091802766 \cdot 10^{62} \lor \neg \left(x \cdot 2 \le 3.757552955654937149870253387206513889626 \cdot 10^{-155}\right):\\ \;\;\;\;\frac{\frac{2 \cdot x}{y - t}}{z}\\ \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}\;x \cdot 2 \le -7.239284083966433340971141087068091802766 \cdot 10^{62} \lor \neg \left(x \cdot 2 \le 3.757552955654937149870253387206513889626 \cdot 10^{-155}\right):\\
\;\;\;\;\frac{\frac{2 \cdot x}{y - t}}{z}\\

\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 r394085 = x;
        double r394086 = 2.0;
        double r394087 = r394085 * r394086;
        double r394088 = y;
        double r394089 = z;
        double r394090 = r394088 * r394089;
        double r394091 = t;
        double r394092 = r394091 * r394089;
        double r394093 = r394090 - r394092;
        double r394094 = r394087 / r394093;
        return r394094;
}

double f(double x, double y, double z, double t) {
        double r394095 = x;
        double r394096 = 2.0;
        double r394097 = r394095 * r394096;
        double r394098 = -7.239284083966433e+62;
        bool r394099 = r394097 <= r394098;
        double r394100 = 3.757552955654937e-155;
        bool r394101 = r394097 <= r394100;
        double r394102 = !r394101;
        bool r394103 = r394099 || r394102;
        double r394104 = r394096 * r394095;
        double r394105 = y;
        double r394106 = t;
        double r394107 = r394105 - r394106;
        double r394108 = r394104 / r394107;
        double r394109 = z;
        double r394110 = r394108 / r394109;
        double r394111 = r394109 * r394107;
        double r394112 = r394097 / r394111;
        double r394113 = r394103 ? r394110 : r394112;
        return r394113;
}

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.0
\[\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 2.0) < -7.239284083966433e+62 or 3.757552955654937e-155 < (* x 2.0)

    1. Initial program 9.3

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

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

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

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

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

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

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

    if -7.239284083966433e+62 < (* x 2.0) < 3.757552955654937e-155

    1. Initial program 3.9

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

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

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

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

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

Reproduce

herbie shell --seed 2019325 
(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))))