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 r439584 = x;
        double r439585 = y;
        double r439586 = z;
        double r439587 = r439585 + r439586;
        double r439588 = r439584 * r439587;
        double r439589 = r439588 / r439586;
        return r439589;
}

double f(double x, double y, double z) {
        double r439590 = x;
        double r439591 = -7.650785111325439e-11;
        bool r439592 = r439590 <= r439591;
        double r439593 = z;
        double r439594 = y;
        double r439595 = r439594 + r439593;
        double r439596 = r439593 / r439595;
        double r439597 = r439590 / r439596;
        double r439598 = 1.2168599634495576e-147;
        bool r439599 = r439590 <= r439598;
        double r439600 = r439590 * r439594;
        double r439601 = r439600 / r439593;
        double r439602 = r439601 + r439590;
        double r439603 = r439595 / r439593;
        double r439604 = r439590 * r439603;
        double r439605 = r439599 ? r439602 : r439604;
        double r439606 = r439592 ? r439597 : r439605;
        return r439606;
}

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))