Average Error: 6.8 → 2.1
Time: 10.1s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -49355.0736941491268:\\ \;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\ \mathbf{elif}\;z \le 1.74137454924600484 \cdot 10^{79}:\\ \;\;\;\;\frac{x}{\frac{{\left(z \cdot \left(y - t\right)\right)}^{1}}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{x}}{\frac{z}{\sqrt[3]{x}}} \cdot \frac{\sqrt[3]{x}}{\frac{y - t}{2}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -49355.0736941491268:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{y - t}{2}}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{x}}{\frac{z}{\sqrt[3]{x}}} \cdot \frac{\sqrt[3]{x}}{\frac{y - t}{2}}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r592675 = x;
        double r592676 = 2.0;
        double r592677 = r592675 * r592676;
        double r592678 = y;
        double r592679 = z;
        double r592680 = r592678 * r592679;
        double r592681 = t;
        double r592682 = r592681 * r592679;
        double r592683 = r592680 - r592682;
        double r592684 = r592677 / r592683;
        return r592684;
}

double f(double x, double y, double z, double t) {
        double r592685 = z;
        double r592686 = -49355.07369414913;
        bool r592687 = r592685 <= r592686;
        double r592688 = x;
        double r592689 = r592688 / r592685;
        double r592690 = y;
        double r592691 = t;
        double r592692 = r592690 - r592691;
        double r592693 = 2.0;
        double r592694 = r592692 / r592693;
        double r592695 = r592689 / r592694;
        double r592696 = 1.741374549246005e+79;
        bool r592697 = r592685 <= r592696;
        double r592698 = r592685 * r592692;
        double r592699 = 1.0;
        double r592700 = pow(r592698, r592699);
        double r592701 = r592700 / r592693;
        double r592702 = r592688 / r592701;
        double r592703 = cbrt(r592688);
        double r592704 = r592685 / r592703;
        double r592705 = r592703 / r592704;
        double r592706 = r592703 / r592694;
        double r592707 = r592705 * r592706;
        double r592708 = r592697 ? r592702 : r592707;
        double r592709 = r592687 ? r592695 : r592708;
        return r592709;
}

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.8
Target2.2
Herbie2.1
\[\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 3 regimes
  2. if z < -49355.07369414913

    1. Initial program 11.2

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{y - t}{2}}}\]
    6. Applied associate-/r*1.7

      \[\leadsto \color{blue}{\frac{\frac{x}{\frac{z}{1}}}{\frac{y - t}{2}}}\]
    7. Simplified1.7

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

    if -49355.07369414913 < z < 1.741374549246005e+79

    1. Initial program 2.4

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

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

      \[\leadsto \frac{x}{\frac{z \cdot \color{blue}{{\left(y - t\right)}^{1}}}{2}}\]
    5. Applied pow12.4

      \[\leadsto \frac{x}{\frac{\color{blue}{{z}^{1}} \cdot {\left(y - t\right)}^{1}}{2}}\]
    6. Applied pow-prod-down2.4

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

    if 1.741374549246005e+79 < z

    1. Initial program 12.7

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{y - t}{2}}}\]
    6. Applied add-cube-cbrt10.6

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\frac{z}{1}} \cdot \frac{\sqrt[3]{x}}{\frac{y - t}{2}}}\]
    8. Simplified1.9

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

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

Reproduce

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