Average Error: 12.3 → 1.7
Time: 7.7s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -5104496756807823400959889660759009918976:\\ \;\;\;\;\frac{x}{\frac{z}{y}} + x\\ \mathbf{elif}\;z \le 1.097856366012339157215663859472876118082 \cdot 10^{-51}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\frac{z}{y}}{x}} + x\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -5104496756807823400959889660759009918976:\\
\;\;\;\;\frac{x}{\frac{z}{y}} + x\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r332515 = x;
        double r332516 = y;
        double r332517 = z;
        double r332518 = r332516 + r332517;
        double r332519 = r332515 * r332518;
        double r332520 = r332519 / r332517;
        return r332520;
}

double f(double x, double y, double z) {
        double r332521 = z;
        double r332522 = -5.1044967568078234e+39;
        bool r332523 = r332521 <= r332522;
        double r332524 = x;
        double r332525 = y;
        double r332526 = r332521 / r332525;
        double r332527 = r332524 / r332526;
        double r332528 = r332527 + r332524;
        double r332529 = 1.0978563660123392e-51;
        bool r332530 = r332521 <= r332529;
        double r332531 = r332524 * r332525;
        double r332532 = 1.0;
        double r332533 = r332532 / r332521;
        double r332534 = r332531 * r332533;
        double r332535 = r332534 + r332524;
        double r332536 = r332526 / r332524;
        double r332537 = r332532 / r332536;
        double r332538 = r332537 + r332524;
        double r332539 = r332530 ? r332535 : r332538;
        double r332540 = r332523 ? r332528 : r332539;
        return r332540;
}

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.1
Herbie1.7
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 3 regimes
  2. if z < -5.1044967568078234e+39

    1. Initial program 18.4

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Taylor expanded around 0 6.0

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} + x}\]
    3. Using strategy rm
    4. Applied associate-/l*0.0

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

    if -5.1044967568078234e+39 < z < 1.0978563660123392e-51

    1. Initial program 7.1

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Taylor expanded around 0 3.6

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} + x}\]
    3. Using strategy rm
    4. Applied div-inv3.7

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

    if 1.0978563660123392e-51 < z

    1. Initial program 14.5

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Taylor expanded around 0 4.8

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} + x}\]
    3. Using strategy rm
    4. Applied associate-/l*0.2

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} + x\]
    5. Using strategy rm
    6. Applied clear-num0.3

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

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

Reproduce

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