Average Error: 6.6 → 2.5
Time: 12.6s
Precision: binary64
\[[x, y]=\mathsf{sort}([x, y])\]
\[\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}\]
\[\begin{array}{l} \mathbf{if}\;\frac{1}{x} \leq -410859949002324.94:\\ \;\;\;\;{\left(y \cdot \left(x + z \cdot \left(x \cdot z\right)\right)\right)}^{-1}\\ \mathbf{elif}\;\frac{1}{x} \leq 0.47775306239330895:\\ \;\;\;\;\frac{\frac{\frac{1}{x}}{y}}{1 + z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y}}{x + z \cdot \left(x \cdot z\right)}\\ \end{array}\]
\frac{\frac{1}{x}}{y \cdot \left(1 + z \cdot z\right)}
\begin{array}{l}
\mathbf{if}\;\frac{1}{x} \leq -410859949002324.94:\\
\;\;\;\;{\left(y \cdot \left(x + z \cdot \left(x \cdot z\right)\right)\right)}^{-1}\\

\mathbf{elif}\;\frac{1}{x} \leq 0.47775306239330895:\\
\;\;\;\;\frac{\frac{\frac{1}{x}}{y}}{1 + z \cdot z}\\

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (/ 1.0 x) (* y (+ 1.0 (* z z)))))
(FPCore (x y z)
 :precision binary64
 (if (<= (/ 1.0 x) -410859949002324.94)
   (pow (* y (+ x (* z (* x z)))) -1.0)
   (if (<= (/ 1.0 x) 0.47775306239330895)
     (/ (/ (/ 1.0 x) y) (+ 1.0 (* z z)))
     (/ (/ 1.0 y) (+ x (* z (* x z)))))))
double code(double x, double y, double z) {
	return (1.0 / x) / (y * (1.0 + (z * z)));
}
double code(double x, double y, double z) {
	double tmp;
	if ((1.0 / x) <= -410859949002324.94) {
		tmp = pow((y * (x + (z * (x * z)))), -1.0);
	} else if ((1.0 / x) <= 0.47775306239330895) {
		tmp = ((1.0 / x) / y) / (1.0 + (z * z));
	} else {
		tmp = (1.0 / y) / (x + (z * (x * z)));
	}
	return tmp;
}

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.6
Target5.2
Herbie2.5
\[\begin{array}{l} \mathbf{if}\;y \cdot \left(1 + z \cdot z\right) < -\infty:\\ \;\;\;\;\frac{\frac{1}{y}}{\left(1 + z \cdot z\right) \cdot x}\\ \mathbf{elif}\;y \cdot \left(1 + z \cdot z\right) < 8.680743250567252 \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 3 regimes
  2. if (/.f64 1 x) < -410859949002324.938

    1. Initial program 14.0

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

      \[\leadsto \frac{\frac{1}{\color{blue}{1 \cdot x}}}{y \cdot \left(1 + z \cdot z\right)}\]
    4. Applied add-sqr-sqrt_binary64_1067114.0

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

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

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

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

      \[\leadsto \frac{1}{y} \cdot \color{blue}{\frac{1}{x + x \cdot \left(z \cdot z\right)}}\]
    9. Using strategy rm
    10. Applied associate-*r*_binary64_105894.7

      \[\leadsto \frac{1}{y} \cdot \frac{1}{x + \color{blue}{\left(x \cdot z\right) \cdot z}}\]
    11. Using strategy rm
    12. Applied inv-pow_binary64_107344.7

      \[\leadsto \frac{1}{y} \cdot \color{blue}{{\left(x + \left(x \cdot z\right) \cdot z\right)}^{-1}}\]
    13. Applied inv-pow_binary64_107344.7

      \[\leadsto \color{blue}{{y}^{-1}} \cdot {\left(x + \left(x \cdot z\right) \cdot z\right)}^{-1}\]
    14. Applied pow-prod-down_binary64_107204.7

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

    if -410859949002324.938 < (/.f64 1 x) < 0.47775306239330895

    1. Initial program 1.9

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

      \[\leadsto \color{blue}{\frac{\frac{\frac{1}{x}}{y}}{1 + z \cdot z}}\]
    4. Simplified2.2

      \[\leadsto \frac{\color{blue}{\frac{1}{x \cdot y}}}{1 + z \cdot z}\]
    5. Using strategy rm
    6. Applied associate-/r*_binary64_105931.9

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

    if 0.47775306239330895 < (/.f64 1 x)

    1. Initial program 10.6

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

      \[\leadsto \frac{\frac{1}{\color{blue}{1 \cdot x}}}{y \cdot \left(1 + z \cdot z\right)}\]
    4. Applied add-sqr-sqrt_binary64_1067110.6

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

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

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

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

      \[\leadsto \frac{1}{y} \cdot \color{blue}{\frac{1}{x + x \cdot \left(z \cdot z\right)}}\]
    9. Using strategy rm
    10. Applied associate-*r*_binary64_105891.0

      \[\leadsto \frac{1}{y} \cdot \frac{1}{x + \color{blue}{\left(x \cdot z\right) \cdot z}}\]
    11. Using strategy rm
    12. Applied un-div-inv_binary64_106470.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{x} \leq -410859949002324.94:\\ \;\;\;\;{\left(y \cdot \left(x + z \cdot \left(x \cdot z\right)\right)\right)}^{-1}\\ \mathbf{elif}\;\frac{1}{x} \leq 0.47775306239330895:\\ \;\;\;\;\frac{\frac{\frac{1}{x}}{y}}{1 + z \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{y}}{x + z \cdot \left(x \cdot z\right)}\\ \end{array}\]

Reproduce

herbie shell --seed 2021090 
(FPCore (x y z)
  :name "Statistics.Distribution.CauchyLorentz:$cdensity from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (if (< (* y (+ 1.0 (* z z))) (- INFINITY)) (/ (/ 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)))))