Average Error: 6.6 → 1.2
Time: 14.7s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -1.220893446978389593521798659780257639163 \cdot 10^{273}:\\ \;\;\;\;\frac{\frac{2}{\frac{z}{x}}}{y - t}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 4.552142341779211339600179624511961051271 \cdot 10^{196}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \cdot z - t \cdot z \le -1.220893446978389593521798659780257639163 \cdot 10^{273}:\\
\;\;\;\;\frac{\frac{2}{\frac{z}{x}}}{y - t}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r28341215 = x;
        double r28341216 = 2.0;
        double r28341217 = r28341215 * r28341216;
        double r28341218 = y;
        double r28341219 = z;
        double r28341220 = r28341218 * r28341219;
        double r28341221 = t;
        double r28341222 = r28341221 * r28341219;
        double r28341223 = r28341220 - r28341222;
        double r28341224 = r28341217 / r28341223;
        return r28341224;
}

double f(double x, double y, double z, double t) {
        double r28341225 = y;
        double r28341226 = z;
        double r28341227 = r28341225 * r28341226;
        double r28341228 = t;
        double r28341229 = r28341228 * r28341226;
        double r28341230 = r28341227 - r28341229;
        double r28341231 = -1.2208934469783896e+273;
        bool r28341232 = r28341230 <= r28341231;
        double r28341233 = 2.0;
        double r28341234 = x;
        double r28341235 = r28341226 / r28341234;
        double r28341236 = r28341233 / r28341235;
        double r28341237 = r28341225 - r28341228;
        double r28341238 = r28341236 / r28341237;
        double r28341239 = 4.552142341779211e+196;
        bool r28341240 = r28341230 <= r28341239;
        double r28341241 = r28341234 * r28341233;
        double r28341242 = r28341241 / r28341230;
        double r28341243 = r28341234 / r28341226;
        double r28341244 = r28341233 / r28341237;
        double r28341245 = r28341243 * r28341244;
        double r28341246 = r28341240 ? r28341242 : r28341245;
        double r28341247 = r28341232 ? r28341238 : r28341246;
        return r28341247;
}

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.6
Target2.0
Herbie1.2
\[\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 3 regimes
  2. if (- (* y z) (* t z)) < -1.2208934469783896e+273

    1. Initial program 16.8

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

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

    if -1.2208934469783896e+273 < (- (* y z) (* t z)) < 4.552142341779211e+196

    1. Initial program 1.5

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

    if 4.552142341779211e+196 < (- (* y z) (* t z))

    1. Initial program 17.2

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. Using strategy rm
    3. Applied distribute-rgt-out--11.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -1.220893446978389593521798659780257639163 \cdot 10^{273}:\\ \;\;\;\;\frac{\frac{2}{\frac{z}{x}}}{y - t}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 4.552142341779211339600179624511961051271 \cdot 10^{196}:\\ \;\;\;\;\frac{x \cdot 2}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\ \end{array}\]

Reproduce

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