Average Error: 6.6 → 1.1
Time: 14.0s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -9.59273402401235705083952067476240049133 \cdot 10^{254}:\\ \;\;\;\;\frac{\frac{2 \cdot x}{z}}{y - t}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 5.139090220757435068465924158146742164578 \cdot 10^{231}:\\ \;\;\;\;\frac{2 \cdot x}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2 \cdot x}{z}}{y - t}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;y \cdot z - t \cdot z \le -9.59273402401235705083952067476240049133 \cdot 10^{254}:\\
\;\;\;\;\frac{\frac{2 \cdot x}{z}}{y - t}\\

\mathbf{elif}\;y \cdot z - t \cdot z \le 5.139090220757435068465924158146742164578 \cdot 10^{231}:\\
\;\;\;\;\frac{2 \cdot x}{y \cdot z - t \cdot z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r22783439 = x;
        double r22783440 = 2.0;
        double r22783441 = r22783439 * r22783440;
        double r22783442 = y;
        double r22783443 = z;
        double r22783444 = r22783442 * r22783443;
        double r22783445 = t;
        double r22783446 = r22783445 * r22783443;
        double r22783447 = r22783444 - r22783446;
        double r22783448 = r22783441 / r22783447;
        return r22783448;
}

double f(double x, double y, double z, double t) {
        double r22783449 = y;
        double r22783450 = z;
        double r22783451 = r22783449 * r22783450;
        double r22783452 = t;
        double r22783453 = r22783452 * r22783450;
        double r22783454 = r22783451 - r22783453;
        double r22783455 = -9.592734024012357e+254;
        bool r22783456 = r22783454 <= r22783455;
        double r22783457 = 2.0;
        double r22783458 = x;
        double r22783459 = r22783457 * r22783458;
        double r22783460 = r22783459 / r22783450;
        double r22783461 = r22783449 - r22783452;
        double r22783462 = r22783460 / r22783461;
        double r22783463 = 5.139090220757435e+231;
        bool r22783464 = r22783454 <= r22783463;
        double r22783465 = r22783459 / r22783454;
        double r22783466 = r22783464 ? r22783465 : r22783462;
        double r22783467 = r22783456 ? r22783462 : r22783466;
        return r22783467;
}

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.6
Target2.0
Herbie1.1
\[\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 (- (* y z) (* t z)) < -9.592734024012357e+254 or 5.139090220757435e+231 < (- (* y z) (* t z))

    1. Initial program 17.7

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
    2. Using strategy rm
    3. Applied distribute-rgt-out--13.9

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

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

    if -9.592734024012357e+254 < (- (* y z) (* t z)) < 5.139090220757435e+231

    1. Initial program 1.5

      \[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot z - t \cdot z \le -9.59273402401235705083952067476240049133 \cdot 10^{254}:\\ \;\;\;\;\frac{\frac{2 \cdot x}{z}}{y - t}\\ \mathbf{elif}\;y \cdot z - t \cdot z \le 5.139090220757435068465924158146742164578 \cdot 10^{231}:\\ \;\;\;\;\frac{2 \cdot x}{y \cdot z - t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{2 \cdot x}{z}}{y - t}\\ \end{array}\]

Reproduce

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