Average Error: 1.6 → 0.3
Time: 4.0s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \leq -1.160409340095365 \cdot 10^{-34}:\\ \;\;\;\;\left|\frac{x + 4}{y} - x \cdot \left(\frac{1}{y} \cdot z\right)\right|\\ \mathbf{elif}\;x \leq 4.6080437301362304 \cdot 10^{-68}:\\ \;\;\;\;\left|\frac{1}{\frac{y}{4 + \left(x - x \cdot z\right)}}\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 \leq -1.160409340095365 \cdot 10^{-34}:\\
\;\;\;\;\left|\frac{x + 4}{y} - x \cdot \left(\frac{1}{y} \cdot z\right)\right|\\

\mathbf{elif}\;x \leq 4.6080437301362304 \cdot 10^{-68}:\\
\;\;\;\;\left|\frac{1}{\frac{y}{4 + \left(x - x \cdot z\right)}}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{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 (<= x -1.160409340095365e-34)
   (fabs (- (/ (+ x 4.0) y) (* x (* (/ 1.0 y) z))))
   (if (<= x 4.6080437301362304e-68)
     (fabs (/ 1.0 (/ y (+ 4.0 (- x (* x z))))))
     (fabs (- (/ (+ x 4.0) y) (* x (/ z y)))))))
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 tmp;
	if (x <= -1.160409340095365e-34) {
		tmp = fabs(((x + 4.0) / y) - (x * ((1.0 / y) * z)));
	} else if (x <= 4.6080437301362304e-68) {
		tmp = fabs(1.0 / (y / (4.0 + (x - (x * z)))));
	} else {
		tmp = fabs(((x + 4.0) / y) - (x * (z / y)));
	}
	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 x < -1.16040934009536494e-34

    1. Initial program 0.2

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

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

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

    if -1.16040934009536494e-34 < x < 4.60804373013623043e-68

    1. Initial program 2.8

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

      \[\leadsto \color{blue}{\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|}\]
    3. Using strategy rm
    4. Applied clear-num_binary640.1

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

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

    if 4.60804373013623043e-68 < x

    1. Initial program 0.2

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

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

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

      \[\leadsto \left|\frac{x + 4}{y} - x \cdot \color{blue}{\frac{z}{y}}\right|\]
    6. Using strategy rm
    7. Applied *-un-lft-identity_binary640.6

      \[\leadsto \left|\frac{x + 4}{\color{blue}{1 \cdot y}} - x \cdot \frac{z}{y}\right|\]
    8. Applied associate-/r*_binary640.6

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

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

Reproduce

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