Average Error: 6.7 → 3.4
Time: 6.7s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot 2 \le 1.20445290796802163 \cdot 10^{-28}:\\ \;\;\;\;\left(\left(2 \cdot x\right) \cdot \left(\sqrt[3]{\frac{1}{z}} \cdot \sqrt[3]{\frac{1}{z}}\right)\right) \cdot \frac{\sqrt[3]{\frac{1}{z}}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \cdot 2 \le 1.20445290796802163 \cdot 10^{-28}:\\
\;\;\;\;\left(\left(2 \cdot x\right) \cdot \left(\sqrt[3]{\frac{1}{z}} \cdot \sqrt[3]{\frac{1}{z}}\right)\right) \cdot \frac{\sqrt[3]{\frac{1}{z}}}{y - t}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r517482 = x;
        double r517483 = 2.0;
        double r517484 = r517482 * r517483;
        double r517485 = y;
        double r517486 = z;
        double r517487 = r517485 * r517486;
        double r517488 = t;
        double r517489 = r517488 * r517486;
        double r517490 = r517487 - r517489;
        double r517491 = r517484 / r517490;
        return r517491;
}

double f(double x, double y, double z, double t) {
        double r517492 = x;
        double r517493 = 2.0;
        double r517494 = r517492 * r517493;
        double r517495 = 1.2044529079680216e-28;
        bool r517496 = r517494 <= r517495;
        double r517497 = r517493 * r517492;
        double r517498 = 1.0;
        double r517499 = z;
        double r517500 = r517498 / r517499;
        double r517501 = cbrt(r517500);
        double r517502 = r517501 * r517501;
        double r517503 = r517497 * r517502;
        double r517504 = y;
        double r517505 = t;
        double r517506 = r517504 - r517505;
        double r517507 = r517501 / r517506;
        double r517508 = r517503 * r517507;
        double r517509 = r517494 / r517506;
        double r517510 = r517509 / r517499;
        double r517511 = r517496 ? r517508 : r517510;
        return r517511;
}

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.0
Herbie3.4
\[\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 2 regimes
  2. if (* x 2.0) < 1.2044529079680216e-28

    1. Initial program 5.7

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

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

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

      \[\leadsto \left(x \cdot 2\right) \cdot \color{blue}{\frac{\frac{1}{z}}{y - t}}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity4.5

      \[\leadsto \left(x \cdot 2\right) \cdot \frac{\frac{1}{z}}{\color{blue}{1 \cdot \left(y - t\right)}}\]
    9. Applied add-cube-cbrt5.1

      \[\leadsto \left(x \cdot 2\right) \cdot \frac{\color{blue}{\left(\sqrt[3]{\frac{1}{z}} \cdot \sqrt[3]{\frac{1}{z}}\right) \cdot \sqrt[3]{\frac{1}{z}}}}{1 \cdot \left(y - t\right)}\]
    10. Applied times-frac5.1

      \[\leadsto \left(x \cdot 2\right) \cdot \color{blue}{\left(\frac{\sqrt[3]{\frac{1}{z}} \cdot \sqrt[3]{\frac{1}{z}}}{1} \cdot \frac{\sqrt[3]{\frac{1}{z}}}{y - t}\right)}\]
    11. Applied associate-*r*3.7

      \[\leadsto \color{blue}{\left(\left(x \cdot 2\right) \cdot \frac{\sqrt[3]{\frac{1}{z}} \cdot \sqrt[3]{\frac{1}{z}}}{1}\right) \cdot \frac{\sqrt[3]{\frac{1}{z}}}{y - t}}\]
    12. Simplified3.7

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

    if 1.2044529079680216e-28 < (* x 2.0)

    1. Initial program 9.8

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot 2 \le 1.20445290796802163 \cdot 10^{-28}:\\ \;\;\;\;\left(\left(2 \cdot x\right) \cdot \left(\sqrt[3]{\frac{1}{z}} \cdot \sqrt[3]{\frac{1}{z}}\right)\right) \cdot \frac{\sqrt[3]{\frac{1}{z}}}{y - t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{y - t}}{z}\\ \end{array}\]

Reproduce

herbie shell --seed 2020045 +o rules:numerics
(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))))