Average Error: 1.6 → 0.1
Time: 7.1min
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.58962761951495524 \cdot 10^{-18} \lor \neg \left(x \le 1.04021454216689316 \cdot 10^{-21}\right):\\ \;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{x \cdot z}{y}\right|\\ \end{array}\]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
\mathbf{if}\;x \le -2.58962761951495524 \cdot 10^{-18} \lor \neg \left(x \le 1.04021454216689316 \cdot 10^{-21}\right):\\
\;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\

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

\end{array}
double code(double x, double y, double z) {
	return ((double) fabs(((double) ((((double) (x + 4.0)) / y) - ((double) ((x / y) * z))))));
}
double code(double x, double y, double z) {
	double VAR;
	if (((x <= -2.5896276195149552e-18) || !(x <= 1.0402145421668932e-21))) {
		VAR = ((double) fabs(((double) ((((double) (x + 4.0)) / y) - ((double) (x * (z / y)))))));
	} else {
		VAR = ((double) fabs(((double) ((((double) (x + 4.0)) / y) - (((double) (x * z)) / y)))));
	}
	return VAR;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < -2.58962761951495524e-18 or 1.04021454216689316e-21 < x

    1. Initial program 0.2

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Using strategy rm
    3. Applied div-inv0.2

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\left(x \cdot \frac{1}{y}\right)} \cdot z\right|\]
    4. Applied associate-*l*0.2

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

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

    if -2.58962761951495524e-18 < x < 1.04021454216689316e-21

    1. Initial program 2.7

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Using strategy rm
    3. Applied associate-*l/0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.58962761951495524 \cdot 10^{-18} \lor \neg \left(x \le 1.04021454216689316 \cdot 10^{-21}\right):\\ \;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{x \cdot z}{y}\right|\\ \end{array}\]

Reproduce

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