Average Error: 1.7 → 0.1
Time: 3.1s
Precision: 64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;\frac{x + 4}{y} - \frac{x}{y} \cdot z \le -9.58651736767009604 \cdot 10^{-35} \lor \neg \left(\frac{x + 4}{y} - \frac{x}{y} \cdot z \le 2.7981691915432765 \cdot 10^{-34}\right):\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\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}\;\frac{x + 4}{y} - \frac{x}{y} \cdot z \le -9.58651736767009604 \cdot 10^{-35} \lor \neg \left(\frac{x + 4}{y} - \frac{x}{y} \cdot z \le 2.7981691915432765 \cdot 10^{-34}\right):\\
\;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\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 fabs((((x + 4.0) / y) - ((x / y) * z)));
}
double code(double x, double y, double z) {
	double temp;
	if ((((((x + 4.0) / y) - ((x / y) * z)) <= -9.586517367670096e-35) || !((((x + 4.0) / y) - ((x / y) * z)) <= 2.7981691915432765e-34))) {
		temp = fabs((((x + 4.0) / y) - ((x / y) * z)));
	} else {
		temp = fabs((((x + 4.0) / y) - (x * (z / y))));
	}
	return temp;
}

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 4.0) y) (* (/ x y) z)) < -9.586517367670096e-35 or 2.7981691915432765e-34 < (- (/ (+ x 4.0) y) (* (/ x y) z))

    1. Initial program 0.1

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

    if -9.586517367670096e-35 < (- (/ (+ x 4.0) y) (* (/ x y) z)) < 2.7981691915432765e-34

    1. Initial program 4.8

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

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

      \[\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|\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + 4}{y} - \frac{x}{y} \cdot z \le -9.58651736767009604 \cdot 10^{-35} \lor \neg \left(\frac{x + 4}{y} - \frac{x}{y} \cdot z \le 2.7981691915432765 \cdot 10^{-34}\right):\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\ \end{array}\]

Reproduce

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