Average Error: 12.1 → 2.4
Time: 7.2s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.016978897081638 \cdot 10^{-26}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \mathbf{elif}\;z \le -2.4206933261639595 \cdot 10^{-283}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \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 -1.016978897081638 \cdot 10^{-26}:\\
\;\;\;\;x \cdot \frac{y + z}{z}\\

\mathbf{elif}\;z \le -2.4206933261639595 \cdot 10^{-283}:\\
\;\;\;\;\frac{x \cdot y}{z} + x\\

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

\end{array}
double f(double x, double y, double z) {
        double r507837 = x;
        double r507838 = y;
        double r507839 = z;
        double r507840 = r507838 + r507839;
        double r507841 = r507837 * r507840;
        double r507842 = r507841 / r507839;
        return r507842;
}

double f(double x, double y, double z) {
        double r507843 = z;
        double r507844 = -1.016978897081638e-26;
        bool r507845 = r507843 <= r507844;
        double r507846 = x;
        double r507847 = y;
        double r507848 = r507847 + r507843;
        double r507849 = r507848 / r507843;
        double r507850 = r507846 * r507849;
        double r507851 = -2.4206933261639595e-283;
        bool r507852 = r507843 <= r507851;
        double r507853 = r507846 * r507847;
        double r507854 = r507853 / r507843;
        double r507855 = r507854 + r507846;
        double r507856 = r507843 / r507848;
        double r507857 = r507846 / r507856;
        double r507858 = r507852 ? r507855 : r507857;
        double r507859 = r507845 ? r507850 : r507858;
        return r507859;
}

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

Derivation

  1. Split input into 3 regimes
  2. if z < -1.016978897081638e-26

    1. Initial program 14.9

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

      \[\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 -1.016978897081638e-26 < z < -2.4206933261639595e-283

    1. Initial program 6.7

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

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

    if -2.4206933261639595e-283 < z

    1. Initial program 12.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.016978897081638 \cdot 10^{-26}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \mathbf{elif}\;z \le -2.4206933261639595 \cdot 10^{-283}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \end{array}\]

Reproduce

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