Average Error: 12.5 → 1.8
Time: 11.1s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -3.551978784679197257345348304191645638639 \cdot 10^{-5} \lor \neg \left(x \le 3.607407530800736809062199940665984863568 \cdot 10^{-69}\right):\\ \;\;\;\;\frac{x}{\frac{-z}{-\left(z + y\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}} + x\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;x \le -3.551978784679197257345348304191645638639 \cdot 10^{-5} \lor \neg \left(x \le 3.607407530800736809062199940665984863568 \cdot 10^{-69}\right):\\
\;\;\;\;\frac{x}{\frac{-z}{-\left(z + y\right)}}\\

\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x}} + x\\

\end{array}
double f(double x, double y, double z) {
        double r389761 = x;
        double r389762 = y;
        double r389763 = z;
        double r389764 = r389762 + r389763;
        double r389765 = r389761 * r389764;
        double r389766 = r389765 / r389763;
        return r389766;
}

double f(double x, double y, double z) {
        double r389767 = x;
        double r389768 = -3.551978784679197e-05;
        bool r389769 = r389767 <= r389768;
        double r389770 = 3.607407530800737e-69;
        bool r389771 = r389767 <= r389770;
        double r389772 = !r389771;
        bool r389773 = r389769 || r389772;
        double r389774 = z;
        double r389775 = -r389774;
        double r389776 = y;
        double r389777 = r389774 + r389776;
        double r389778 = -r389777;
        double r389779 = r389775 / r389778;
        double r389780 = r389767 / r389779;
        double r389781 = r389774 / r389767;
        double r389782 = r389776 / r389781;
        double r389783 = r389782 + r389767;
        double r389784 = r389773 ? r389780 : r389783;
        return r389784;
}

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
Herbie1.8
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -3.551978784679197e-05 or 3.607407530800737e-69 < x

    1. Initial program 19.9

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Simplified0.3

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{z + y}}}\]
    5. Using strategy rm
    6. Applied frac-2neg0.3

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

    if -3.551978784679197e-05 < x < 3.607407530800737e-69

    1. Initial program 5.2

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Simplified6.0

      \[\leadsto \frac{x}{\color{blue}{\frac{z}{z + y}}}\]
    5. Taylor expanded around 0 2.7

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

      \[\leadsto \color{blue}{\frac{y \cdot x}{z} + x}\]
    7. Using strategy rm
    8. Applied associate-/l*3.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -3.551978784679197257345348304191645638639 \cdot 10^{-5} \lor \neg \left(x \le 3.607407530800736809062199940665984863568 \cdot 10^{-69}\right):\\ \;\;\;\;\frac{x}{\frac{-z}{-\left(z + y\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}} + x\\ \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))