Average Error: 12.7 → 3.1
Time: 2.8s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;y \le 1.1715459163105659 \cdot 10^{110}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;y \le 1.12365834115160665 \cdot 10^{238}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;y \le 1.1715459163105659 \cdot 10^{110}:\\
\;\;\;\;\frac{x}{\frac{z}{y + z}}\\

\mathbf{elif}\;y \le 1.12365834115160665 \cdot 10^{238}:\\
\;\;\;\;\frac{x \cdot y}{z} + x\\

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

\end{array}
double f(double x, double y, double z) {
        double r516932 = x;
        double r516933 = y;
        double r516934 = z;
        double r516935 = r516933 + r516934;
        double r516936 = r516932 * r516935;
        double r516937 = r516936 / r516934;
        return r516937;
}

double f(double x, double y, double z) {
        double r516938 = y;
        double r516939 = 1.1715459163105659e+110;
        bool r516940 = r516938 <= r516939;
        double r516941 = x;
        double r516942 = z;
        double r516943 = r516938 + r516942;
        double r516944 = r516942 / r516943;
        double r516945 = r516941 / r516944;
        double r516946 = 1.1236583411516066e+238;
        bool r516947 = r516938 <= r516946;
        double r516948 = r516941 * r516938;
        double r516949 = r516948 / r516942;
        double r516950 = r516949 + r516941;
        double r516951 = r516943 / r516942;
        double r516952 = r516941 * r516951;
        double r516953 = r516947 ? r516950 : r516952;
        double r516954 = r516940 ? r516945 : r516953;
        return r516954;
}

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

Derivation

  1. Split input into 3 regimes
  2. if y < 1.1715459163105659e+110

    1. Initial program 12.8

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

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

    if 1.1715459163105659e+110 < y < 1.1236583411516066e+238

    1. Initial program 11.4

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

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

    if 1.1236583411516066e+238 < y

    1. Initial program 14.4

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity14.4

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

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y + z}{z}}\]
    5. Simplified14.9

      \[\leadsto \color{blue}{x} \cdot \frac{y + z}{z}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification3.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le 1.1715459163105659 \cdot 10^{110}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;y \le 1.12365834115160665 \cdot 10^{238}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \end{array}\]

Reproduce

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