Average Error: 6.8 → 2.2
Time: 4.3s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.95442192702372847 \cdot 10^{61}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{elif}\;z \le 4.6738271756222066 \cdot 10^{62}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{1}}{1} \cdot \frac{\frac{x}{\frac{y - t}{2}}}{z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -1.95442192702372847 \cdot 10^{61}:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\

\mathbf{elif}\;z \le 4.6738271756222066 \cdot 10^{62}:\\
\;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r758414 = x;
        double r758415 = 2.0;
        double r758416 = r758414 * r758415;
        double r758417 = y;
        double r758418 = z;
        double r758419 = r758417 * r758418;
        double r758420 = t;
        double r758421 = r758420 * r758418;
        double r758422 = r758419 - r758421;
        double r758423 = r758416 / r758422;
        return r758423;
}

double f(double x, double y, double z, double t) {
        double r758424 = z;
        double r758425 = -1.9544219270237285e+61;
        bool r758426 = r758424 <= r758425;
        double r758427 = x;
        double r758428 = r758427 / r758424;
        double r758429 = y;
        double r758430 = t;
        double r758431 = r758429 - r758430;
        double r758432 = 2.0;
        double r758433 = r758431 / r758432;
        double r758434 = r758428 / r758433;
        double r758435 = 4.673827175622207e+62;
        bool r758436 = r758424 <= r758435;
        double r758437 = r758424 * r758431;
        double r758438 = r758437 / r758432;
        double r758439 = r758427 / r758438;
        double r758440 = 1.0;
        double r758441 = sqrt(r758440);
        double r758442 = r758441 / r758440;
        double r758443 = r758427 / r758433;
        double r758444 = r758443 / r758424;
        double r758445 = r758442 * r758444;
        double r758446 = r758436 ? r758439 : r758445;
        double r758447 = r758426 ? r758434 : r758446;
        return r758447;
}

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.0
Herbie2.2
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2}{y \cdot z - t \cdot z} \lt -2.559141628295061 \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.04502782733012586 \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 z < -1.9544219270237285e+61

    1. Initial program 12.7

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity9.8

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

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

      \[\leadsto \color{blue}{\frac{\frac{x}{\frac{z}{1}}}{\frac{y - t}{2}}}\]
    7. Simplified2.1

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

    if -1.9544219270237285e+61 < z < 4.673827175622207e+62

    1. Initial program 2.2

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

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

    if 4.673827175622207e+62 < z

    1. Initial program 12.7

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{y - t}{2}}}\]
    6. Applied *-un-lft-identity10.3

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{\frac{z}{1} \cdot \frac{y - t}{2}}\]
    7. Applied times-frac2.3

      \[\leadsto \color{blue}{\frac{1}{\frac{z}{1}} \cdot \frac{x}{\frac{y - t}{2}}}\]
    8. Simplified2.3

      \[\leadsto \color{blue}{\frac{1}{z}} \cdot \frac{x}{\frac{y - t}{2}}\]
    9. Using strategy rm
    10. Applied *-un-lft-identity2.3

      \[\leadsto \frac{1}{\color{blue}{1 \cdot z}} \cdot \frac{x}{\frac{y - t}{2}}\]
    11. Applied add-sqr-sqrt2.3

      \[\leadsto \frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{1 \cdot z} \cdot \frac{x}{\frac{y - t}{2}}\]
    12. Applied times-frac2.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.95442192702372847 \cdot 10^{61}:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{elif}\;z \le 4.6738271756222066 \cdot 10^{62}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{1}}{1} \cdot \frac{\frac{x}{\frac{y - t}{2}}}{z}\\ \end{array}\]

Reproduce

herbie shell --seed 2020057 
(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.0450278273301259e-269) (/ (* (/ x z) 2) (- y t)) (* (/ x (* (- y t) z)) 2)))

  (/ (* x 2) (- (* y z) (* t z))))