Average Error: 6.6 → 2.9
Time: 13.6s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot 2 \le -8.487545604087800663717439236716923273121 \cdot 10^{116}:\\ \;\;\;\;\frac{\sqrt[3]{\frac{x \cdot 2}{y - t}} \cdot \sqrt[3]{\frac{x \cdot 2}{y - t}}}{\frac{z}{\sqrt[3]{\frac{x \cdot 2}{y - t}}}}\\ \mathbf{elif}\;x \cdot 2 \le 4.672191924242227383090621876278125047429 \cdot 10^{-197}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{elif}\;x \cdot 2 \le 3.071367817763602617128651373833917514734 \cdot 10^{113}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \left(y - t\right)}}{\sqrt[3]{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{\frac{x \cdot 2}{y - t}} \cdot \sqrt[3]{\frac{x \cdot 2}{y - t}}}{\frac{z}{\sqrt[3]{\frac{x \cdot 2}{y - t}}}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \cdot 2 \le -8.487545604087800663717439236716923273121 \cdot 10^{116}:\\
\;\;\;\;\frac{\sqrt[3]{\frac{x \cdot 2}{y - t}} \cdot \sqrt[3]{\frac{x \cdot 2}{y - t}}}{\frac{z}{\sqrt[3]{\frac{x \cdot 2}{y - t}}}}\\

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

\mathbf{elif}\;x \cdot 2 \le 3.071367817763602617128651373833917514734 \cdot 10^{113}:\\
\;\;\;\;\frac{\frac{x \cdot 2}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \left(y - t\right)}}{\sqrt[3]{z}}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r525781 = x;
        double r525782 = 2.0;
        double r525783 = r525781 * r525782;
        double r525784 = y;
        double r525785 = z;
        double r525786 = r525784 * r525785;
        double r525787 = t;
        double r525788 = r525787 * r525785;
        double r525789 = r525786 - r525788;
        double r525790 = r525783 / r525789;
        return r525790;
}

double f(double x, double y, double z, double t) {
        double r525791 = x;
        double r525792 = 2.0;
        double r525793 = r525791 * r525792;
        double r525794 = -8.4875456040878e+116;
        bool r525795 = r525793 <= r525794;
        double r525796 = y;
        double r525797 = t;
        double r525798 = r525796 - r525797;
        double r525799 = r525793 / r525798;
        double r525800 = cbrt(r525799);
        double r525801 = r525800 * r525800;
        double r525802 = z;
        double r525803 = r525802 / r525800;
        double r525804 = r525801 / r525803;
        double r525805 = 4.6721919242422274e-197;
        bool r525806 = r525793 <= r525805;
        double r525807 = r525793 / r525802;
        double r525808 = r525807 / r525798;
        double r525809 = 3.0713678177636026e+113;
        bool r525810 = r525793 <= r525809;
        double r525811 = cbrt(r525802);
        double r525812 = r525811 * r525811;
        double r525813 = r525812 * r525798;
        double r525814 = r525793 / r525813;
        double r525815 = r525814 / r525811;
        double r525816 = r525810 ? r525815 : r525804;
        double r525817 = r525806 ? r525808 : r525816;
        double r525818 = r525795 ? r525804 : r525817;
        return r525818;
}

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
Target1.9
Herbie2.9
\[\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 3 regimes
  2. if (* x 2.0) < -8.4875456040878e+116 or 3.0713678177636026e+113 < (* x 2.0)

    1. Initial program 14.4

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

      \[\leadsto \color{blue}{\frac{2}{y - t} \cdot \frac{x}{z}}\]
    3. Using strategy rm
    4. Applied associate-*r/4.0

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

      \[\leadsto \frac{\color{blue}{\frac{x \cdot 2}{y - t}}}{z}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt4.9

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{\frac{x \cdot 2}{y - t}} \cdot \sqrt[3]{\frac{x \cdot 2}{y - t}}\right) \cdot \sqrt[3]{\frac{x \cdot 2}{y - t}}}}{z}\]
    8. Applied associate-/l*4.9

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

    if -8.4875456040878e+116 < (* x 2.0) < 4.6721919242422274e-197

    1. Initial program 3.8

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

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

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

      \[\leadsto \frac{2}{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}{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*5.1

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

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

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

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

    if 4.6721919242422274e-197 < (* x 2.0) < 3.0713678177636026e+113

    1. Initial program 3.5

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

      \[\leadsto \color{blue}{\frac{2}{y - t} \cdot \frac{x}{z}}\]
    3. Using strategy rm
    4. Applied associate-*r/4.6

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

      \[\leadsto \frac{\color{blue}{\frac{x \cdot 2}{y - t}}}{z}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt5.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot 2 \le -8.487545604087800663717439236716923273121 \cdot 10^{116}:\\ \;\;\;\;\frac{\sqrt[3]{\frac{x \cdot 2}{y - t}} \cdot \sqrt[3]{\frac{x \cdot 2}{y - t}}}{\frac{z}{\sqrt[3]{\frac{x \cdot 2}{y - t}}}}\\ \mathbf{elif}\;x \cdot 2 \le 4.672191924242227383090621876278125047429 \cdot 10^{-197}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{z}}{y - t}\\ \mathbf{elif}\;x \cdot 2 \le 3.071367817763602617128651373833917514734 \cdot 10^{113}:\\ \;\;\;\;\frac{\frac{x \cdot 2}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \left(y - t\right)}}{\sqrt[3]{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{\frac{x \cdot 2}{y - t}} \cdot \sqrt[3]{\frac{x \cdot 2}{y - t}}}{\frac{z}{\sqrt[3]{\frac{x \cdot 2}{y - t}}}}\\ \end{array}\]

Reproduce

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