Average Error: 6.4 → 4.2
Time: 13.7s
Precision: 64
\[\frac{\frac{1.0}{x}}{y \cdot \left(1.0 + z \cdot z\right)}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.2727104958862755 \cdot 10^{+34}:\\ \;\;\;\;\frac{\frac{1.0}{\left(y \cdot z\right) \cdot z} - \frac{\frac{1.0}{y}}{\left(z \cdot z\right) \cdot \left(z \cdot z\right)}}{x}\\ \mathbf{elif}\;z \le 2.57842419165539 \cdot 10^{+190}:\\ \;\;\;\;\frac{\frac{\frac{1.0}{1.0 + z \cdot z}}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1.0}{\left(y \cdot z\right) \cdot z} - \frac{\frac{1.0}{y}}{\left(z \cdot z\right) \cdot \left(z \cdot z\right)}}{x}\\ \end{array}\]
\frac{\frac{1.0}{x}}{y \cdot \left(1.0 + z \cdot z\right)}
\begin{array}{l}
\mathbf{if}\;z \le -1.2727104958862755 \cdot 10^{+34}:\\
\;\;\;\;\frac{\frac{1.0}{\left(y \cdot z\right) \cdot z} - \frac{\frac{1.0}{y}}{\left(z \cdot z\right) \cdot \left(z \cdot z\right)}}{x}\\

\mathbf{elif}\;z \le 2.57842419165539 \cdot 10^{+190}:\\
\;\;\;\;\frac{\frac{\frac{1.0}{1.0 + z \cdot z}}{y}}{x}\\

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

\end{array}
double f(double x, double y, double z) {
        double r17726379 = 1.0;
        double r17726380 = x;
        double r17726381 = r17726379 / r17726380;
        double r17726382 = y;
        double r17726383 = z;
        double r17726384 = r17726383 * r17726383;
        double r17726385 = r17726379 + r17726384;
        double r17726386 = r17726382 * r17726385;
        double r17726387 = r17726381 / r17726386;
        return r17726387;
}

double f(double x, double y, double z) {
        double r17726388 = z;
        double r17726389 = -1.2727104958862755e+34;
        bool r17726390 = r17726388 <= r17726389;
        double r17726391 = 1.0;
        double r17726392 = y;
        double r17726393 = r17726392 * r17726388;
        double r17726394 = r17726393 * r17726388;
        double r17726395 = r17726391 / r17726394;
        double r17726396 = r17726391 / r17726392;
        double r17726397 = r17726388 * r17726388;
        double r17726398 = r17726397 * r17726397;
        double r17726399 = r17726396 / r17726398;
        double r17726400 = r17726395 - r17726399;
        double r17726401 = x;
        double r17726402 = r17726400 / r17726401;
        double r17726403 = 2.57842419165539e+190;
        bool r17726404 = r17726388 <= r17726403;
        double r17726405 = r17726391 + r17726397;
        double r17726406 = r17726391 / r17726405;
        double r17726407 = r17726406 / r17726392;
        double r17726408 = r17726407 / r17726401;
        double r17726409 = r17726404 ? r17726408 : r17726402;
        double r17726410 = r17726390 ? r17726402 : r17726409;
        return r17726410;
}

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.4
Target5.8
Herbie4.2
\[\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.2727104958862755e+34 or 2.57842419165539e+190 < z

    1. Initial program 13.6

      \[\frac{\frac{1.0}{x}}{y \cdot \left(1.0 + z \cdot z\right)}\]
    2. Using strategy rm
    3. Applied div-inv13.6

      \[\leadsto \color{blue}{\frac{1.0}{x} \cdot \frac{1}{y \cdot \left(1.0 + z \cdot z\right)}}\]
    4. Using strategy rm
    5. Applied associate-*l/13.6

      \[\leadsto \color{blue}{\frac{1.0 \cdot \frac{1}{y \cdot \left(1.0 + z \cdot z\right)}}{x}}\]
    6. Simplified13.4

      \[\leadsto \frac{\color{blue}{\frac{\frac{1.0}{1.0 + z \cdot z}}{y}}}{x}\]
    7. Taylor expanded around inf 13.6

      \[\leadsto \frac{\color{blue}{1.0 \cdot \frac{1}{{z}^{2} \cdot y} - 1.0 \cdot \frac{1}{{z}^{4} \cdot y}}}{x}\]
    8. Simplified7.4

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

    if -1.2727104958862755e+34 < z < 2.57842419165539e+190

    1. Initial program 2.7

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

      \[\leadsto \color{blue}{\frac{1.0}{x} \cdot \frac{1}{y \cdot \left(1.0 + z \cdot z\right)}}\]
    4. Using strategy rm
    5. Applied associate-*l/2.7

      \[\leadsto \color{blue}{\frac{1.0 \cdot \frac{1}{y \cdot \left(1.0 + z \cdot z\right)}}{x}}\]
    6. Simplified2.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.2727104958862755 \cdot 10^{+34}:\\ \;\;\;\;\frac{\frac{1.0}{\left(y \cdot z\right) \cdot z} - \frac{\frac{1.0}{y}}{\left(z \cdot z\right) \cdot \left(z \cdot z\right)}}{x}\\ \mathbf{elif}\;z \le 2.57842419165539 \cdot 10^{+190}:\\ \;\;\;\;\frac{\frac{\frac{1.0}{1.0 + z \cdot z}}{y}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1.0}{\left(y \cdot z\right) \cdot z} - \frac{\frac{1.0}{y}}{\left(z \cdot z\right) \cdot \left(z \cdot z\right)}}{x}\\ \end{array}\]

Reproduce

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