Average Error: 6.9 → 1.2
Time: 39.6s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \cdot y - t \cdot z = -\infty:\\ \;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\ \mathbf{elif}\;z \cdot y - t \cdot z \le 3.15544594796386898663194447832483562784 \cdot 10^{297}:\\ \;\;\;\;\frac{2 \cdot x}{z \cdot y - 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}\;z \cdot y - t \cdot z = -\infty:\\
\;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\

\mathbf{elif}\;z \cdot y - t \cdot z \le 3.15544594796386898663194447832483562784 \cdot 10^{297}:\\
\;\;\;\;\frac{2 \cdot x}{z \cdot y - 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 r24774531 = x;
        double r24774532 = 2.0;
        double r24774533 = r24774531 * r24774532;
        double r24774534 = y;
        double r24774535 = z;
        double r24774536 = r24774534 * r24774535;
        double r24774537 = t;
        double r24774538 = r24774537 * r24774535;
        double r24774539 = r24774536 - r24774538;
        double r24774540 = r24774533 / r24774539;
        return r24774540;
}

double f(double x, double y, double z, double t) {
        double r24774541 = z;
        double r24774542 = y;
        double r24774543 = r24774541 * r24774542;
        double r24774544 = t;
        double r24774545 = r24774544 * r24774541;
        double r24774546 = r24774543 - r24774545;
        double r24774547 = -inf.0;
        bool r24774548 = r24774546 <= r24774547;
        double r24774549 = x;
        double r24774550 = r24774549 / r24774541;
        double r24774551 = 2.0;
        double r24774552 = r24774542 - r24774544;
        double r24774553 = r24774551 / r24774552;
        double r24774554 = r24774550 * r24774553;
        double r24774555 = 3.155445947963869e+297;
        bool r24774556 = r24774546 <= r24774555;
        double r24774557 = r24774551 * r24774549;
        double r24774558 = r24774557 / r24774546;
        double r24774559 = r24774556 ? r24774558 : r24774554;
        double r24774560 = r24774548 ? r24774554 : r24774559;
        return r24774560;
}

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.9
Target2.1
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 2 regimes
  2. if (- (* y z) (* t z)) < -inf.0 or 3.155445947963869e+297 < (- (* y z) (* t z))

    1. Initial program 24.5

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

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

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

    if -inf.0 < (- (* y z) (* t z)) < 3.155445947963869e+297

    1. Initial program 1.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot y - t \cdot z = -\infty:\\ \;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\ \mathbf{elif}\;z \cdot y - t \cdot z \le 3.15544594796386898663194447832483562784 \cdot 10^{297}:\\ \;\;\;\;\frac{2 \cdot x}{z \cdot y - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} \cdot \frac{2}{y - t}\\ \end{array}\]

Reproduce

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