Average Error: 12.4 → 1.7
Time: 3.3s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \leq -7.161731230796641 \cdot 10^{+48} \lor \neg \left(x \leq 2.3321824048372046 \cdot 10^{-101}\right):\\ \;\;\;\;x + x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \left(x \cdot y\right) \cdot \frac{1}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;x \leq -7.161731230796641 \cdot 10^{+48} \lor \neg \left(x \leq 2.3321824048372046 \cdot 10^{-101}\right):\\
\;\;\;\;x + x \cdot \frac{y}{z}\\

\mathbf{else}:\\
\;\;\;\;x + \left(x \cdot y\right) \cdot \frac{1}{z}\\

\end{array}
double code(double x, double y, double z) {
	return (((double) (x * ((double) (y + z)))) / z);
}
double code(double x, double y, double z) {
	double VAR;
	if (((x <= -7.161731230796641e+48) || !(x <= 2.3321824048372046e-101))) {
		VAR = ((double) (x + ((double) (x * (y / z)))));
	} else {
		VAR = ((double) (x + ((double) (((double) (x * y)) * (1.0 / z)))));
	}
	return VAR;
}

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

Derivation

  1. Split input into 2 regimes
  2. if x < -7.161731230796641e48 or 2.33218240483720457e-101 < x

    1. Initial program 20.5

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Simplified0.5

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

    if -7.161731230796641e48 < x < 2.33218240483720457e-101

    1. Initial program 5.3

      \[\frac{x \cdot \left(y + z\right)}{z}\]
    2. Simplified5.6

      \[\leadsto \color{blue}{x + x \cdot \frac{y}{z}}\]
    3. Using strategy rm
    4. Applied div-inv5.6

      \[\leadsto x + x \cdot \color{blue}{\left(y \cdot \frac{1}{z}\right)}\]
    5. Applied associate-*r*2.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7.161731230796641 \cdot 10^{+48} \lor \neg \left(x \leq 2.3321824048372046 \cdot 10^{-101}\right):\\ \;\;\;\;x + x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \left(x \cdot y\right) \cdot \frac{1}{z}\\ \end{array}\]

Reproduce

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