Average Error: 12.4 → 2.9
Time: 11.0s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.5447905988096068 \cdot 10^{-136}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;z \le 1.5164738101784048 \cdot 10^{-21}:\\ \;\;\;\;\left(x \cdot \left(y + z\right)\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -1.5447905988096068 \cdot 10^{-136}:\\
\;\;\;\;\frac{x}{\frac{z}{y + z}}\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r450636 = x;
        double r450637 = y;
        double r450638 = z;
        double r450639 = r450637 + r450638;
        double r450640 = r450636 * r450639;
        double r450641 = r450640 / r450638;
        return r450641;
}

double f(double x, double y, double z) {
        double r450642 = z;
        double r450643 = -1.5447905988096068e-136;
        bool r450644 = r450642 <= r450643;
        double r450645 = x;
        double r450646 = y;
        double r450647 = r450646 + r450642;
        double r450648 = r450642 / r450647;
        double r450649 = r450645 / r450648;
        double r450650 = 1.5164738101784048e-21;
        bool r450651 = r450642 <= r450650;
        double r450652 = r450645 * r450647;
        double r450653 = 1.0;
        double r450654 = r450653 / r450642;
        double r450655 = r450652 * r450654;
        double r450656 = r450647 / r450642;
        double r450657 = r450645 * r450656;
        double r450658 = r450651 ? r450655 : r450657;
        double r450659 = r450644 ? r450649 : r450658;
        return r450659;
}

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.4
Target3.0
Herbie2.9
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 3 regimes
  2. if z < -1.5447905988096068e-136

    1. Initial program 13.1

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

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

    if -1.5447905988096068e-136 < z < 1.5164738101784048e-21

    1. Initial program 8.3

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

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

    if 1.5164738101784048e-21 < z

    1. Initial program 15.6

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

      \[\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}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.9

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

Reproduce

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