Average Error: 6.9 → 2.5
Time: 41.6s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -9.64695992765113087623332530882491557503 \cdot 10^{91}:\\ \;\;\;\;\frac{\frac{2}{y - t} \cdot x}{z}\\ \mathbf{elif}\;x \le 1.412151503464593793070845111912715599368 \cdot 10^{-62}:\\ \;\;\;\;\frac{2 \cdot x}{z \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2}{y - t} \cdot x}{z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \le -9.64695992765113087623332530882491557503 \cdot 10^{91}:\\
\;\;\;\;\frac{\frac{2}{y - t} \cdot x}{z}\\

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

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

\end{array}
double f(double x, double y, double z, double t) {
        double r28366642 = x;
        double r28366643 = 2.0;
        double r28366644 = r28366642 * r28366643;
        double r28366645 = y;
        double r28366646 = z;
        double r28366647 = r28366645 * r28366646;
        double r28366648 = t;
        double r28366649 = r28366648 * r28366646;
        double r28366650 = r28366647 - r28366649;
        double r28366651 = r28366644 / r28366650;
        return r28366651;
}

double f(double x, double y, double z, double t) {
        double r28366652 = x;
        double r28366653 = -9.646959927651131e+91;
        bool r28366654 = r28366652 <= r28366653;
        double r28366655 = 2.0;
        double r28366656 = y;
        double r28366657 = t;
        double r28366658 = r28366656 - r28366657;
        double r28366659 = r28366655 / r28366658;
        double r28366660 = r28366659 * r28366652;
        double r28366661 = z;
        double r28366662 = r28366660 / r28366661;
        double r28366663 = 1.4121515034645938e-62;
        bool r28366664 = r28366652 <= r28366663;
        double r28366665 = r28366655 * r28366652;
        double r28366666 = r28366661 * r28366658;
        double r28366667 = r28366665 / r28366666;
        double r28366668 = r28366664 ? r28366667 : r28366662;
        double r28366669 = r28366654 ? r28366662 : r28366668;
        return r28366669;
}

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
Herbie2.5
\[\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 < -9.646959927651131e+91 or 1.4121515034645938e-62 < x

    1. Initial program 11.0

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

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

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

    if -9.646959927651131e+91 < x < 1.4121515034645938e-62

    1. Initial program 3.7

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \frac{2}{y - t}}{z}}\]
    5. Using strategy rm
    6. Applied div-inv7.7

      \[\leadsto \color{blue}{\left(x \cdot \frac{2}{y - t}\right) \cdot \frac{1}{z}}\]
    7. Using strategy rm
    8. Applied associate-*r/7.7

      \[\leadsto \color{blue}{\frac{x \cdot 2}{y - t}} \cdot \frac{1}{z}\]
    9. Applied frac-times2.4

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

      \[\leadsto \frac{\color{blue}{2 \cdot x}}{\left(y - t\right) \cdot z}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.5

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

Reproduce

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