Average Error: 12.1 → 1.9
Time: 2.5s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \leq -1.0453651096244319 \cdot 10^{-38} \lor \neg \left(x \leq 1.6296836021789269 \cdot 10^{-167}\right):\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{x \cdot y}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;x \leq -1.0453651096244319 \cdot 10^{-38} \lor \neg \left(x \leq 1.6296836021789269 \cdot 10^{-167}\right):\\
\;\;\;\;x \cdot \frac{y + z}{z}\\

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -1.0453651096244319e-38) (not (<= x 1.6296836021789269e-167)))
   (* x (/ (+ y z) z))
   (+ x (/ (* x 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.0453651096244319e-38) || !(x <= 1.6296836021789269e-167)) {
		tmp = x * ((y + z) / z);
	} else {
		tmp = x + ((x * 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.1
Target2.9
Herbie1.9
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -1.04536510962443192e-38 or 1.6296836021789269e-167 < x

    1. Initial program 15.8

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

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

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

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

    if -1.04536510962443192e-38 < x < 1.6296836021789269e-167

    1. Initial program 6.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.0453651096244319 \cdot 10^{-38} \lor \neg \left(x \leq 1.6296836021789269 \cdot 10^{-167}\right):\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{x \cdot y}{z}\\ \end{array}\]

Reproduce

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