Average Error: 12.2 → 2.3
Time: 3.4s
Precision: binary64
\[\frac{x \cdot \left(y + z\right)}{z} \]
\[\begin{array}{l} t_0 := \mathsf{fma}\left(x, \frac{y}{z}, x\right)\\ \mathbf{if}\;z \leq -2.7 \cdot 10^{-139}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{-72}:\\ \;\;\;\;{\left(\sqrt[3]{x + \frac{x \cdot y}{z}}\right)}^{3}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fma x (/ y z) x)))
   (if (<= z -2.7e-139)
     t_0
     (if (<= z 4.1e-72) (pow (cbrt (+ x (/ (* x y) z))) 3.0) t_0))))
double code(double x, double y, double z) {
	return (x * (y + z)) / z;
}
double code(double x, double y, double z) {
	double t_0 = fma(x, (y / z), x);
	double tmp;
	if (z <= -2.7e-139) {
		tmp = t_0;
	} else if (z <= 4.1e-72) {
		tmp = pow(cbrt((x + ((x * y) / z))), 3.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y, z)
	return Float64(Float64(x * Float64(y + z)) / z)
end
function code(x, y, z)
	t_0 = fma(x, Float64(y / z), x)
	tmp = 0.0
	if (z <= -2.7e-139)
		tmp = t_0;
	elseif (z <= 4.1e-72)
		tmp = cbrt(Float64(x + Float64(Float64(x * y) / z))) ^ 3.0;
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y / z), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -2.7e-139], t$95$0, If[LessEqual[z, 4.1e-72], N[Power[N[Power[N[(x + N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision], t$95$0]]]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
t_0 := \mathsf{fma}\left(x, \frac{y}{z}, x\right)\\
\mathbf{if}\;z \leq -2.7 \cdot 10^{-139}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 4.1 \cdot 10^{-72}:\\
\;\;\;\;{\left(\sqrt[3]{x + \frac{x \cdot y}{z}}\right)}^{3}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original12.2
Target3.3
Herbie2.3
\[\frac{x}{\frac{z}{y + z}} \]

Derivation

  1. Split input into 2 regimes
  2. if z < -2.6999999999999998e-139 or 4.10000000000000003e-72 < z

    1. Initial program 13.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{y}{z}, x\right)} \]

    if -2.6999999999999998e-139 < z < 4.10000000000000003e-72

    1. Initial program 9.4

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

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

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\mathsf{fma}\left(x, \frac{y}{z}, x\right)}\right)}^{3}} \]
    4. Taylor expanded in y around 0 6.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.7 \cdot 10^{-139}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{y}{z}, x\right)\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{-72}:\\ \;\;\;\;{\left(\sqrt[3]{x + \frac{x \cdot y}{z}}\right)}^{3}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{y}{z}, x\right)\\ \end{array} \]

Reproduce

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