Average Error: 12.2 → 3.5
Time: 2.3s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;y \leq -7.430130491561406 \cdot 10^{+46}:\\ \;\;\;\;\frac{x}{z} \cdot \left(y + z\right)\\ \mathbf{elif}\;y \leq 1.1477876828940585 \cdot 10^{+239}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot x}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;y \leq -7.430130491561406 \cdot 10^{+46}:\\
\;\;\;\;\frac{x}{z} \cdot \left(y + z\right)\\

\mathbf{elif}\;y \leq 1.1477876828940585 \cdot 10^{+239}:\\
\;\;\;\;\frac{x}{\frac{z}{y + z}}\\

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
 :precision binary64
 (if (<= y -7.430130491561406e+46)
   (* (/ x z) (+ y z))
   (if (<= y 1.1477876828940585e+239)
     (/ x (/ z (+ y z)))
     (+ x (/ (* y x) 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 (y <= -7.430130491561406e+46) {
		tmp = (x / z) * (y + z);
	} else if (y <= 1.1477876828940585e+239) {
		tmp = x / (z / (y + z));
	} else {
		tmp = x + ((y * x) / 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.2
Target3.0
Herbie3.5
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 3 regimes
  2. if y < -7.4301304915614058e46

    1. Initial program 13.0

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

      \[\leadsto \color{blue}{\frac{x}{\frac{z}{y + z}}}\]
    4. Using strategy rm
    5. Applied associate-/r/_binary6410.6

      \[\leadsto \color{blue}{\frac{x}{z} \cdot \left(y + z\right)}\]

    if -7.4301304915614058e46 < y < 1.1477876828940585e239

    1. Initial program 11.8

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

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

    if 1.1477876828940585e239 < y

    1. Initial program 16.4

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{z} + x}\]
    3. Simplified16.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7.430130491561406 \cdot 10^{+46}:\\ \;\;\;\;\frac{x}{z} \cdot \left(y + z\right)\\ \mathbf{elif}\;y \leq 1.1477876828940585 \cdot 10^{+239}:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot x}{z}\\ \end{array}\]

Reproduce

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