Average Error: 12.3 → 2.9
Time: 13.7s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -8.3314135878818525418922407335108977686 \cdot 10^{-18}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \mathbf{elif}\;z \le 2.717641103527439173532310107215917032371 \cdot 10^{-184}:\\ \;\;\;\;\left(x \cdot \left(y + z\right)\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -8.3314135878818525418922407335108977686 \cdot 10^{-18}:\\
\;\;\;\;x \cdot \frac{y + z}{z}\\

\mathbf{elif}\;z \le 2.717641103527439173532310107215917032371 \cdot 10^{-184}:\\
\;\;\;\;\left(x \cdot \left(y + z\right)\right) \cdot \frac{1}{z}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{y + z}}\\

\end{array}
double f(double x, double y, double z) {
        double r301157 = x;
        double r301158 = y;
        double r301159 = z;
        double r301160 = r301158 + r301159;
        double r301161 = r301157 * r301160;
        double r301162 = r301161 / r301159;
        return r301162;
}

double f(double x, double y, double z) {
        double r301163 = z;
        double r301164 = -8.331413587881853e-18;
        bool r301165 = r301163 <= r301164;
        double r301166 = x;
        double r301167 = y;
        double r301168 = r301167 + r301163;
        double r301169 = r301168 / r301163;
        double r301170 = r301166 * r301169;
        double r301171 = 2.717641103527439e-184;
        bool r301172 = r301163 <= r301171;
        double r301173 = r301166 * r301168;
        double r301174 = 1.0;
        double r301175 = r301174 / r301163;
        double r301176 = r301173 * r301175;
        double r301177 = r301163 / r301168;
        double r301178 = r301166 / r301177;
        double r301179 = r301172 ? r301176 : r301178;
        double r301180 = r301165 ? r301170 : r301179;
        return r301180;
}

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

Original12.3
Target3.2
Herbie2.9
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 3 regimes
  2. if z < -8.331413587881853e-18

    1. Initial program 16.2

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

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

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

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

    if -8.331413587881853e-18 < z < 2.717641103527439e-184

    1. Initial program 7.6

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

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

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y + z}{z}}\]
    5. Simplified9.7

      \[\leadsto \color{blue}{x} \cdot \frac{y + z}{z}\]
    6. Using strategy rm
    7. Applied div-inv9.8

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

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

    if 2.717641103527439e-184 < z

    1. Initial program 12.7

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -8.3314135878818525418922407335108977686 \cdot 10^{-18}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \mathbf{elif}\;z \le 2.717641103527439173532310107215917032371 \cdot 10^{-184}:\\ \;\;\;\;\left(x \cdot \left(y + z\right)\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019325 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (/ x (/ z (+ y z)))

  (/ (* x (+ y z)) z))