Average Error: 1.5 → 0.7
Time: 5.4s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;y \leq -3.1242606810193704 \cdot 10^{+132} \lor \neg \left(y \leq 1.9976429913566016 \cdot 10^{-69}\right):\\ \;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \end{array}\]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
\mathbf{if}\;y \leq -3.1242606810193704 \cdot 10^{+132} \lor \neg \left(y \leq 1.9976429913566016 \cdot 10^{-69}\right):\\
\;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\

\end{array}
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -3.1242606810193704e+132) (not (<= y 1.9976429913566016e-69)))
   (fabs (- (/ (+ x 4.0) y) (* x (/ z y))))
   (fabs (/ (- (+ x 4.0) (* x z)) y))))
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 tmp;
	if ((y <= -3.1242606810193704e+132) || !(y <= 1.9976429913566016e-69)) {
		tmp = fabs(((x + 4.0) / y) - (x * (z / y)));
	} else {
		tmp = fabs(((x + 4.0) - (x * z)) / y);
	}
	return tmp;
}

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 < -3.12428e132 or 1.99763e-69 < y

    1. Initial program 2.6

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

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

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

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

    if -3.12428e132 < y < 1.99763e-69

    1. Initial program 0.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.1242606810193704 \cdot 10^{+132} \lor \neg \left(y \leq 1.9976429913566016 \cdot 10^{-69}\right):\\ \;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \end{array}\]

Reproduce

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