Average Error: 6.8 → 2.2
Time: 4.4s
Precision: 64
\[\frac{x \cdot 2}{y \cdot z - t \cdot z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.0397032106121382 \cdot 10^{-57} \lor \neg \left(x \le 4.5645374866027015 \cdot 10^{-88}\right):\\ \;\;\;\;\frac{\frac{x}{\frac{y - t}{2}}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{z}}{y - t} \cdot \frac{\sqrt[3]{x}}{\frac{1}{2}}\\ \end{array}\]
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\begin{array}{l}
\mathbf{if}\;x \le -2.0397032106121382 \cdot 10^{-57} \lor \neg \left(x \le 4.5645374866027015 \cdot 10^{-88}\right):\\
\;\;\;\;\frac{\frac{x}{\frac{y - t}{2}}}{z}\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r547815 = x;
        double r547816 = 2.0;
        double r547817 = r547815 * r547816;
        double r547818 = y;
        double r547819 = z;
        double r547820 = r547818 * r547819;
        double r547821 = t;
        double r547822 = r547821 * r547819;
        double r547823 = r547820 - r547822;
        double r547824 = r547817 / r547823;
        return r547824;
}

double f(double x, double y, double z, double t) {
        double r547825 = x;
        double r547826 = -2.0397032106121382e-57;
        bool r547827 = r547825 <= r547826;
        double r547828 = 4.5645374866027015e-88;
        bool r547829 = r547825 <= r547828;
        double r547830 = !r547829;
        bool r547831 = r547827 || r547830;
        double r547832 = y;
        double r547833 = t;
        double r547834 = r547832 - r547833;
        double r547835 = 2.0;
        double r547836 = r547834 / r547835;
        double r547837 = r547825 / r547836;
        double r547838 = z;
        double r547839 = r547837 / r547838;
        double r547840 = cbrt(r547825);
        double r547841 = r547840 * r547840;
        double r547842 = r547841 / r547838;
        double r547843 = r547842 / r547834;
        double r547844 = 1.0;
        double r547845 = r547844 / r547835;
        double r547846 = r547840 / r547845;
        double r547847 = r547843 * r547846;
        double r547848 = r547831 ? r547839 : r547847;
        return r547848;
}

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.3
Herbie2.2
\[\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.0397032106121382e-57 or 4.5645374866027015e-88 < x

    1. Initial program 9.0

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{y - t}{2}}}\]
    6. Applied *-un-lft-identity8.1

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{\frac{z}{1} \cdot \frac{y - t}{2}}\]
    7. Applied times-frac2.5

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

      \[\leadsto \color{blue}{\frac{1}{z}} \cdot \frac{x}{\frac{y - t}{2}}\]
    9. Using strategy rm
    10. Applied associate-*l/2.4

      \[\leadsto \color{blue}{\frac{1 \cdot \frac{x}{\frac{y - t}{2}}}{z}}\]
    11. Simplified2.4

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

    if -2.0397032106121382e-57 < x < 4.5645374866027015e-88

    1. Initial program 3.6

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

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{1} \cdot \frac{y - t}{2}}}\]
    6. Applied *-un-lft-identity2.2

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{\frac{z}{1} \cdot \frac{y - t}{2}}\]
    7. Applied times-frac9.3

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

      \[\leadsto \color{blue}{\frac{1}{z}} \cdot \frac{x}{\frac{y - t}{2}}\]
    9. Using strategy rm
    10. Applied div-inv9.3

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

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

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

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

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

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

Reproduce

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