Average Error: 12.4 → 2.3
Time: 2.1s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.3343627764232323 \cdot 10^{30}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;x \le 1.1988184646526967 \cdot 10^{-249}:\\ \;\;\;\;\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 -1.3343627764232323 \cdot 10^{30}:\\
\;\;\;\;\frac{x}{\frac{z}{y + z}}\\

\mathbf{elif}\;x \le 1.1988184646526967 \cdot 10^{-249}:\\
\;\;\;\;\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 r446535 = x;
        double r446536 = y;
        double r446537 = z;
        double r446538 = r446536 + r446537;
        double r446539 = r446535 * r446538;
        double r446540 = r446539 / r446537;
        return r446540;
}

double f(double x, double y, double z) {
        double r446541 = x;
        double r446542 = -1.3343627764232323e+30;
        bool r446543 = r446541 <= r446542;
        double r446544 = z;
        double r446545 = y;
        double r446546 = r446545 + r446544;
        double r446547 = r446544 / r446546;
        double r446548 = r446541 / r446547;
        double r446549 = 1.1988184646526967e-249;
        bool r446550 = r446541 <= r446549;
        double r446551 = r446541 * r446545;
        double r446552 = r446551 / r446544;
        double r446553 = r446552 + r446541;
        double r446554 = r446546 / r446544;
        double r446555 = r446541 * r446554;
        double r446556 = r446550 ? r446553 : r446555;
        double r446557 = r446543 ? r446548 : r446556;
        return r446557;
}

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.4
Target3.0
Herbie2.3
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 3 regimes
  2. if x < -1.3343627764232323e+30

    1. Initial program 23.9

      \[\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 -1.3343627764232323e+30 < x < 1.1988184646526967e-249

    1. Initial program 5.6

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

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

    if 1.1988184646526967e-249 < x

    1. Initial program 13.3

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.3343627764232323 \cdot 10^{30}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;x \le 1.1988184646526967 \cdot 10^{-249}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \end{array}\]

Reproduce

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