Average Error: 1.4 → 2.3
Time: 9.9s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;y \le 4.2510798617965315 \cdot 10^{-152}:\\ \;\;\;\;\left|\frac{x + 4}{y} - \left(x \cdot z\right) \cdot \frac{1}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{\frac{y}{z}}\right|\\ \end{array}\]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
\mathbf{if}\;y \le 4.2510798617965315 \cdot 10^{-152}:\\
\;\;\;\;\left|\frac{x + 4}{y} - \left(x \cdot z\right) \cdot \frac{1}{y}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{\frac{y}{z}}\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 ((y <= 4.2510798617965315e-152)) {
		VAR = ((double) fabs(((double) (((double) (((double) (x + 4.0)) / y)) - ((double) (((double) (x * z)) * ((double) (1.0 / y))))))));
	} else {
		VAR = ((double) fabs(((double) (((double) (((double) (x + 4.0)) / y)) - ((double) (x / ((double) (y / z))))))));
	}
	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 y < 4.2510798617965315e-152

    1. Initial program 1.2

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

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right|\]
    4. Using strategy rm
    5. Applied div-inv3.0

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

    if 4.2510798617965315e-152 < y

    1. Initial program 1.7

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

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right|\]
    4. Using strategy rm
    5. Applied associate-/l*1.2

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

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

Reproduce

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