Average Error: 1.5 → 0.2
Time: 5.2s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
\[\begin{array}{l} t_0 := \left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\\ \mathbf{if}\;t_0 \leq 5.149715951358518 \cdot 10^{-88}:\\ \;\;\;\;\left|\frac{x}{y} - \frac{\mathsf{fma}\left(x, z, -4\right)}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
t_0 := \left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\\
\mathbf{if}\;t_0 \leq 5.149715951358518 \cdot 10^{-88}:\\
\;\;\;\;\left|\frac{x}{y} - \frac{\mathsf{fma}\left(x, z, -4\right)}{y}\right|\\

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


\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 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z)))))
   (if (<= t_0 5.149715951358518e-88)
     (fabs (- (/ x y) (/ (fma x z -4.0) y)))
     t_0)))
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 = fabs(((x + 4.0) / y) - ((x / y) * z));
	double tmp;
	if (t_0 <= 5.149715951358518e-88) {
		tmp = fabs((x / y) - (fma(x, z, -4.0) / y));
	} else {
		tmp = t_0;
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Split input into 2 regimes
  2. if (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))) < 5.1497159513585182e-88

    1. Initial program 5.5

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

    if 5.1497159513585182e-88 < (fabs.f64 (-.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| \]
    2. Applied *-un-lft-identity_binary640.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \leq 5.149715951358518 \cdot 10^{-88}:\\ \;\;\;\;\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 2022104 
(FPCore (x y z)
  :name "fabs fraction 1"
  :precision binary64
  (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))