Average Error: 6.9 → 2.8
Time: 4.0s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.6539304554457753 \cdot 10^{33}:\\ \;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\ \mathbf{elif}\;z \le 1.79162799052716663 \cdot 10^{-139}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{\frac{z}{2}}}{y - t}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -1.6539304554457753 \cdot 10^{33}:\\
\;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r515568 = x;
        double r515569 = 2.0;
        double r515570 = r515568 * r515569;
        double r515571 = y;
        double r515572 = z;
        double r515573 = r515571 * r515572;
        double r515574 = t;
        double r515575 = r515574 * r515572;
        double r515576 = r515573 - r515575;
        double r515577 = r515570 / r515576;
        return r515577;
}

double f(double x, double y, double z, double t) {
        double r515578 = z;
        double r515579 = -1.6539304554457753e+33;
        bool r515580 = r515578 <= r515579;
        double r515581 = x;
        double r515582 = 2.0;
        double r515583 = y;
        double r515584 = t;
        double r515585 = r515583 - r515584;
        double r515586 = r515582 / r515585;
        double r515587 = r515581 * r515586;
        double r515588 = r515587 / r515578;
        double r515589 = 1.7916279905271666e-139;
        bool r515590 = r515578 <= r515589;
        double r515591 = r515578 * r515585;
        double r515592 = r515591 / r515582;
        double r515593 = r515581 / r515592;
        double r515594 = r515578 / r515582;
        double r515595 = r515581 / r515594;
        double r515596 = r515595 / r515585;
        double r515597 = r515590 ? r515593 : r515596;
        double r515598 = r515580 ? r515588 : r515597;
        return r515598;
}

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.2
Herbie2.8
\[\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.6539304554457753e+33

    1. Initial program 11.6

      \[\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 div-inv9.8

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

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

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

    if -1.6539304554457753e+33 < z < 1.7916279905271666e-139

    1. Initial program 2.8

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

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

    if 1.7916279905271666e-139 < z

    1. Initial program 7.7

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{\frac{2}{y - t}}}}\]
    10. Using strategy rm
    11. Applied associate-/r/6.1

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{2} \cdot \left(y - t\right)}}\]
    12. Applied associate-/r*2.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.6539304554457753 \cdot 10^{33}:\\ \;\;\;\;\frac{x \cdot \frac{2}{y - t}}{z}\\ \mathbf{elif}\;z \le 1.79162799052716663 \cdot 10^{-139}:\\ \;\;\;\;\frac{x}{\frac{z \cdot \left(y - t\right)}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{\frac{z}{2}}}{y - t}\\ \end{array}\]

Reproduce

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