Average Error: 12.7 → 2.0
Time: 3.2s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.025060815940221284599523414245967851062 \cdot 10^{-116} \lor \neg \left(x \le 2.664793329374929939202329816063701600281 \cdot 10^{-65}\right):\\ \;\;\;\;\frac{y}{z} \cdot x + 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}\;x \le -1.025060815940221284599523414245967851062 \cdot 10^{-116} \lor \neg \left(x \le 2.664793329374929939202329816063701600281 \cdot 10^{-65}\right):\\
\;\;\;\;\frac{y}{z} \cdot x + x\\

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

\end{array}
double f(double x, double y, double z) {
        double r388804 = x;
        double r388805 = y;
        double r388806 = z;
        double r388807 = r388805 + r388806;
        double r388808 = r388804 * r388807;
        double r388809 = r388808 / r388806;
        return r388809;
}

double f(double x, double y, double z) {
        double r388810 = x;
        double r388811 = -1.0250608159402213e-116;
        bool r388812 = r388810 <= r388811;
        double r388813 = 2.66479332937493e-65;
        bool r388814 = r388810 <= r388813;
        double r388815 = !r388814;
        bool r388816 = r388812 || r388815;
        double r388817 = y;
        double r388818 = z;
        double r388819 = r388817 / r388818;
        double r388820 = r388819 * r388810;
        double r388821 = r388820 + r388810;
        double r388822 = r388810 * r388817;
        double r388823 = 1.0;
        double r388824 = r388823 / r388818;
        double r388825 = r388822 * r388824;
        double r388826 = r388825 + r388810;
        double r388827 = r388816 ? r388821 : r388826;
        return r388827;
}

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

Derivation

  1. Split input into 2 regimes
  2. if x < -1.0250608159402213e-116 or 2.66479332937493e-65 < x

    1. Initial program 17.0

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

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

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

    if -1.0250608159402213e-116 < x < 2.66479332937493e-65

    1. Initial program 6.5

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{1} \cdot \left(\frac{\sqrt[3]{y}}{z} \cdot x\right)} + x\]
    10. Using strategy rm
    11. Applied associate-*l/3.4

      \[\leadsto \frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{1} \cdot \color{blue}{\frac{\sqrt[3]{y} \cdot x}{z}} + x\]
    12. Using strategy rm
    13. Applied div-inv3.4

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

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

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

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

Reproduce

herbie shell --seed 2019353 +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))