Average Error: 1.6 → 0.4
Time: 2.6s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \le -3.2470651805444677 \cdot 10^{59} \lor \neg \left(x \le 5.4138098491585839 \cdot 10^{-131}\right):\\ \;\;\;\;\left|\frac{4}{y} + \frac{x}{y} \cdot \left(1 - z\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + \left(4 - x \cdot z\right)}{y}\right|\\ \end{array}\]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
\mathbf{if}\;x \le -3.2470651805444677 \cdot 10^{59} \lor \neg \left(x \le 5.4138098491585839 \cdot 10^{-131}\right):\\
\;\;\;\;\left|\frac{4}{y} + \frac{x}{y} \cdot \left(1 - z\right)\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{x + \left(4 - x \cdot z\right)}{y}\right|\\

\end{array}
double code(double x, double y, double z) {
	return ((double) fabs(((double) (((double) (((double) (x + 4.0)) / y)) - ((double) (((double) (x / y)) * z))))));
}
double code(double x, double y, double z) {
	double VAR;
	if (((x <= -3.2470651805444677e+59) || !(x <= 5.413809849158584e-131))) {
		VAR = ((double) fabs(((double) (((double) (4.0 / y)) + ((double) (((double) (x / y)) * ((double) (1.0 - z))))))));
	} else {
		VAR = ((double) fabs(((double) (((double) (x + ((double) (4.0 - ((double) (x * z)))))) / y))));
	}
	return VAR;
}

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 x < -3.2470651805444677e59 or 5.4138098491585839e-131 < x

    1. Initial program 0.7

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

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

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

    if -3.2470651805444677e59 < x < 5.4138098491585839e-131

    1. Initial program 2.3

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

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right|\]
    4. Applied sub-div0.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -3.2470651805444677 \cdot 10^{59} \lor \neg \left(x \le 5.4138098491585839 \cdot 10^{-131}\right):\\ \;\;\;\;\left|\frac{4}{y} + \frac{x}{y} \cdot \left(1 - z\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + \left(4 - x \cdot z\right)}{y}\right|\\ \end{array}\]

Reproduce

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