Average Error: 6.7 → 3.9
Time: 50.5s
Precision: 64
\[\frac{\frac{1.0}{x}}{y \cdot \left(1.0 + z \cdot z\right)}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.3479099727642317 \cdot 10^{+41}:\\ \;\;\;\;\frac{\frac{1.0}{x}}{\left(z \cdot y\right) \cdot z}\\ \mathbf{elif}\;z \le 9.636870595470585 \cdot 10^{+117}:\\ \;\;\;\;\left(\frac{1}{y} \cdot \frac{1}{\mathsf{fma}\left(z, z, 1.0\right)}\right) \cdot \frac{1.0}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1.0}{x}}{\left(z \cdot y\right) \cdot z}\\ \end{array}\]
\frac{\frac{1.0}{x}}{y \cdot \left(1.0 + z \cdot z\right)}
\begin{array}{l}
\mathbf{if}\;z \le -2.3479099727642317 \cdot 10^{+41}:\\
\;\;\;\;\frac{\frac{1.0}{x}}{\left(z \cdot y\right) \cdot z}\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r14150508 = 1.0;
        double r14150509 = x;
        double r14150510 = r14150508 / r14150509;
        double r14150511 = y;
        double r14150512 = z;
        double r14150513 = r14150512 * r14150512;
        double r14150514 = r14150508 + r14150513;
        double r14150515 = r14150511 * r14150514;
        double r14150516 = r14150510 / r14150515;
        return r14150516;
}

double f(double x, double y, double z) {
        double r14150517 = z;
        double r14150518 = -2.3479099727642317e+41;
        bool r14150519 = r14150517 <= r14150518;
        double r14150520 = 1.0;
        double r14150521 = x;
        double r14150522 = r14150520 / r14150521;
        double r14150523 = y;
        double r14150524 = r14150517 * r14150523;
        double r14150525 = r14150524 * r14150517;
        double r14150526 = r14150522 / r14150525;
        double r14150527 = 9.636870595470585e+117;
        bool r14150528 = r14150517 <= r14150527;
        double r14150529 = 1.0;
        double r14150530 = r14150529 / r14150523;
        double r14150531 = fma(r14150517, r14150517, r14150520);
        double r14150532 = r14150529 / r14150531;
        double r14150533 = r14150530 * r14150532;
        double r14150534 = r14150533 * r14150522;
        double r14150535 = r14150528 ? r14150534 : r14150526;
        double r14150536 = r14150519 ? r14150526 : r14150535;
        return r14150536;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original6.7
Target5.9
Herbie3.9
\[\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 < -2.3479099727642317e+41 or 9.636870595470585e+117 < z

    1. Initial program 14.7

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

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

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

    if -2.3479099727642317e+41 < z < 9.636870595470585e+117

    1. Initial program 1.3

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

      \[\leadsto \frac{\frac{1.0}{x}}{\color{blue}{{z}^{2} \cdot y + 1.0 \cdot y}}\]
    3. Simplified1.3

      \[\leadsto \frac{\frac{1.0}{x}}{\color{blue}{\mathsf{fma}\left(z, z, 1.0\right) \cdot y}}\]
    4. Using strategy rm
    5. Applied div-inv1.3

      \[\leadsto \color{blue}{\frac{1.0}{x} \cdot \frac{1}{\mathsf{fma}\left(z, z, 1.0\right) \cdot y}}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt1.3

      \[\leadsto \frac{1.0}{x} \cdot \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\mathsf{fma}\left(z, z, 1.0\right) \cdot y}\]
    8. Applied times-frac1.2

      \[\leadsto \frac{1.0}{x} \cdot \color{blue}{\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\mathsf{fma}\left(z, z, 1.0\right)} \cdot \frac{\sqrt[3]{1}}{y}\right)}\]
    9. Simplified1.2

      \[\leadsto \frac{1.0}{x} \cdot \left(\color{blue}{\frac{1}{\mathsf{fma}\left(z, z, 1.0\right)}} \cdot \frac{\sqrt[3]{1}}{y}\right)\]
    10. Simplified1.2

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

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

Reproduce

herbie shell --seed 2019162 +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)))))