Average Error: 6.3 → 3.5
Time: 49.6s
Precision: 64
\[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.075470482331493311969829664152890033654 \cdot 10^{137}:\\ \;\;\;\;\frac{\frac{1}{x}}{\left(z \cdot y\right) \cdot z}\\ \mathbf{elif}\;z \le 5.011064830926822850239479880900929355774 \cdot 10^{56}:\\ \;\;\;\;\frac{1}{\sqrt{1 + z \cdot z} \cdot y} \cdot \frac{\frac{1}{x}}{\sqrt{1 + z \cdot z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{\left(z \cdot y\right) \cdot z}\\ \end{array}\]
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\begin{array}{l}
\mathbf{if}\;z \le -1.075470482331493311969829664152890033654 \cdot 10^{137}:\\
\;\;\;\;\frac{\frac{1}{x}}{\left(z \cdot y\right) \cdot z}\\

\mathbf{elif}\;z \le 5.011064830926822850239479880900929355774 \cdot 10^{56}:\\
\;\;\;\;\frac{1}{\sqrt{1 + z \cdot z} \cdot y} \cdot \frac{\frac{1}{x}}{\sqrt{1 + z \cdot z}}\\

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

\end{array}
double f(double x, double y, double z) {
        double r13715839 = 1.0;
        double r13715840 = x;
        double r13715841 = r13715839 / r13715840;
        double r13715842 = y;
        double r13715843 = z;
        double r13715844 = r13715843 * r13715843;
        double r13715845 = r13715839 + r13715844;
        double r13715846 = r13715842 * r13715845;
        double r13715847 = r13715841 / r13715846;
        return r13715847;
}

double f(double x, double y, double z) {
        double r13715848 = z;
        double r13715849 = -1.0754704823314933e+137;
        bool r13715850 = r13715848 <= r13715849;
        double r13715851 = 1.0;
        double r13715852 = x;
        double r13715853 = r13715851 / r13715852;
        double r13715854 = y;
        double r13715855 = r13715848 * r13715854;
        double r13715856 = r13715855 * r13715848;
        double r13715857 = r13715853 / r13715856;
        double r13715858 = 5.011064830926823e+56;
        bool r13715859 = r13715848 <= r13715858;
        double r13715860 = r13715848 * r13715848;
        double r13715861 = r13715851 + r13715860;
        double r13715862 = sqrt(r13715861);
        double r13715863 = r13715862 * r13715854;
        double r13715864 = r13715851 / r13715863;
        double r13715865 = 1.0;
        double r13715866 = r13715865 / r13715852;
        double r13715867 = r13715866 / r13715862;
        double r13715868 = r13715864 * r13715867;
        double r13715869 = r13715859 ? r13715868 : r13715857;
        double r13715870 = r13715850 ? r13715857 : r13715869;
        return r13715870;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.3
Target5.5
Herbie3.5
\[\begin{array}{l} \mathbf{if}\;y \cdot \left(1 + z \cdot z\right) \lt -\infty:\\ \;\;\;\;\frac{\frac{1}{y}}{\left(1 + z \cdot z\right) \cdot x}\\ \mathbf{elif}\;y \cdot \left(1 + z \cdot z\right) \lt 8.680743250567251617010582226806563373013 \cdot 10^{305}:\\ \;\;\;\;\frac{\frac{1}{x}}{\left(1 + z \cdot z\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y}}{\left(1 + z \cdot z\right) \cdot x}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -1.0754704823314933e+137 or 5.011064830926823e+56 < z

    1. Initial program 14.7

      \[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt14.7

      \[\leadsto \frac{\frac{1}{x}}{y \cdot \color{blue}{\left(\sqrt{1 + z \cdot z} \cdot \sqrt{1 + z \cdot z}\right)}}\]
    4. Applied associate-*r*14.7

      \[\leadsto \frac{\frac{1}{x}}{\color{blue}{\left(y \cdot \sqrt{1 + z \cdot z}\right) \cdot \sqrt{1 + z \cdot z}}}\]
    5. Taylor expanded around inf 14.9

      \[\leadsto \color{blue}{\frac{1}{x \cdot \left({z}^{2} \cdot y\right)}}\]
    6. Simplified7.4

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

    if -1.0754704823314933e+137 < z < 5.011064830926823e+56

    1. Initial program 1.4

      \[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt1.4

      \[\leadsto \frac{\frac{1}{x}}{y \cdot \color{blue}{\left(\sqrt{1 + z \cdot z} \cdot \sqrt{1 + z \cdot z}\right)}}\]
    4. Applied associate-*r*1.4

      \[\leadsto \frac{\frac{1}{x}}{\color{blue}{\left(y \cdot \sqrt{1 + z \cdot z}\right) \cdot \sqrt{1 + z \cdot z}}}\]
    5. Using strategy rm
    6. Applied div-inv1.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.075470482331493311969829664152890033654 \cdot 10^{137}:\\ \;\;\;\;\frac{\frac{1}{x}}{\left(z \cdot y\right) \cdot z}\\ \mathbf{elif}\;z \le 5.011064830926822850239479880900929355774 \cdot 10^{56}:\\ \;\;\;\;\frac{1}{\sqrt{1 + z \cdot z} \cdot y} \cdot \frac{\frac{1}{x}}{\sqrt{1 + z \cdot z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{\left(z \cdot y\right) \cdot z}\\ \end{array}\]

Reproduce

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