Average Error: 6.8 → 3.4
Time: 13.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 \cdot \frac{x}{y - t}}{z}\\ \mathbf{elif}\;x \le 3.288774290230586596963631347037002842634 \cdot 10^{-245}:\\ \;\;\;\;\frac{2 \cdot \frac{x}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \frac{x}{y - t}}{z}\\ \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 \cdot \frac{x}{y - t}}{z}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot \frac{x}{y - t}}{z}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r28120140 = x;
        double r28120141 = 2.0;
        double r28120142 = r28120140 * r28120141;
        double r28120143 = y;
        double r28120144 = z;
        double r28120145 = r28120143 * r28120144;
        double r28120146 = t;
        double r28120147 = r28120146 * r28120144;
        double r28120148 = r28120145 - r28120147;
        double r28120149 = r28120142 / r28120148;
        return r28120149;
}

double f(double x, double y, double z, double t) {
        double r28120150 = x;
        double r28120151 = -4.0563845529555984e+88;
        bool r28120152 = r28120150 <= r28120151;
        double r28120153 = 2.0;
        double r28120154 = y;
        double r28120155 = t;
        double r28120156 = r28120154 - r28120155;
        double r28120157 = r28120150 / r28120156;
        double r28120158 = r28120153 * r28120157;
        double r28120159 = z;
        double r28120160 = r28120158 / r28120159;
        double r28120161 = 3.2887742902305866e-245;
        bool r28120162 = r28120150 <= r28120161;
        double r28120163 = r28120150 / r28120159;
        double r28120164 = r28120153 * r28120163;
        double r28120165 = r28120164 / r28120156;
        double r28120166 = r28120162 ? r28120165 : r28120160;
        double r28120167 = r28120152 ? r28120160 : r28120166;
        return r28120167;
}

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.4
\[\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.1

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

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

      \[\leadsto \frac{\color{blue}{\left(2 \cdot \frac{1}{y - t}\right)} \cdot x}{z}\]
    7. Applied associate-*l*4.3

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

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

    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.1

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

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

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

Reproduce

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