Average Error: 11.5 → 2.7
Time: 14.0s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(y + z\right) \cdot x}{z} = -\infty:\\ \;\;\;\;x + \frac{x}{z} \cdot y\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{x}}{z} \cdot \left(\sqrt[3]{x} \cdot \left(\sqrt[3]{x} \cdot y\right)\right) + x\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;\frac{\left(y + z\right) \cdot x}{z} = -\infty:\\
\;\;\;\;x + \frac{x}{z} \cdot y\\

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

\end{array}
double f(double x, double y, double z) {
        double r22858330 = x;
        double r22858331 = y;
        double r22858332 = z;
        double r22858333 = r22858331 + r22858332;
        double r22858334 = r22858330 * r22858333;
        double r22858335 = r22858334 / r22858332;
        return r22858335;
}

double f(double x, double y, double z) {
        double r22858336 = y;
        double r22858337 = z;
        double r22858338 = r22858336 + r22858337;
        double r22858339 = x;
        double r22858340 = r22858338 * r22858339;
        double r22858341 = r22858340 / r22858337;
        double r22858342 = -inf.0;
        bool r22858343 = r22858341 <= r22858342;
        double r22858344 = r22858339 / r22858337;
        double r22858345 = r22858344 * r22858336;
        double r22858346 = r22858339 + r22858345;
        double r22858347 = cbrt(r22858339);
        double r22858348 = r22858347 / r22858337;
        double r22858349 = r22858347 * r22858336;
        double r22858350 = r22858347 * r22858349;
        double r22858351 = r22858348 * r22858350;
        double r22858352 = r22858351 + r22858339;
        double r22858353 = r22858343 ? r22858346 : r22858352;
        return r22858353;
}

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

Original11.5
Target2.9
Herbie2.7
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if (/ (* x (+ y z)) z) < -inf.0

    1. Initial program 59.8

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

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

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

    if -inf.0 < (/ (* x (+ y z)) z)

    1. Initial program 7.8

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

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

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

      \[\leadsto y \cdot \frac{x}{\color{blue}{1 \cdot z}} + x\]
    7. Applied add-cube-cbrt5.4

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(y + z\right) \cdot x}{z} = -\infty:\\ \;\;\;\;x + \frac{x}{z} \cdot y\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{x}}{z} \cdot \left(\sqrt[3]{x} \cdot \left(\sqrt[3]{x} \cdot y\right)\right) + x\\ \end{array}\]

Reproduce

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