Average Error: 1.5 → 0.2
Time: 3.3s
Precision: 64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.2385186491081033 \cdot 10^{-6} \lor \neg \left(x \le 2.5989146979654925 \cdot 10^{-79}\right):\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\left(\left(x + 4\right) - x \cdot z\right) \cdot \frac{1}{y}\right|\\ \end{array}\]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
\mathbf{if}\;x \le -1.2385186491081033 \cdot 10^{-6} \lor \neg \left(x \le 2.5989146979654925 \cdot 10^{-79}\right):\\
\;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\\

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

\end{array}
double code(double x, double y, double z) {
	return ((double) fabs(((double) (((double) (((double) (x + 4.0)) / y)) - ((double) (((double) (x / y)) * z))))));
}
double code(double x, double y, double z) {
	double VAR;
	if (((x <= -1.2385186491081033e-06) || !(x <= 2.5989146979654925e-79))) {
		VAR = ((double) fabs(((double) (((double) (((double) (x + 4.0)) / y)) - ((double) (((double) (x / y)) * z))))));
	} else {
		VAR = ((double) fabs(((double) (((double) (((double) (x + 4.0)) - ((double) (x * z)))) * ((double) (1.0 / 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 < -1.2385186491081033e-06 or 2.5989146979654925e-79 < x

    1. Initial program 0.3

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

    if -1.2385186491081033e-06 < x < 2.5989146979654925e-79

    1. Initial program 2.6

      \[\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|\]
    4. Applied sub-div0.1

      \[\leadsto \left|\color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}}\right|\]
    5. Using strategy rm
    6. Applied div-inv0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.2385186491081033 \cdot 10^{-6} \lor \neg \left(x \le 2.5989146979654925 \cdot 10^{-79}\right):\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\left(\left(x + 4\right) - x \cdot z\right) \cdot \frac{1}{y}\right|\\ \end{array}\]

Reproduce

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