Average Error: 1.6 → 0.2
Time: 3.3s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \leq -5.168477911800305 \cdot 10^{+83}:\\ \;\;\;\;\left|\frac{4}{y} + x \cdot \frac{1 - z}{y}\right|\\ \mathbf{elif}\;x \leq 5.386724146293841 \cdot 10^{+25}:\\ \;\;\;\;\left|\frac{x + \left(4 - x \cdot z\right)}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - \sqrt{x} \cdot \left(z \cdot \frac{\sqrt{x}}{y}\right)\right|\\ \end{array}\]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
\mathbf{if}\;x \leq -5.168477911800305 \cdot 10^{+83}:\\
\;\;\;\;\left|\frac{4}{y} + x \cdot \frac{1 - z}{y}\right|\\

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

\mathbf{else}:\\
\;\;\;\;\left|\frac{x + 4}{y} - \sqrt{x} \cdot \left(z \cdot \frac{\sqrt{x}}{y}\right)\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.168477911800305e+83)) {
		VAR = ((double) fabs(((double) ((4.0 / y) + ((double) (x * (((double) (1.0 - z)) / y)))))));
	} else {
		double VAR_1;
		if ((x <= 5.386724146293841e+25)) {
			VAR_1 = ((double) fabs((((double) (x + ((double) (4.0 - ((double) (x * z)))))) / y)));
		} else {
			VAR_1 = ((double) fabs(((double) ((((double) (x + 4.0)) / y) - ((double) (((double) sqrt(x)) * ((double) (z * (((double) sqrt(x)) / y)))))))));
		}
		VAR = VAR_1;
	}
	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 3 regimes
  2. if x < -5.16847791180030524e83

    1. Initial program 0.1

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

      \[\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|\]
    4. Using strategy rm
    5. Applied div-inv0.3

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

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

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

    if -5.16847791180030524e83 < x < 5.3867241462938411e25

    1. Initial program 2.2

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

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

    if 5.3867241462938411e25 < x

    1. Initial program 0.1

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
    2. Using strategy rm
    3. Applied *-un-lft-identity0.1

      \[\leadsto \left|\frac{x + 4}{y} - \frac{x}{\color{blue}{1 \cdot y}} \cdot z\right|\]
    4. Applied add-sqr-sqrt0.2

      \[\leadsto \left|\frac{x + 4}{y} - \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{1 \cdot y} \cdot z\right|\]
    5. Applied times-frac0.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.168477911800305 \cdot 10^{+83}:\\ \;\;\;\;\left|\frac{4}{y} + x \cdot \frac{1 - z}{y}\right|\\ \mathbf{elif}\;x \leq 5.386724146293841 \cdot 10^{+25}:\\ \;\;\;\;\left|\frac{x + \left(4 - x \cdot z\right)}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - \sqrt{x} \cdot \left(z \cdot \frac{\sqrt{x}}{y}\right)\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))))