Average Error: 6.7 → 3.7
Time: 13.8s
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 r22820528 = x;
        double r22820529 = 2.0;
        double r22820530 = r22820528 * r22820529;
        double r22820531 = y;
        double r22820532 = z;
        double r22820533 = r22820531 * r22820532;
        double r22820534 = t;
        double r22820535 = r22820534 * r22820532;
        double r22820536 = r22820533 - r22820535;
        double r22820537 = r22820530 / r22820536;
        return r22820537;
}

double f(double x, double y, double z, double t) {
        double r22820538 = x;
        double r22820539 = -7.290611189347871e-40;
        bool r22820540 = r22820538 <= r22820539;
        double r22820541 = 2.0;
        double r22820542 = r22820541 * r22820538;
        double r22820543 = y;
        double r22820544 = t;
        double r22820545 = r22820543 - r22820544;
        double r22820546 = r22820542 / r22820545;
        double r22820547 = z;
        double r22820548 = r22820546 / r22820547;
        double r22820549 = r22820547 * r22820545;
        double r22820550 = r22820542 / r22820549;
        double r22820551 = r22820540 ? r22820548 : r22820550;
        return r22820551;
}

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))))