Average Error: 13.1 → 1.8
Time: 3.0s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.9968229567179367 \cdot 10^{-62} \lor \neg \left(x \le 3.19439199967627457 \cdot 10^{-43}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \left(\frac{y}{\sqrt[3]{z}} \cdot x\right) + x\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;x \le -1.9968229567179367 \cdot 10^{-62} \lor \neg \left(x \le 3.19439199967627457 \cdot 10^{-43}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r407239 = x;
        double r407240 = y;
        double r407241 = z;
        double r407242 = r407240 + r407241;
        double r407243 = r407239 * r407242;
        double r407244 = r407243 / r407241;
        return r407244;
}

double f(double x, double y, double z) {
        double r407245 = x;
        double r407246 = -1.9968229567179367e-62;
        bool r407247 = r407245 <= r407246;
        double r407248 = 3.1943919996762746e-43;
        bool r407249 = r407245 <= r407248;
        double r407250 = !r407249;
        bool r407251 = r407247 || r407250;
        double r407252 = y;
        double r407253 = z;
        double r407254 = r407252 / r407253;
        double r407255 = fma(r407254, r407245, r407245);
        double r407256 = 1.0;
        double r407257 = cbrt(r407253);
        double r407258 = r407257 * r407257;
        double r407259 = r407256 / r407258;
        double r407260 = r407252 / r407257;
        double r407261 = r407260 * r407245;
        double r407262 = r407259 * r407261;
        double r407263 = r407262 + r407245;
        double r407264 = r407251 ? r407255 : r407263;
        return r407264;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original13.1
Target2.9
Herbie1.8
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -1.9968229567179367e-62 or 3.1943919996762746e-43 < x

    1. Initial program 19.2

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Simplified0.3

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{z}, x, x\right)}\]

    if -1.9968229567179367e-62 < x < 3.1943919996762746e-43

    1. Initial program 6.5

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Simplified6.3

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{z}, x, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef6.3

      \[\leadsto \color{blue}{\frac{y}{z} \cdot x + x}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt6.8

      \[\leadsto \frac{y}{\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}} \cdot x + x\]
    7. Applied *-un-lft-identity6.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.9968229567179367 \cdot 10^{-62} \lor \neg \left(x \le 3.19439199967627457 \cdot 10^{-43}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \left(\frac{y}{\sqrt[3]{z}} \cdot x\right) + x\\ \end{array}\]

Reproduce

herbie shell --seed 2020047 +o rules:numerics
(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))