Average Error: 12.5 → 2.6
Time: 9.6s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -4.056144289794804798347970022182757266328 \cdot 10^{65}:\\ \;\;\;\;x \cdot \frac{y}{z} + x\\ \mathbf{elif}\;z \le 1.225720897419198623826645488615396096951 \cdot 10^{-260}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \mathbf{elif}\;z \le 7.922771623064943154406308622166351307166 \cdot 10^{-230}:\\ \;\;\;\;\frac{1}{\frac{\frac{z}{x}}{y}} + x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{\sqrt{z}} \cdot \left(\frac{y}{\sqrt{z}} \cdot x\right)\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -4.056144289794804798347970022182757266328 \cdot 10^{65}:\\
\;\;\;\;x \cdot \frac{y}{z} + x\\

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

\mathbf{elif}\;z \le 7.922771623064943154406308622166351307166 \cdot 10^{-230}:\\
\;\;\;\;\frac{1}{\frac{\frac{z}{x}}{y}} + x\\

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

\end{array}
double f(double x, double y, double z) {
        double r30306623 = x;
        double r30306624 = y;
        double r30306625 = z;
        double r30306626 = r30306624 + r30306625;
        double r30306627 = r30306623 * r30306626;
        double r30306628 = r30306627 / r30306625;
        return r30306628;
}

double f(double x, double y, double z) {
        double r30306629 = z;
        double r30306630 = -4.056144289794805e+65;
        bool r30306631 = r30306629 <= r30306630;
        double r30306632 = x;
        double r30306633 = y;
        double r30306634 = r30306633 / r30306629;
        double r30306635 = r30306632 * r30306634;
        double r30306636 = r30306635 + r30306632;
        double r30306637 = 1.2257208974191986e-260;
        bool r30306638 = r30306629 <= r30306637;
        double r30306639 = r30306632 * r30306633;
        double r30306640 = r30306639 / r30306629;
        double r30306641 = r30306640 + r30306632;
        double r30306642 = 7.922771623064943e-230;
        bool r30306643 = r30306629 <= r30306642;
        double r30306644 = 1.0;
        double r30306645 = r30306629 / r30306632;
        double r30306646 = r30306645 / r30306633;
        double r30306647 = r30306644 / r30306646;
        double r30306648 = r30306647 + r30306632;
        double r30306649 = sqrt(r30306629);
        double r30306650 = r30306644 / r30306649;
        double r30306651 = r30306633 / r30306649;
        double r30306652 = r30306651 * r30306632;
        double r30306653 = r30306650 * r30306652;
        double r30306654 = r30306632 + r30306653;
        double r30306655 = r30306643 ? r30306648 : r30306654;
        double r30306656 = r30306638 ? r30306641 : r30306655;
        double r30306657 = r30306631 ? r30306636 : r30306656;
        return r30306657;
}

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

Derivation

  1. Split input into 4 regimes
  2. if z < -4.056144289794805e+65

    1. Initial program 19.1

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} + x}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity7.0

      \[\leadsto \frac{x \cdot y}{\color{blue}{1 \cdot z}} + x\]
    5. Applied times-frac0.1

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y}{z}} + x\]
    6. Simplified0.1

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

    if -4.056144289794805e+65 < z < 1.2257208974191986e-260

    1. Initial program 6.4

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

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

    if 1.2257208974191986e-260 < z < 7.922771623064943e-230

    1. Initial program 10.8

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} + x}\]
    3. Using strategy rm
    4. Applied clear-num7.0

      \[\leadsto \color{blue}{\frac{1}{\frac{z}{x \cdot y}}} + x\]
    5. Using strategy rm
    6. Applied associate-/r*12.2

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

    if 7.922771623064943e-230 < z

    1. Initial program 13.2

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} + x}\]
    3. Using strategy rm
    4. Applied div-inv5.0

      \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot \frac{1}{z}} + x\]
    5. Using strategy rm
    6. Applied add-sqr-sqrt5.1

      \[\leadsto \left(x \cdot y\right) \cdot \frac{1}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}} + x\]
    7. Applied add-cube-cbrt5.1

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

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

      \[\leadsto \color{blue}{\left(\left(x \cdot y\right) \cdot \frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{z}}\right) \cdot \frac{\sqrt[3]{1}}{\sqrt{z}}} + x\]
    10. Simplified2.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -4.056144289794804798347970022182757266328 \cdot 10^{65}:\\ \;\;\;\;x \cdot \frac{y}{z} + x\\ \mathbf{elif}\;z \le 1.225720897419198623826645488615396096951 \cdot 10^{-260}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \mathbf{elif}\;z \le 7.922771623064943154406308622166351307166 \cdot 10^{-230}:\\ \;\;\;\;\frac{1}{\frac{\frac{z}{x}}{y}} + x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{\sqrt{z}} \cdot \left(\frac{y}{\sqrt{z}} \cdot x\right)\\ \end{array}\]

Reproduce

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