Average Error: 1.7 → 0.7
Time: 8.9s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \le -6.3586335028668337 \cdot 10^{78}:\\ \;\;\;\;\left|\frac{x + 4}{y} - z \cdot \frac{1}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \le 6.17940370842914209 \cdot 10^{-119}:\\ \;\;\;\;\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.3586335028668337 \cdot 10^{78}:\\
\;\;\;\;\left|\frac{x + 4}{y} - z \cdot \frac{1}{\frac{y}{x}}\right|\\

\mathbf{elif}\;x \le 6.17940370842914209 \cdot 10^{-119}:\\
\;\;\;\;\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) (x + 4.0)) / y) - ((double) ((x / y) * z))))));
}
double code(double x, double y, double z) {
	double VAR;
	if ((x <= -6.358633502866834e+78)) {
		VAR = ((double) fabs(((double) ((((double) (x + 4.0)) / y) - ((double) (z * (1.0 / (y / x))))))));
	} else {
		double VAR_1;
		if ((x <= 6.179403708429142e-119)) {
			VAR_1 = ((double) fabs((((double) (((double) (x + 4.0)) - ((double) (x * z)))) / y)));
		} else {
			VAR_1 = ((double) fabs(((double) ((((double) (x + 4.0)) / y) - ((double) (x * (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.3586335028668337e78

    1. Initial program 0.1

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

      \[\leadsto \left|\color{blue}{\frac{1}{\frac{y}{x + 4}}} - \frac{x}{y} \cdot z\right|\]
    4. Taylor expanded around 0 12.7

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

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

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

    if -6.3586335028668337e78 < x < 6.17940370842914209e-119

    1. Initial program 2.5

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

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

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

    if 6.17940370842914209e-119 < x

    1. Initial program 0.8

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

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

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

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

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