Average Error: 6.7 → 3.7
Time: 13.3s
Precision: 64
\[\frac{x \cdot 2.0}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -7.290611189347871 \cdot 10^{-40}:\\ \;\;\;\;\frac{\frac{2.0 \cdot x}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{2.0 \cdot x}{z \cdot \left(y - t\right)}\\ \end{array}\]
\frac{x \cdot 2.0}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \le -7.290611189347871 \cdot 10^{-40}:\\
\;\;\;\;\frac{\frac{2.0 \cdot x}{y - t}}{z}\\

\mathbf{else}:\\
\;\;\;\;\frac{2.0 \cdot x}{z \cdot \left(y - t\right)}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r23359755 = x;
        double r23359756 = 2.0;
        double r23359757 = r23359755 * r23359756;
        double r23359758 = y;
        double r23359759 = z;
        double r23359760 = r23359758 * r23359759;
        double r23359761 = t;
        double r23359762 = r23359761 * r23359759;
        double r23359763 = r23359760 - r23359762;
        double r23359764 = r23359757 / r23359763;
        return r23359764;
}

double f(double x, double y, double z, double t) {
        double r23359765 = x;
        double r23359766 = -7.290611189347871e-40;
        bool r23359767 = r23359765 <= r23359766;
        double r23359768 = 2.0;
        double r23359769 = r23359768 * r23359765;
        double r23359770 = y;
        double r23359771 = t;
        double r23359772 = r23359770 - r23359771;
        double r23359773 = r23359769 / r23359772;
        double r23359774 = z;
        double r23359775 = r23359773 / r23359774;
        double r23359776 = r23359774 * r23359772;
        double r23359777 = r23359769 / r23359776;
        double r23359778 = r23359767 ? r23359775 : r23359777;
        return r23359778;
}

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.7
Target2.1
Herbie3.7
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot 2.0}{y \cdot z - t \cdot z} \lt -2.559141628295061 \cdot 10^{-13}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2.0\\ \mathbf{elif}\;\frac{x \cdot 2.0}{y \cdot z - t \cdot z} \lt 1.045027827330126 \cdot 10^{-269}:\\ \;\;\;\;\frac{\frac{x}{z} \cdot 2.0}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\left(y - t\right) \cdot z} \cdot 2.0\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -7.290611189347871e-40

    1. Initial program 10.0

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{2.0 \cdot x}{z}}}{y - t}\]
    7. Applied associate-/l/9.2

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

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

    if -7.290611189347871e-40 < x

    1. Initial program 5.5

      \[\frac{x \cdot 2.0}{y \cdot z - t \cdot z}\]
    2. Simplified4.6

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

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

      \[\leadsto \frac{\color{blue}{\frac{2.0 \cdot x}{z}}}{y - t}\]
    7. Applied associate-/l/4.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -7.290611189347871 \cdot 10^{-40}:\\ \;\;\;\;\frac{\frac{2.0 \cdot x}{y - t}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{2.0 \cdot x}{z \cdot \left(y - t\right)}\\ \end{array}\]

Reproduce

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