Average Error: 12.7 → 1.9
Time: 2.7s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -7.650785111325438631956082643378294801118 \cdot 10^{-11}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;x \le 1.216859963449557585469759774915782234926 \cdot 10^{-147}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;x \le -7.650785111325438631956082643378294801118 \cdot 10^{-11}:\\
\;\;\;\;\frac{x}{\frac{z}{y + z}}\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r529052 = x;
        double r529053 = y;
        double r529054 = z;
        double r529055 = r529053 + r529054;
        double r529056 = r529052 * r529055;
        double r529057 = r529056 / r529054;
        return r529057;
}

double f(double x, double y, double z) {
        double r529058 = x;
        double r529059 = -7.650785111325439e-11;
        bool r529060 = r529058 <= r529059;
        double r529061 = z;
        double r529062 = y;
        double r529063 = r529062 + r529061;
        double r529064 = r529061 / r529063;
        double r529065 = r529058 / r529064;
        double r529066 = 1.2168599634495576e-147;
        bool r529067 = r529058 <= r529066;
        double r529068 = r529058 * r529062;
        double r529069 = r529068 / r529061;
        double r529070 = r529069 + r529058;
        double r529071 = r529063 / r529061;
        double r529072 = r529058 * r529071;
        double r529073 = r529067 ? r529070 : r529072;
        double r529074 = r529060 ? r529065 : r529073;
        return r529074;
}

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

Derivation

  1. Split input into 3 regimes
  2. if x < -7.650785111325439e-11

    1. Initial program 22.6

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

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

    if -7.650785111325439e-11 < x < 1.2168599634495576e-147

    1. Initial program 6.0

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

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

    if 1.2168599634495576e-147 < x

    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-frac1.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -7.650785111325438631956082643378294801118 \cdot 10^{-11}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;x \le 1.216859963449557585469759774915782234926 \cdot 10^{-147}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \end{array}\]

Reproduce

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