Average Error: 1.5 → 0.1
Time: 3.5s
Precision: 64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.5424594366857613 \cdot 10^{29}:\\ \;\;\;\;\left|\left(\left(4 \cdot \left(\sqrt[3]{\frac{1}{y}} \cdot \sqrt[3]{\frac{1}{y}}\right)\right) \cdot \sqrt[3]{\frac{1}{y}} + \frac{x}{y}\right) - \frac{x}{y} \cdot z\right|\\ \mathbf{elif}\;x \le 2.1896364681112564 \cdot 10^{-12}:\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{x \cdot z}{y}\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}\;x \le -1.5424594366857613 \cdot 10^{29}:\\
\;\;\;\;\left|\left(\left(4 \cdot \left(\sqrt[3]{\frac{1}{y}} \cdot \sqrt[3]{\frac{1}{y}}\right)\right) \cdot \sqrt[3]{\frac{1}{y}} + \frac{x}{y}\right) - \frac{x}{y} \cdot z\right|\\

\mathbf{elif}\;x \le 2.1896364681112564 \cdot 10^{-12}:\\
\;\;\;\;\left|\frac{x + 4}{y} - \frac{x \cdot z}{y}\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 <= -1.5424594366857613e+29)) {
		temp = fabs(((((4.0 * (cbrt((1.0 / y)) * cbrt((1.0 / y)))) * cbrt((1.0 / y))) + (x / y)) - ((x / y) * z)));
	} else {
		double temp_1;
		if ((x <= 2.1896364681112564e-12)) {
			temp_1 = fabs((((x + 4.0) / y) - ((x * z) / y)));
		} else {
			temp_1 = fabs((((x + 4.0) / y) - (x * (z / y))));
		}
		temp = temp_1;
	}
	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 3 regimes
  2. if x < -1.5424594366857613e+29

    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(4 \cdot \frac{1}{y} + \frac{x}{y}\right)} - \frac{x}{y} \cdot z\right|\]
    3. Using strategy rm
    4. Applied add-cube-cbrt0.1

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

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

    if -1.5424594366857613e+29 < x < 2.1896364681112564e-12

    1. Initial program 2.5

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Using strategy rm
    3. Applied associate-*l/0.1

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

    if 2.1896364681112564e-12 < x

    1. Initial program 0.2

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.5424594366857613 \cdot 10^{29}:\\ \;\;\;\;\left|\left(\left(4 \cdot \left(\sqrt[3]{\frac{1}{y}} \cdot \sqrt[3]{\frac{1}{y}}\right)\right) \cdot \sqrt[3]{\frac{1}{y}} + \frac{x}{y}\right) - \frac{x}{y} \cdot z\right|\\ \mathbf{elif}\;x \le 2.1896364681112564 \cdot 10^{-12}:\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\ \end{array}\]

Reproduce

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