Average Error: 12.1 → 1.7
Time: 12.5s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(y + z\right) \cdot x}{z} \le 6.664392603785444 \cdot 10^{+27}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;\frac{\left(y + z\right) \cdot x}{z} \le 1.603991626425806 \cdot 10^{+271}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;\frac{\left(y + z\right) \cdot x}{z} \le 6.664392603785444 \cdot 10^{+27}:\\
\;\;\;\;\frac{x}{\frac{z}{y + z}}\\

\mathbf{elif}\;\frac{\left(y + z\right) \cdot x}{z} \le 1.603991626425806 \cdot 10^{+271}:\\
\;\;\;\;\frac{x \cdot y}{z} + x\\

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

\end{array}
double f(double x, double y, double z) {
        double r22709653 = x;
        double r22709654 = y;
        double r22709655 = z;
        double r22709656 = r22709654 + r22709655;
        double r22709657 = r22709653 * r22709656;
        double r22709658 = r22709657 / r22709655;
        return r22709658;
}

double f(double x, double y, double z) {
        double r22709659 = y;
        double r22709660 = z;
        double r22709661 = r22709659 + r22709660;
        double r22709662 = x;
        double r22709663 = r22709661 * r22709662;
        double r22709664 = r22709663 / r22709660;
        double r22709665 = 6.664392603785444e+27;
        bool r22709666 = r22709664 <= r22709665;
        double r22709667 = r22709660 / r22709661;
        double r22709668 = r22709662 / r22709667;
        double r22709669 = 1.603991626425806e+271;
        bool r22709670 = r22709664 <= r22709669;
        double r22709671 = r22709662 * r22709659;
        double r22709672 = r22709671 / r22709660;
        double r22709673 = r22709672 + r22709662;
        double r22709674 = r22709670 ? r22709673 : r22709668;
        double r22709675 = r22709666 ? r22709668 : r22709674;
        return r22709675;
}

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

Derivation

  1. Split input into 2 regimes
  2. if (/ (* x (+ y z)) z) < 6.664392603785444e+27 or 1.603991626425806e+271 < (/ (* x (+ y z)) z)

    1. Initial program 14.5

      \[\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 6.664392603785444e+27 < (/ (* x (+ y z)) z) < 1.603991626425806e+271

    1. Initial program 0.2

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Taylor expanded around 0 0.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(y + z\right) \cdot x}{z} \le 6.664392603785444 \cdot 10^{+27}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;\frac{\left(y + z\right) \cdot x}{z} \le 1.603991626425806 \cdot 10^{+271}:\\ \;\;\;\;\frac{x \cdot y}{z} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \end{array}\]

Reproduce

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