Average Error: 12.4 → 1.8
Time: 13.4s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.506173955242470049044551297425952300751 \cdot 10^{-68} \lor \neg \left(z \le 3.06752064508004405517094747470919674471 \cdot 10^{-23}\right):\\ \;\;\;\;x \cdot \frac{y}{z} + x\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z} + x\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -2.506173955242470049044551297425952300751 \cdot 10^{-68} \lor \neg \left(z \le 3.06752064508004405517094747470919674471 \cdot 10^{-23}\right):\\
\;\;\;\;x \cdot \frac{y}{z} + x\\

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

\end{array}
double f(double x, double y, double z) {
        double r346212 = x;
        double r346213 = y;
        double r346214 = z;
        double r346215 = r346213 + r346214;
        double r346216 = r346212 * r346215;
        double r346217 = r346216 / r346214;
        return r346217;
}

double f(double x, double y, double z) {
        double r346218 = z;
        double r346219 = -2.50617395524247e-68;
        bool r346220 = r346218 <= r346219;
        double r346221 = 3.067520645080044e-23;
        bool r346222 = r346218 <= r346221;
        double r346223 = !r346222;
        bool r346224 = r346220 || r346223;
        double r346225 = x;
        double r346226 = y;
        double r346227 = r346226 / r346218;
        double r346228 = r346225 * r346227;
        double r346229 = r346228 + r346225;
        double r346230 = r346225 * r346226;
        double r346231 = 1.0;
        double r346232 = r346231 / r346218;
        double r346233 = r346230 * r346232;
        double r346234 = r346233 + r346225;
        double r346235 = r346224 ? r346229 : r346234;
        return r346235;
}

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

Derivation

  1. Split input into 2 regimes
  2. if z < -2.50617395524247e-68 or 3.067520645080044e-23 < z

    1. Initial program 14.8

      \[\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 *-un-lft-identity5.0

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

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

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

    if -2.50617395524247e-68 < z < 3.067520645080044e-23

    1. Initial program 7.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -2.506173955242470049044551297425952300751 \cdot 10^{-68} \lor \neg \left(z \le 3.06752064508004405517094747470919674471 \cdot 10^{-23}\right):\\ \;\;\;\;x \cdot \frac{y}{z} + x\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y\right) \cdot \frac{1}{z} + x\\ \end{array}\]

Reproduce

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