Average Error: 1.6 → 0.9
Time: 5.9s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;y \leq -4.4593506574680894 \cdot 10^{+108} \lor \neg \left(y \leq 2.987582394727669 \cdot 10^{+125}\right):\\ \;\;\;\;\left|\frac{1}{\sqrt[3]{y} \cdot \sqrt[3]{y}} \cdot \frac{x + 4}{\sqrt[3]{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 -4.4593506574680894 \cdot 10^{+108} \lor \neg \left(y \leq 2.987582394727669 \cdot 10^{+125}\right):\\
\;\;\;\;\left|\frac{1}{\sqrt[3]{y} \cdot \sqrt[3]{y}} \cdot \frac{x + 4}{\sqrt[3]{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 -4.4593506574680894e+108) (not (<= y 2.987582394727669e+125)))
   (fabs
    (- (* (/ 1.0 (* (cbrt y) (cbrt y))) (/ (+ x 4.0) (cbrt 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 <= -4.4593506574680894e+108) || !(y <= 2.987582394727669e+125)) {
		tmp = fabs(((1.0 / (cbrt(y) * cbrt(y))) * ((x + 4.0) / cbrt(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 < -4.4593506574680894e108 or 2.98758239472766907e125 < y

    1. Initial program 3.8

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

      \[\leadsto \left|\frac{x + 4}{\color{blue}{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y}}} - \frac{x}{y} \cdot z\right|\]
    4. Applied *-un-lft-identity_binary644.6

      \[\leadsto \left|\frac{\color{blue}{1 \cdot \left(x + 4\right)}}{\left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right) \cdot \sqrt[3]{y}} - \frac{x}{y} \cdot z\right|\]
    5. Applied times-frac_binary644.6

      \[\leadsto \left|\color{blue}{\frac{1}{\sqrt[3]{y} \cdot \sqrt[3]{y}} \cdot \frac{x + 4}{\sqrt[3]{y}}} - \frac{x}{y} \cdot z\right|\]
    6. Using strategy rm
    7. Applied div-inv_binary644.6

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

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

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

    if -4.4593506574680894e108 < y < 2.98758239472766907e125

    1. Initial program 0.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.4593506574680894 \cdot 10^{+108} \lor \neg \left(y \leq 2.987582394727669 \cdot 10^{+125}\right):\\ \;\;\;\;\left|\frac{1}{\sqrt[3]{y} \cdot \sqrt[3]{y}} \cdot \frac{x + 4}{\sqrt[3]{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 2020268 
(FPCore (x y z)
  :name "fabs fraction 1"
  :precision binary64
  (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))