Average Error: 1.7 → 0.2
Time: 3.6s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
\[\begin{array}{l} \mathbf{if}\;x \leq -5.5 \cdot 10^{+64}:\\ \;\;\;\;\left|\frac{x}{y} - \frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\left|\frac{\mathsf{fma}\left(x, 1 - z, 4\right)}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\\ \end{array} \]
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
(FPCore (x y z)
 :precision binary64
 (if (<= x -5.5e+64)
   (fabs (- (/ x y) (/ z (/ y x))))
   (if (<= x 1.0)
     (fabs (/ (fma x (- 1.0 z) 4.0) y))
     (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))))
double code(double x, double y, double z) {
	return fabs((((x + 4.0) / y) - ((x / y) * z)));
}
double code(double x, double y, double z) {
	double tmp;
	if (x <= -5.5e+64) {
		tmp = fabs(((x / y) - (z / (y / x))));
	} else if (x <= 1.0) {
		tmp = fabs((fma(x, (1.0 - z), 4.0) / y));
	} else {
		tmp = fabs((((x + 4.0) / y) - ((x / y) * z)));
	}
	return tmp;
}
function code(x, y, z)
	return abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z)))
end
function code(x, y, z)
	tmp = 0.0
	if (x <= -5.5e+64)
		tmp = abs(Float64(Float64(x / y) - Float64(z / Float64(y / x))));
	elseif (x <= 1.0)
		tmp = abs(Float64(fma(x, Float64(1.0 - z), 4.0) / y));
	else
		tmp = abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z)));
	end
	return tmp
end
code[x_, y_, z_] := N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[x, -5.5e+64], N[Abs[N[(N[(x / y), $MachinePrecision] - N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.0], N[Abs[N[(N[(x * N[(1.0 - z), $MachinePrecision] + 4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
\mathbf{if}\;x \leq -5.5 \cdot 10^{+64}:\\
\;\;\;\;\left|\frac{x}{y} - \frac{z}{\frac{y}{x}}\right|\\

\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(x, 1 - z, 4\right)}{y}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\\


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Split input into 3 regimes
  2. if x < -5.4999999999999996e64

    1. Initial program 0.1

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Applied egg-rr0.1

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{z}{\frac{y}{x}}}\right| \]
    3. Taylor expanded in x around inf 0.1

      \[\leadsto \left|\color{blue}{\frac{x}{y}} - \frac{z}{\frac{y}{x}}\right| \]

    if -5.4999999999999996e64 < x < 1

    1. Initial program 2.5

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Applied egg-rr2.7

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{z}{\frac{y}{x}}}\right| \]
    3. Taylor expanded in x around 0 0.3

      \[\leadsto \left|\color{blue}{\left(\frac{x}{y} + 4 \cdot \frac{1}{y}\right) - \frac{z \cdot x}{y}}\right| \]
    4. Simplified0.3

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

    if 1 < x

    1. Initial program 0.1

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.5 \cdot 10^{+64}:\\ \;\;\;\;\left|\frac{x}{y} - \frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\left|\frac{\mathsf{fma}\left(x, 1 - z, 4\right)}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\\ \end{array} \]

Reproduce

herbie shell --seed 2022166 
(FPCore (x y z)
  :name "fabs fraction 1"
  :precision binary64
  (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))