Average Error: 12.4 → 1.2
Time: 2.8s
Precision: 64
\[\frac{x \cdot \left(y + z\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le 6.8455758493201267 \cdot 10^{-274}:\\ \;\;\;\;\frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \left(\frac{\sqrt[3]{y}}{\sqrt[3]{z}} \cdot x\right) + x\\ \mathbf{elif}\;z \le 2.39214907321889172 \cdot 10^{23}:\\ \;\;\;\;\frac{y \cdot x}{z} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x + x\\ \end{array}\]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le 6.8455758493201267 \cdot 10^{-274}:\\
\;\;\;\;\frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \left(\frac{\sqrt[3]{y}}{\sqrt[3]{z}} \cdot x\right) + x\\

\mathbf{elif}\;z \le 2.39214907321889172 \cdot 10^{23}:\\
\;\;\;\;\frac{y \cdot x}{z} + x\\

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

\end{array}
double code(double x, double y, double z) {
	return ((x * (y + z)) / z);
}
double code(double x, double y, double z) {
	double VAR;
	if ((z <= 6.845575849320127e-274)) {
		VAR = ((((cbrt(y) * cbrt(y)) / (cbrt(z) * cbrt(z))) * ((cbrt(y) / cbrt(z)) * x)) + x);
	} else {
		double VAR_1;
		if ((z <= 2.3921490732188917e+23)) {
			VAR_1 = (((y * x) / z) + x);
		} else {
			VAR_1 = (((y / z) * x) + x);
		}
		VAR = VAR_1;
	}
	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
Target2.9
Herbie1.2
\[\frac{x}{\frac{z}{y + z}}\]

Derivation

  1. Split input into 3 regimes
  2. if z < 6.845575849320127e-274

    1. Initial program 12.9

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{z}, x, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef3.3

      \[\leadsto \color{blue}{\frac{y}{z} \cdot x + x}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt3.7

      \[\leadsto \frac{y}{\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}} \cdot x + x\]
    7. Applied add-cube-cbrt3.8

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

      \[\leadsto \color{blue}{\left(\frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \frac{\sqrt[3]{y}}{\sqrt[3]{z}}\right)} \cdot x + x\]
    9. Applied associate-*l*1.2

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

    if 6.845575849320127e-274 < z < 2.3921490732188917e+23

    1. Initial program 5.3

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{z}, x, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef6.3

      \[\leadsto \color{blue}{\frac{y}{z} \cdot x + x}\]
    5. Using strategy rm
    6. Applied associate-*l/2.7

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

    if 2.3921490732188917e+23 < z

    1. Initial program 16.9

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y}{z}, x, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le 6.8455758493201267 \cdot 10^{-274}:\\ \;\;\;\;\frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot \left(\frac{\sqrt[3]{y}}{\sqrt[3]{z}} \cdot x\right) + x\\ \mathbf{elif}\;z \le 2.39214907321889172 \cdot 10^{23}:\\ \;\;\;\;\frac{y \cdot x}{z} + x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot x + x\\ \end{array}\]

Reproduce

herbie shell --seed 2020102 +o rules:numerics
(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))