Average Error: 1.6 → 0.8
Time: 5.0s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \leq -5.282705680863495 \cdot 10^{-194} \lor \neg \left(x \leq 3.375223685948184 \cdot 10^{+19}\right):\\ \;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\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 \leq -5.282705680863495 \cdot 10^{-194} \lor \neg \left(x \leq 3.375223685948184 \cdot 10^{+19}\right):\\
\;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\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) (x + 4.0)) / y) - ((double) ((x / y) * z))))));
}
double code(double x, double y, double z) {
	double VAR;
	if (((x <= -5.282705680863495e-194) || !(x <= 3.375223685948184e+19))) {
		VAR = ((double) fabs(((double) ((((double) (x + 4.0)) / y) - ((double) (x * (z / y)))))));
	} else {
		VAR = ((double) fabs((((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 < -5.2827056808634953e-194 or 33752236859481842000 < x

    1. Initial program 0.9

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

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

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

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

    if -5.2827056808634953e-194 < x < 33752236859481842000

    1. Initial program 2.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.282705680863495 \cdot 10^{-194} \lor \neg \left(x \leq 3.375223685948184 \cdot 10^{+19}\right):\\ \;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + \left(4 - x \cdot z\right)}{y}\right|\\ \end{array}\]

Reproduce

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