Average Error: 1.5 → 0.2
Time: 6.7s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \leq -2.8755087116004516 \cdot 10^{-15}:\\ \;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 4.7579917362672096 \cdot 10^{+24}:\\ \;\;\;\;\left|\frac{\left(\frac{4}{y} - \frac{x}{y}\right) \cdot \left(y \cdot \left(\frac{4}{y} + \frac{x}{y}\right) - x \cdot z\right)}{y \cdot \left(\frac{4}{y} - \frac{x}{y}\right)}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\left(\frac{x}{y} + 4 \cdot \frac{1}{y}\right) - z \cdot \frac{x}{y}\right|\\ \end{array}\]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
\mathbf{if}\;x \leq -2.8755087116004516 \cdot 10^{-15}:\\
\;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\

\mathbf{elif}\;x \leq 4.7579917362672096 \cdot 10^{+24}:\\
\;\;\;\;\left|\frac{\left(\frac{4}{y} - \frac{x}{y}\right) \cdot \left(y \cdot \left(\frac{4}{y} + \frac{x}{y}\right) - x \cdot z\right)}{y \cdot \left(\frac{4}{y} - \frac{x}{y}\right)}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\left(\frac{x}{y} + 4 \cdot \frac{1}{y}\right) - z \cdot \frac{x}{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 (<= x -2.8755087116004516e-15)
   (fabs (- (/ (+ x 4.0) y) (* x (/ z y))))
   (if (<= x 4.7579917362672096e+24)
     (fabs
      (/
       (* (- (/ 4.0 y) (/ x y)) (- (* y (+ (/ 4.0 y) (/ x y))) (* x z)))
       (* y (- (/ 4.0 y) (/ x y)))))
     (fabs (- (+ (/ x y) (* 4.0 (/ 1.0 y))) (* z (/ x 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 (x <= -2.8755087116004516e-15) {
		tmp = fabs(((x + 4.0) / y) - (x * (z / y)));
	} else if (x <= 4.7579917362672096e+24) {
		tmp = fabs((((4.0 / y) - (x / y)) * ((y * ((4.0 / y) + (x / y))) - (x * z))) / (y * ((4.0 / y) - (x / y))));
	} else {
		tmp = fabs(((x / y) + (4.0 * (1.0 / y))) - (z * (x / 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 3 regimes
  2. if x < -2.8755087116004516e-15

    1. Initial program 0.1

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

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\left(x \cdot \frac{1}{y}\right)} \cdot z\right|\]
    4. Applied associate-*l*_binary64_190.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|\]

    if -2.8755087116004516e-15 < x < 4.75799173626720961e24

    1. Initial program 2.4

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Taylor expanded around 0 2.4

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

      \[\leadsto \left|\color{blue}{\left(\frac{4}{y} + \frac{x}{y}\right)} - \frac{x}{y} \cdot z\right|\]
    4. Using strategy rm
    5. Applied associate-*l/_binary64_210.2

      \[\leadsto \left|\left(\frac{4}{y} + \frac{x}{y}\right) - \color{blue}{\frac{x \cdot z}{y}}\right|\]
    6. Applied flip-+_binary64_5225.7

      \[\leadsto \left|\color{blue}{\frac{\frac{4}{y} \cdot \frac{4}{y} - \frac{x}{y} \cdot \frac{x}{y}}{\frac{4}{y} - \frac{x}{y}}} - \frac{x \cdot z}{y}\right|\]
    7. Applied frac-sub_binary64_8725.8

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

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

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

    if 4.75799173626720961e24 < x

    1. Initial program 0.1

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Taylor expanded around 0 0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.8755087116004516 \cdot 10^{-15}:\\ \;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 4.7579917362672096 \cdot 10^{+24}:\\ \;\;\;\;\left|\frac{\left(\frac{4}{y} - \frac{x}{y}\right) \cdot \left(y \cdot \left(\frac{4}{y} + \frac{x}{y}\right) - x \cdot z\right)}{y \cdot \left(\frac{4}{y} - \frac{x}{y}\right)}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\left(\frac{x}{y} + 4 \cdot \frac{1}{y}\right) - z \cdot \frac{x}{y}\right|\\ \end{array}\]

Reproduce

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