Average Error: 1.4 → 0.1
Time: 4.4s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
\[\begin{array}{l} t_0 := \frac{x + 4}{y} - \frac{x}{y} \cdot z\\ t_1 := \left|t_0\right|\\ \mathbf{if}\;t_0 \leq -4.342490900678005 \cdot 10^{-20}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 1.6211268901314473 \cdot 10^{-72}:\\ \;\;\;\;\left|\frac{x}{y} - \frac{\mathsf{fma}\left(x, z, -4\right)}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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) (* (/ x y) z))) (t_1 (fabs t_0)))
   (if (<= t_0 -4.342490900678005e-20)
     t_1
     (if (<= t_0 1.6211268901314473e-72)
       (fabs (- (/ x y) (/ (fma x z -4.0) y)))
       t_1))))
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) - ((x / y) * z);
	double t_1 = fabs(t_0);
	double tmp;
	if (t_0 <= -4.342490900678005e-20) {
		tmp = t_1;
	} else if (t_0 <= 1.6211268901314473e-72) {
		tmp = fabs(((x / y) - (fma(x, z, -4.0) / y)));
	} else {
		tmp = t_1;
	}
	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(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z))
	t_1 = abs(t_0)
	tmp = 0.0
	if (t_0 <= -4.342490900678005e-20)
		tmp = t_1;
	elseif (t_0 <= 1.6211268901314473e-72)
		tmp = abs(Float64(Float64(x / y) - Float64(fma(x, z, -4.0) / y)));
	else
		tmp = t_1;
	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[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Abs[t$95$0], $MachinePrecision]}, If[LessEqual[t$95$0, -4.342490900678005e-20], t$95$1, If[LessEqual[t$95$0, 1.6211268901314473e-72], N[Abs[N[(N[(x / y), $MachinePrecision] - N[(N[(x * z + -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
t_0 := \frac{x + 4}{y} - \frac{x}{y} \cdot z\\
t_1 := \left|t_0\right|\\
\mathbf{if}\;t_0 \leq -4.342490900678005 \cdot 10^{-20}:\\
\;\;\;\;t_1\\

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

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Split input into 2 regimes
  2. if (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z)) < -4.34249090067800473e-20 or 1.62112689013145e-72 < (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))

    1. Initial program 0.2

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

    if -4.34249090067800473e-20 < (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z)) < 1.62112689013145e-72

    1. Initial program 4.1

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

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

      \[\leadsto \left|\color{blue}{\frac{x}{y} - \frac{\mathsf{fma}\left(x, z, -4\right)}{y}}\right| \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

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

Reproduce

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