Average Error: 1.5 → 0.4
Time: 5.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}\;x \leq -1 \cdot 10^{+106}:\\ \;\;\;\;\left|t_0 - \frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \leq 2.211824109761336 \cdot 10^{-38}:\\ \;\;\;\;\left|\frac{x - \mathsf{fma}\left(z, x, -4\right)}{y}\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 (<= x -1e+106)
     (fabs (- t_0 (/ z (/ y x))))
     (if (<= x 2.211824109761336e-38)
       (fabs (/ (- x (fma z x -4.0)) y))
       (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 (x <= -1e+106) {
		tmp = fabs((t_0 - (z / (y / x))));
	} else if (x <= 2.211824109761336e-38) {
		tmp = fabs(((x - fma(z, x, -4.0)) / y));
	} 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 (x <= -1e+106)
		tmp = abs(Float64(t_0 - Float64(z / Float64(y / x))));
	elseif (x <= 2.211824109761336e-38)
		tmp = abs(Float64(Float64(x - fma(z, x, -4.0)) / y));
	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[x, -1e+106], N[Abs[N[(t$95$0 - N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 2.211824109761336e-38], N[Abs[N[(N[(x - N[(z * x + -4.0), $MachinePrecision]), $MachinePrecision] / y), $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}\;x \leq -1 \cdot 10^{+106}:\\
\;\;\;\;\left|t_0 - \frac{z}{\frac{y}{x}}\right|\\

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

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


\end{array}

Error

Derivation

  1. Split input into 3 regimes
  2. if x < -1.00000000000000009e106

    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| \]

    if -1.00000000000000009e106 < x < 2.21182410976133591e-38

    1. Initial program 2.2

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Taylor expanded in x around 0 5.3

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

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

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

    if 2.21182410976133591e-38 < x

    1. Initial program 0.1

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

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

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

Reproduce

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