Average Error: 12.2 → 2.9
Time: 13.0s
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(x \cdot \left(z + y\right)\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(x \cdot \left(z + y\right)\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r22504633 = x;
        double r22504634 = y;
        double r22504635 = z;
        double r22504636 = r22504634 + r22504635;
        double r22504637 = r22504633 * r22504636;
        double r22504638 = r22504637 / r22504635;
        return r22504638;
}

double f(double x, double y, double z) {
        double r22504639 = z;
        double r22504640 = -4.927501217648652e-148;
        bool r22504641 = r22504639 <= r22504640;
        double r22504642 = x;
        double r22504643 = y;
        double r22504644 = r22504643 / r22504639;
        double r22504645 = 1.0;
        double r22504646 = r22504644 + r22504645;
        double r22504647 = r22504642 * r22504646;
        double r22504648 = 4.862339089142536e-99;
        bool r22504649 = r22504639 <= r22504648;
        double r22504650 = r22504645 / r22504639;
        double r22504651 = r22504639 + r22504643;
        double r22504652 = r22504642 * r22504651;
        double r22504653 = r22504650 * r22504652;
        double r22504654 = r22504649 ? r22504653 : r22504647;
        double r22504655 = r22504641 ? r22504647 : r22504654;
        return r22504655;
}

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 *-un-lft-identity9.2

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

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

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

      \[\leadsto x \cdot \color{blue}{\left(\left(y + z\right) \cdot \frac{1}{z}\right)}\]
    8. Applied associate-*r*9.3

      \[\leadsto \color{blue}{\left(x \cdot \left(y + z\right)\right) \cdot \frac{1}{z}}\]
  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(x \cdot \left(z + y\right)\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))