Average Error: 12.4 → 1.8
Time: 5.4s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \leq -1.0527729931731066 \cdot 10^{+145}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \mathbf{elif}\;x \leq 1.386016132827874 \cdot 10^{-44}:\\ \;\;\;\;x + \frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;x \leq -1.0527729931731066 \cdot 10^{+145}:\\
\;\;\;\;x \cdot \frac{y + z}{z}\\

\mathbf{elif}\;x \leq 1.386016132827874 \cdot 10^{-44}:\\
\;\;\;\;x + \frac{x \cdot y}{z}\\

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
 :precision binary64
 (if (<= x -1.0527729931731066e+145)
   (* x (/ (+ y z) z))
   (if (<= x 1.386016132827874e-44) (+ x (/ (* x y) z)) (/ x (/ z (+ y z))))))
double code(double x, double y, double z) {
	return (x * (y + z)) / z;
}
double code(double x, double y, double z) {
	double tmp;
	if (x <= -1.0527729931731066e+145) {
		tmp = x * ((y + z) / z);
	} else if (x <= 1.386016132827874e-44) {
		tmp = x + ((x * y) / z);
	} else {
		tmp = x / (z / (y + z));
	}
	return tmp;
}

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

Derivation

  1. Split input into 3 regimes
  2. if x < -1.05277299317310665e145

    1. Initial program 37.5

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

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

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

    if -1.05277299317310665e145 < x < 1.386016132827874e-44

    1. Initial program 6.1

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

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

    if 1.386016132827874e-44 < x

    1. Initial program 19.5

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Simplified0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.0527729931731066 \cdot 10^{+145}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \mathbf{elif}\;x \leq 1.386016132827874 \cdot 10^{-44}:\\ \;\;\;\;x + \frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \end{array}\]

Reproduce

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