Average Error: 1.7 → 0.1
Time: 2.6s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \leq -22348263.607269768 \lor \neg \left(x \leq 6.128532177682799 \cdot 10^{+19}\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 \leq -22348263.607269768 \lor \neg \left(x \leq 6.128532177682799 \cdot 10^{+19}\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}
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -22348263.607269768) (not (<= x 6.128532177682799e+19)))
   (fabs (+ (/ 4.0 y) (* (/ x y) (- 1.0 z))))
   (fabs (/ (+ x (- 4.0 (* x z))) y))))
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 <= -22348263.607269768) || !(x <= 6.128532177682799e+19))) {
		VAR = ((double) fabs(((double) ((4.0 / y) + ((double) ((x / y) * ((double) (1.0 - z))))))));
	} 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 < -22348263.6072697677 or 61285321776827990000 < x

    1. Initial program 0.1

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

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

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

    if -22348263.6072697677 < x < 61285321776827990000

    1. Initial program 2.7

      \[\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.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -22348263.607269768 \lor \neg \left(x \leq 6.128532177682799 \cdot 10^{+19}\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 2020198 
(FPCore (x y z)
  :name "fabs fraction 1"
  :precision binary64
  (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))