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

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r24263177 = x;
        double r24263178 = 2.0;
        double r24263179 = r24263177 * r24263178;
        double r24263180 = y;
        double r24263181 = z;
        double r24263182 = r24263180 * r24263181;
        double r24263183 = t;
        double r24263184 = r24263183 * r24263181;
        double r24263185 = r24263182 - r24263184;
        double r24263186 = r24263179 / r24263185;
        return r24263186;
}

double f(double x, double y, double z, double t) {
        double r24263187 = x;
        double r24263188 = -4.0563845529555984e+88;
        bool r24263189 = r24263187 <= r24263188;
        double r24263190 = 2.0;
        double r24263191 = r24263190 * r24263187;
        double r24263192 = y;
        double r24263193 = t;
        double r24263194 = r24263192 - r24263193;
        double r24263195 = r24263191 / r24263194;
        double r24263196 = z;
        double r24263197 = r24263195 / r24263196;
        double r24263198 = 3.2887742902305866e-245;
        bool r24263199 = r24263187 <= r24263198;
        double r24263200 = r24263187 / r24263196;
        double r24263201 = r24263190 * r24263200;
        double r24263202 = r24263201 / r24263194;
        double r24263203 = r24263199 ? r24263202 : r24263197;
        double r24263204 = r24263189 ? r24263197 : r24263203;
        return r24263204;
}

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 associate-*l/4.3

      \[\leadsto \frac{\color{blue}{\frac{2 \cdot 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{\frac{2 \cdot x}{y - t}}{z}\\ \mathbf{elif}\;x \le 3.288774290230586596963631347037002842634 \cdot 10^{-245}:\\ \;\;\;\;\frac{2 \cdot \frac{x}{z}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2 \cdot 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))))