Average Error: 12.2 → 2.9
Time: 11.4s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -4.927501217648652263168643426533032149503 \cdot 10^{-148}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} + 1\right)\\ \mathbf{elif}\;z \le 4.86233908914253570831760363524344817033 \cdot 10^{-99}:\\ \;\;\;\;\frac{1}{z} \cdot \left(\left(z + y\right) \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{y}{z} + 1\right)\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -4.927501217648652263168643426533032149503 \cdot 10^{-148}:\\
\;\;\;\;x \cdot \left(\frac{y}{z} + 1\right)\\

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

\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{y}{z} + 1\right)\\

\end{array}
double f(double x, double y, double z) {
        double r23490573 = x;
        double r23490574 = y;
        double r23490575 = z;
        double r23490576 = r23490574 + r23490575;
        double r23490577 = r23490573 * r23490576;
        double r23490578 = r23490577 / r23490575;
        return r23490578;
}

double f(double x, double y, double z) {
        double r23490579 = z;
        double r23490580 = -4.927501217648652e-148;
        bool r23490581 = r23490579 <= r23490580;
        double r23490582 = x;
        double r23490583 = y;
        double r23490584 = r23490583 / r23490579;
        double r23490585 = 1.0;
        double r23490586 = r23490584 + r23490585;
        double r23490587 = r23490582 * r23490586;
        double r23490588 = 4.862339089142536e-99;
        bool r23490589 = r23490579 <= r23490588;
        double r23490590 = r23490585 / r23490579;
        double r23490591 = r23490579 + r23490583;
        double r23490592 = r23490591 * r23490582;
        double r23490593 = r23490590 * r23490592;
        double r23490594 = r23490589 ? r23490593 : r23490587;
        double r23490595 = r23490581 ? r23490587 : r23490594;
        return r23490595;
}

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

Derivation

  1. Split input into 2 regimes
  2. if z < -4.927501217648652e-148 or 4.862339089142536e-99 < z

    1. Initial program 13.1

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

      \[\leadsto \frac{x \cdot \left(y + z\right)}{\color{blue}{1 \cdot z}}\]
    4. Applied times-frac1.0

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

      \[\leadsto \color{blue}{x} \cdot \frac{y + z}{z}\]
    6. Taylor expanded around 0 1.0

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

    if -4.927501217648652e-148 < z < 4.862339089142536e-99

    1. Initial program 9.2

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

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

      \[\leadsto \frac{x}{\color{blue}{z \cdot \frac{1}{y + z}}}\]
    6. Applied *-un-lft-identity10.7

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{z \cdot \frac{1}{y + z}}\]
    7. Applied times-frac9.3

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

      \[\leadsto \frac{1}{z} \cdot \color{blue}{\left(\left(y + z\right) \cdot x\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.9

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

Reproduce

herbie shell --seed 2019172 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"

  :herbie-target
  (/ x (/ z (+ y z)))

  (/ (* x (+ y z)) z))