Average Error: 1.6 → 0.6
Time: 3.9s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
\[\begin{array}{l} t_0 := \frac{x + 4}{y}\\ \mathbf{if}\;y \leq -1 \cdot 10^{-22}:\\ \;\;\;\;\left|t_0 - x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;y \leq 10^{-150}:\\ \;\;\;\;\left|{\left(\frac{y}{\mathsf{fma}\left(x, z, -4\right) - x}\right)}^{-1}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|t_0 - \frac{x}{\frac{y}{z}}\right|\\ \end{array} \]
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (+ x 4.0) y)))
   (if (<= y -1e-22)
     (fabs (- t_0 (* x (/ z y))))
     (if (<= y 1e-150)
       (fabs (pow (/ y (- (fma x z -4.0) x)) -1.0))
       (fabs (- t_0 (/ 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 t_0 = (x + 4.0) / y;
	double tmp;
	if (y <= -1e-22) {
		tmp = fabs((t_0 - (x * (z / y))));
	} else if (y <= 1e-150) {
		tmp = fabs(pow((y / (fma(x, z, -4.0) - x)), -1.0));
	} else {
		tmp = fabs((t_0 - (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)
	t_0 = Float64(Float64(x + 4.0) / y)
	tmp = 0.0
	if (y <= -1e-22)
		tmp = abs(Float64(t_0 - Float64(x * Float64(z / y))));
	elseif (y <= 1e-150)
		tmp = abs((Float64(y / Float64(fma(x, z, -4.0) - x)) ^ -1.0));
	else
		tmp = abs(Float64(t_0 - Float64(x / Float64(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_] := Block[{t$95$0 = N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[y, -1e-22], N[Abs[N[(t$95$0 - N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[y, 1e-150], N[Abs[N[Power[N[(y / N[(N[(x * z + -4.0), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision], N[Abs[N[(t$95$0 - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
t_0 := \frac{x + 4}{y}\\
\mathbf{if}\;y \leq -1 \cdot 10^{-22}:\\
\;\;\;\;\left|t_0 - x \cdot \frac{z}{y}\right|\\

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

\mathbf{else}:\\
\;\;\;\;\left|t_0 - \frac{x}{\frac{y}{z}}\right|\\


\end{array}

Error

Derivation

  1. Split input into 3 regimes
  2. if y < -1e-22

    1. Initial program 2.2

      \[\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{x}{\frac{y}{z}}}\right| \]
    3. Applied egg-rr0.2

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

    if -1e-22 < y < 1.00000000000000001e-150

    1. Initial program 0.1

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

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

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

    if 1.00000000000000001e-150 < y

    1. Initial program 2.0

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

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

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

Reproduce

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