Average Error: 1.7 → 0.1
Time: 2.9s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.80615219986552692 \cdot 10^{-4}:\\ \;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \le 3.91743995991523077 \cdot 10^{31}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\\ \end{array}\]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
\mathbf{if}\;x \le -2.80615219986552692 \cdot 10^{-4}:\\
\;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\

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

\mathbf{else}:\\
\;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{y} \cdot 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 ((x <= -0.0002806152199865527)) {
		VAR = ((double) fabs(((double) (((double) (((double) (x + 4.0)) / y)) - ((double) (x * ((double) (z / y))))))));
	} else {
		double VAR_1;
		if ((x <= 3.9174399599152308e+31)) {
			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) (((double) (x / y)) * z))))));
		}
		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 < -2.80615219986552692e-4

    1. Initial program 0.1

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

      \[\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.1

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

    if -2.80615219986552692e-4 < x < 3.91743995991523077e31

    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|\]

    if 3.91743995991523077e31 < x

    1. Initial program 0.1

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

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

Reproduce

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