Average Error: 1.5 → 0.4
Time: 4.8s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
\[\begin{array}{l} t_0 := \frac{x + 4}{y}\\ t_1 := t_0 - \frac{x}{y} \cdot z\\ \mathbf{if}\;t_1 \leq -1.251895654907906 \cdot 10^{+181}:\\ \;\;\;\;\left|t_0 - {\left(\frac{\frac{y}{x}}{z}\right)}^{-1}\right|\\ \mathbf{elif}\;t_1 \leq 117100.00123213959:\\ \;\;\;\;\left|t_0 - \frac{x}{\frac{y}{z}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|t_0 - \frac{z}{\frac{y}{x}}\right|\\ \end{array} \]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
t_0 := \frac{x + 4}{y}\\
t_1 := t_0 - \frac{x}{y} \cdot z\\
\mathbf{if}\;t_1 \leq -1.251895654907906 \cdot 10^{+181}:\\
\;\;\;\;\left|t_0 - {\left(\frac{\frac{y}{x}}{z}\right)}^{-1}\right|\\

\mathbf{elif}\;t_1 \leq 117100.00123213959:\\
\;\;\;\;\left|t_0 - \frac{x}{\frac{y}{z}}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|t_0 - \frac{z}{\frac{y}{x}}\right|\\


\end{array}
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (+ x 4.0) y)) (t_1 (- t_0 (* (/ x y) z))))
   (if (<= t_1 -1.251895654907906e+181)
     (fabs (- t_0 (pow (/ (/ y x) z) -1.0)))
     (if (<= t_1 117100.00123213959)
       (fabs (- t_0 (/ x (/ y z))))
       (fabs (- t_0 (/ z (/ y x))))))))
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 t_0 = (x + 4.0) / y;
	double t_1 = t_0 - ((x / y) * z);
	double tmp;
	if (t_1 <= -1.251895654907906e+181) {
		tmp = fabs((t_0 - pow(((y / x) / z), -1.0)));
	} else if (t_1 <= 117100.00123213959) {
		tmp = fabs((t_0 - (x / (y / z))));
	} else {
		tmp = fabs((t_0 - (z / (y / x))));
	}
	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 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z)) < -1.251895654907906e181

    1. Initial program 0.1

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

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{z}{\frac{y}{x}}}\right| \]
    3. Applied egg-rr0.1

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

    if -1.251895654907906e181 < (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z)) < 117100.00123213959

    1. Initial program 2.6

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Applied egg-rr0.6

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

    if 117100.00123213959 < (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))

    1. Initial program 0.1

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

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

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

Reproduce

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