Average Error: 6.4 → 4.1
Time: 52.2s
Precision: 64
\[\frac{\frac{1.0}{x}}{y \cdot \left(1.0 + z \cdot z\right)}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.354892073804187 \cdot 10^{+154}:\\ \;\;\;\;\frac{1.0}{x \cdot \left(\left(y \cdot z\right) \cdot z\right)}\\ \mathbf{elif}\;z \le 3.778094829799867 \cdot 10^{+122}:\\ \;\;\;\;\frac{1}{\frac{x}{\frac{1.0}{\mathsf{fma}\left(z, z, 1.0\right)}}} \cdot \frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1.0}{x \cdot \left(\left(y \cdot z\right) \cdot z\right)}\\ \end{array}\]
\frac{\frac{1.0}{x}}{y \cdot \left(1.0 + z \cdot z\right)}
\begin{array}{l}
\mathbf{if}\;z \le -1.354892073804187 \cdot 10^{+154}:\\
\;\;\;\;\frac{1.0}{x \cdot \left(\left(y \cdot z\right) \cdot z\right)}\\

\mathbf{elif}\;z \le 3.778094829799867 \cdot 10^{+122}:\\
\;\;\;\;\frac{1}{\frac{x}{\frac{1.0}{\mathsf{fma}\left(z, z, 1.0\right)}}} \cdot \frac{1}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{1.0}{x \cdot \left(\left(y \cdot z\right) \cdot z\right)}\\

\end{array}
double f(double x, double y, double z) {
        double r14803542 = 1.0;
        double r14803543 = x;
        double r14803544 = r14803542 / r14803543;
        double r14803545 = y;
        double r14803546 = z;
        double r14803547 = r14803546 * r14803546;
        double r14803548 = r14803542 + r14803547;
        double r14803549 = r14803545 * r14803548;
        double r14803550 = r14803544 / r14803549;
        return r14803550;
}

double f(double x, double y, double z) {
        double r14803551 = z;
        double r14803552 = -1.354892073804187e+154;
        bool r14803553 = r14803551 <= r14803552;
        double r14803554 = 1.0;
        double r14803555 = x;
        double r14803556 = y;
        double r14803557 = r14803556 * r14803551;
        double r14803558 = r14803557 * r14803551;
        double r14803559 = r14803555 * r14803558;
        double r14803560 = r14803554 / r14803559;
        double r14803561 = 3.778094829799867e+122;
        bool r14803562 = r14803551 <= r14803561;
        double r14803563 = 1.0;
        double r14803564 = fma(r14803551, r14803551, r14803554);
        double r14803565 = r14803554 / r14803564;
        double r14803566 = r14803555 / r14803565;
        double r14803567 = r14803563 / r14803566;
        double r14803568 = r14803563 / r14803556;
        double r14803569 = r14803567 * r14803568;
        double r14803570 = r14803562 ? r14803569 : r14803560;
        double r14803571 = r14803553 ? r14803560 : r14803570;
        return r14803571;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.4
Target5.8
Herbie4.1
\[\begin{array}{l} \mathbf{if}\;y \cdot \left(1.0 + z \cdot z\right) \lt -\infty:\\ \;\;\;\;\frac{\frac{1.0}{y}}{\left(1.0 + z \cdot z\right) \cdot x}\\ \mathbf{elif}\;y \cdot \left(1.0 + z \cdot z\right) \lt 8.680743250567252 \cdot 10^{+305}:\\ \;\;\;\;\frac{\frac{1.0}{x}}{\left(1.0 + z \cdot z\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1.0}{y}}{\left(1.0 + z \cdot z\right) \cdot x}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -1.354892073804187e+154 or 3.778094829799867e+122 < z

    1. Initial program 17.5

      \[\frac{\frac{1.0}{x}}{y \cdot \left(1.0 + z \cdot z\right)}\]
    2. Taylor expanded around inf 17.5

      \[\leadsto \color{blue}{\frac{1.0}{x \cdot \left({z}^{2} \cdot y\right)}}\]
    3. Simplified8.6

      \[\leadsto \color{blue}{\frac{1.0}{\left(z \cdot \left(z \cdot y\right)\right) \cdot x}}\]

    if -1.354892073804187e+154 < z < 3.778094829799867e+122

    1. Initial program 1.7

      \[\frac{\frac{1.0}{x}}{y \cdot \left(1.0 + z \cdot z\right)}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity1.7

      \[\leadsto \frac{\frac{1.0}{\color{blue}{1 \cdot x}}}{y \cdot \left(1.0 + z \cdot z\right)}\]
    4. Applied *-un-lft-identity1.7

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot 1.0}}{1 \cdot x}}{y \cdot \left(1.0 + z \cdot z\right)}\]
    5. Applied times-frac1.7

      \[\leadsto \frac{\color{blue}{\frac{1}{1} \cdot \frac{1.0}{x}}}{y \cdot \left(1.0 + z \cdot z\right)}\]
    6. Applied times-frac1.9

      \[\leadsto \color{blue}{\frac{\frac{1}{1}}{y} \cdot \frac{\frac{1.0}{x}}{1.0 + z \cdot z}}\]
    7. Simplified1.9

      \[\leadsto \color{blue}{\frac{1}{y}} \cdot \frac{\frac{1.0}{x}}{1.0 + z \cdot z}\]
    8. Simplified1.9

      \[\leadsto \frac{1}{y} \cdot \color{blue}{\frac{\frac{1.0}{\mathsf{fma}\left(z, z, 1.0\right)}}{x}}\]
    9. Using strategy rm
    10. Applied clear-num2.1

      \[\leadsto \frac{1}{y} \cdot \color{blue}{\frac{1}{\frac{x}{\frac{1.0}{\mathsf{fma}\left(z, z, 1.0\right)}}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification4.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.354892073804187 \cdot 10^{+154}:\\ \;\;\;\;\frac{1.0}{x \cdot \left(\left(y \cdot z\right) \cdot z\right)}\\ \mathbf{elif}\;z \le 3.778094829799867 \cdot 10^{+122}:\\ \;\;\;\;\frac{1}{\frac{x}{\frac{1.0}{\mathsf{fma}\left(z, z, 1.0\right)}}} \cdot \frac{1}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1.0}{x \cdot \left(\left(y \cdot z\right) \cdot z\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2019164 +o rules:numerics
(FPCore (x y z)
  :name "Statistics.Distribution.CauchyLorentz:$cdensity from math-functions-0.1.5.2"

  :herbie-target
  (if (< (* y (+ 1.0 (* z z))) -inf.0) (/ (/ 1.0 y) (* (+ 1.0 (* z z)) x)) (if (< (* y (+ 1.0 (* z z))) 8.680743250567252e+305) (/ (/ 1.0 x) (* (+ 1.0 (* z z)) y)) (/ (/ 1.0 y) (* (+ 1.0 (* z z)) x))))

  (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))