Average Error: 12.6 → 2.3
Time: 3.4s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \le 1.77403602642187274 \cdot 10^{-307} \lor \neg \left(x \le 6.014723915304812 \cdot 10^{-32}\right):\\ \;\;\;\;x + x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{x}{z}\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;x \le 1.77403602642187274 \cdot 10^{-307} \lor \neg \left(x \le 6.014723915304812 \cdot 10^{-32}\right):\\
\;\;\;\;x + x \cdot \frac{y}{z}\\

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

\end{array}
double code(double x, double y, double z) {
	return ((double) (((double) (x * ((double) (y + z)))) / z));
}
double code(double x, double y, double z) {
	double VAR;
	if (((x <= 1.7740360264218727e-307) || !(x <= 6.014723915304812e-32))) {
		VAR = ((double) (x + ((double) (x * ((double) (y / z))))));
	} else {
		VAR = ((double) (x + ((double) (y * ((double) (x / 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.6
Target2.9
Herbie2.3
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < 1.77403602642187274e-307 or 6.014723915304812e-32 < x

    1. Initial program 15.1

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

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

    if 1.77403602642187274e-307 < x < 6.014723915304812e-32

    1. Initial program 5.9

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

      \[\leadsto \color{blue}{x + x \cdot \frac{y}{z}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt6.5

      \[\leadsto x + x \cdot \frac{y}{\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}}\]
    5. Applied *-un-lft-identity6.5

      \[\leadsto x + x \cdot \frac{\color{blue}{1 \cdot y}}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}\]
    6. Applied times-frac6.5

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

      \[\leadsto x + \color{blue}{\left(x \cdot \frac{1}{\sqrt[3]{z} \cdot \sqrt[3]{z}}\right) \cdot \frac{y}{\sqrt[3]{z}}}\]
    8. Simplified3.5

      \[\leadsto x + \color{blue}{\frac{x}{\sqrt[3]{z} \cdot \sqrt[3]{z}}} \cdot \frac{y}{\sqrt[3]{z}}\]
    9. Taylor expanded around 0 3.3

      \[\leadsto x + \color{blue}{\frac{x \cdot y}{z}}\]
    10. Simplified2.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 1.77403602642187274 \cdot 10^{-307} \lor \neg \left(x \le 6.014723915304812 \cdot 10^{-32}\right):\\ \;\;\;\;x + x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{x}{z}\\ \end{array}\]

Reproduce

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