Average Error: 6.2 → 3.5
Time: 2.4m
Precision: 64
\[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\]
\[\begin{array}{l} \mathbf{if}\;z \cdot z \le 9.274205810742728755895557522411157122625 \cdot 10^{229}:\\ \;\;\;\;\frac{\frac{\frac{1}{x}}{y \cdot \sqrt{1 + z \cdot z}}}{\sqrt{1 + z \cdot z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{z \cdot \left(y \cdot z\right)}}{x} - \frac{\frac{1}{x}}{\left(y \cdot \left(z \cdot z\right)\right) \cdot \left(z \cdot z\right)}\\ \end{array}\]
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\begin{array}{l}
\mathbf{if}\;z \cdot z \le 9.274205810742728755895557522411157122625 \cdot 10^{229}:\\
\;\;\;\;\frac{\frac{\frac{1}{x}}{y \cdot \sqrt{1 + z \cdot z}}}{\sqrt{1 + z \cdot z}}\\

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

\end{array}
double f(double x, double y, double z) {
        double r15630173 = 1.0;
        double r15630174 = x;
        double r15630175 = r15630173 / r15630174;
        double r15630176 = y;
        double r15630177 = z;
        double r15630178 = r15630177 * r15630177;
        double r15630179 = r15630173 + r15630178;
        double r15630180 = r15630176 * r15630179;
        double r15630181 = r15630175 / r15630180;
        return r15630181;
}

double f(double x, double y, double z) {
        double r15630182 = z;
        double r15630183 = r15630182 * r15630182;
        double r15630184 = 9.274205810742729e+229;
        bool r15630185 = r15630183 <= r15630184;
        double r15630186 = 1.0;
        double r15630187 = x;
        double r15630188 = r15630186 / r15630187;
        double r15630189 = y;
        double r15630190 = r15630186 + r15630183;
        double r15630191 = sqrt(r15630190);
        double r15630192 = r15630189 * r15630191;
        double r15630193 = r15630188 / r15630192;
        double r15630194 = r15630193 / r15630191;
        double r15630195 = r15630189 * r15630182;
        double r15630196 = r15630182 * r15630195;
        double r15630197 = r15630186 / r15630196;
        double r15630198 = r15630197 / r15630187;
        double r15630199 = r15630189 * r15630183;
        double r15630200 = r15630199 * r15630183;
        double r15630201 = r15630188 / r15630200;
        double r15630202 = r15630198 - r15630201;
        double r15630203 = r15630185 ? r15630194 : r15630202;
        return r15630203;
}

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.2
Target5.4
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 z) < 9.274205810742729e+229

    1. Initial program 1.5

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

      \[\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.6

      \[\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 associate-/r*1.3

      \[\leadsto \color{blue}{\frac{\frac{\frac{1}{x}}{y \cdot \sqrt{1 + z \cdot z}}}{\sqrt{1 + z \cdot z}}}\]

    if 9.274205810742729e+229 < (* z z)

    1. Initial program 15.5

      \[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\]
    2. Using strategy rm
    3. Applied associate-/l/15.5

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

      \[\leadsto \color{blue}{1 \cdot \frac{1}{x \cdot \left({z}^{2} \cdot y\right)} - 1 \cdot \frac{1}{x \cdot \left({z}^{4} \cdot y\right)}}\]
    5. Simplified8.0

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

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

Reproduce

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