Average Error: 6.9 → 1.9
Time: 13.9s
Precision: 64
\[\frac{x \cdot 2.0}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -5.4355961856746975 \cdot 10^{+39}:\\ \;\;\;\;\frac{\sqrt[3]{x} \cdot \left(2.0 \cdot \sqrt[3]{x}\right)}{y - t} \cdot \frac{\sqrt[3]{x}}{z}\\ \mathbf{elif}\;z \le 1.3604186575337987 \cdot 10^{-93}:\\ \;\;\;\;\frac{2.0 \cdot x}{z \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{x} \cdot \left(2.0 \cdot \sqrt[3]{x}\right)}{y - t} \cdot \frac{\sqrt[3]{x}}{z}\\ \end{array}\]
\frac{x \cdot 2.0}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;z \le -5.4355961856746975 \cdot 10^{+39}:\\
\;\;\;\;\frac{\sqrt[3]{x} \cdot \left(2.0 \cdot \sqrt[3]{x}\right)}{y - t} \cdot \frac{\sqrt[3]{x}}{z}\\

\mathbf{elif}\;z \le 1.3604186575337987 \cdot 10^{-93}:\\
\;\;\;\;\frac{2.0 \cdot x}{z \cdot \left(y - t\right)}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r28155776 = x;
        double r28155777 = 2.0;
        double r28155778 = r28155776 * r28155777;
        double r28155779 = y;
        double r28155780 = z;
        double r28155781 = r28155779 * r28155780;
        double r28155782 = t;
        double r28155783 = r28155782 * r28155780;
        double r28155784 = r28155781 - r28155783;
        double r28155785 = r28155778 / r28155784;
        return r28155785;
}

double f(double x, double y, double z, double t) {
        double r28155786 = z;
        double r28155787 = -5.4355961856746975e+39;
        bool r28155788 = r28155786 <= r28155787;
        double r28155789 = x;
        double r28155790 = cbrt(r28155789);
        double r28155791 = 2.0;
        double r28155792 = r28155791 * r28155790;
        double r28155793 = r28155790 * r28155792;
        double r28155794 = y;
        double r28155795 = t;
        double r28155796 = r28155794 - r28155795;
        double r28155797 = r28155793 / r28155796;
        double r28155798 = r28155790 / r28155786;
        double r28155799 = r28155797 * r28155798;
        double r28155800 = 1.3604186575337987e-93;
        bool r28155801 = r28155786 <= r28155800;
        double r28155802 = r28155791 * r28155789;
        double r28155803 = r28155786 * r28155796;
        double r28155804 = r28155802 / r28155803;
        double r28155805 = r28155801 ? r28155804 : r28155799;
        double r28155806 = r28155788 ? r28155799 : r28155805;
        return r28155806;
}

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.9
Target2.0
Herbie1.9
\[\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 z < -5.4355961856746975e+39 or 1.3604186575337987e-93 < z

    1. Initial program 10.1

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

      \[\leadsto \color{blue}{\frac{2.0}{y - t} \cdot \frac{x}{z}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity2.4

      \[\leadsto \frac{2.0}{y - t} \cdot \frac{x}{\color{blue}{1 \cdot z}}\]
    5. Applied add-cube-cbrt2.9

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

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

      \[\leadsto \color{blue}{\left(\frac{2.0}{y - t} \cdot \frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{1}\right) \cdot \frac{\sqrt[3]{x}}{z}}\]
    8. Simplified1.6

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

    if -5.4355961856746975e+39 < z < 1.3604186575337987e-93

    1. Initial program 2.3

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

      \[\leadsto \color{blue}{\frac{2.0}{y - t} \cdot \frac{x}{z}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity10.8

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

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

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

      \[\leadsto \color{blue}{\left(\frac{2.0}{y - t} \cdot \frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{1}\right) \cdot \frac{\sqrt[3]{x}}{z}}\]
    8. Simplified9.5

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

      \[\leadsto \color{blue}{\frac{\frac{\left(2.0 \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}}{y - t} \cdot \sqrt[3]{x}}{z}}\]
    11. Simplified10.0

      \[\leadsto \frac{\color{blue}{\frac{2.0 \cdot x}{y - t}}}{z}\]
    12. Using strategy rm
    13. Applied div-inv10.1

      \[\leadsto \frac{\color{blue}{\left(2.0 \cdot x\right) \cdot \frac{1}{y - t}}}{z}\]
    14. Applied associate-/l*2.4

      \[\leadsto \color{blue}{\frac{2.0 \cdot x}{\frac{z}{\frac{1}{y - t}}}}\]
    15. Simplified2.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -5.4355961856746975 \cdot 10^{+39}:\\ \;\;\;\;\frac{\sqrt[3]{x} \cdot \left(2.0 \cdot \sqrt[3]{x}\right)}{y - t} \cdot \frac{\sqrt[3]{x}}{z}\\ \mathbf{elif}\;z \le 1.3604186575337987 \cdot 10^{-93}:\\ \;\;\;\;\frac{2.0 \cdot x}{z \cdot \left(y - t\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{x} \cdot \left(2.0 \cdot \sqrt[3]{x}\right)}{y - t} \cdot \frac{\sqrt[3]{x}}{z}\\ \end{array}\]

Reproduce

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