Average Error: 1.7 → 0.4
Time: 2.7s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \le -6.5593496857007722 \cdot 10^{96}:\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right) + 4 \cdot \frac{1}{y}\right|\\ \mathbf{elif}\;x \le 9.384126219788447 \cdot 10^{-33}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\ \end{array}\]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
\mathbf{if}\;x \le -6.5593496857007722 \cdot 10^{96}:\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right) + 4 \cdot \frac{1}{y}\right|\\

\mathbf{elif}\;x \le 9.384126219788447 \cdot 10^{-33}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{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 <= -6.559349685700772e+96)) {
		VAR = ((double) fabs(((double) (((double) (((double) (x / y)) * ((double) (1.0 - z)))) + ((double) (4.0 * ((double) (1.0 / y))))))));
	} else {
		double VAR_1;
		if ((x <= 9.384126219788447e-33)) {
			VAR_1 = ((double) fabs(((double) (((double) (((double) (x + 4.0)) - ((double) (x * z)))) / y))));
		} else {
			VAR_1 = ((double) fabs(((double) (((double) (((double) (x + 4.0)) / y)) - ((double) (x * ((double) (z / y))))))));
		}
		VAR = VAR_1;
	}
	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 3 regimes
  2. if x < -6.5593496857007722e96

    1. Initial program 0.1

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Taylor expanded around 0 12.2

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

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

    if -6.5593496857007722e96 < x < 9.384126219788447e-33

    1. Initial program 2.4

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

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right|\]
    4. Applied sub-div0.5

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

    if 9.384126219788447e-33 < 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.3

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

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

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

Reproduce

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