Average Error: 1.5 → 1.9
Time: 3.1s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;y \leq -1.7809107074403646 \cdot 10^{+111}:\\ \;\;\;\;\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 -1.7809107074403646 \cdot 10^{+111}:\\
\;\;\;\;\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 (<= y -1.7809107074403646e+111)
   (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 <= -1.7809107074403646e+111) {
		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 < -1.7809107074403646e111

    1. Initial program 3.2

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

      \[\leadsto \color{blue}{\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|}\]
    3. Using strategy rm
    4. Applied div-sub_binary646.8

      \[\leadsto \left|\color{blue}{\frac{x + 4}{y} - \frac{x \cdot z}{y}}\right|\]
    5. Using strategy rm
    6. Applied *-un-lft-identity_binary646.8

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

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

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

    if -1.7809107074403646e111 < y

    1. Initial program 1.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.7809107074403646 \cdot 10^{+111}:\\ \;\;\;\;\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 2020273 
(FPCore (x y z)
  :name "fabs fraction 1"
  :precision binary64
  (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))