Average Error: 1.6 → 0.3
Time: 2.4min
Precision: binary64
Cost: 7304
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \leq -1.9291044923307063 \cdot 10^{+73} \lor \neg \left(x \leq 3.9848049043978355 \cdot 10^{+61}\right):\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \end{array}\]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
\mathbf{if}\;x \leq -1.9291044923307063 \cdot 10^{+73} \lor \neg \left(x \leq 3.9848049043978355 \cdot 10^{+61}\right):\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot 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 (or (<= x -1.9291044923307063e+73) (not (<= x 3.9848049043978355e+61)))
   (fabs (* (/ x y) (- 1.0 z)))
   (fabs (/ (- (+ x 4.0) (* 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.9291044923307063e+73) || !(x <= 3.9848049043978355e+61)) {
		tmp = fabs((x / y) * (1.0 - z));
	} else {
		tmp = fabs(((x + 4.0) - (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

Alternatives

Alternative 1
Error0.7
Cost46016
\[\left|\frac{x + 4}{y} - \frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt[3]{y} \cdot \sqrt[3]{y}} \cdot \left(z \cdot \frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)\right|\]
Alternative 2
Error2.7
Cost7304
\[\begin{array}{l} \mathbf{if}\;x \leq -6.009231922753451 \cdot 10^{+19} \lor \neg \left(x \leq 0.05699953450221314\right):\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y} - \frac{x}{y} \cdot z\right|\\ \end{array}\]
Alternative 3
Error9.0
Cost7176
\[\begin{array}{l} \mathbf{if}\;x \leq -6849231.999510948 \lor \neg \left(x \leq 4.971898665791662 \cdot 10^{-56}\right):\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y}\right|\\ \end{array}\]
Alternative 4
Error12.6
Cost7754
\[\begin{array}{l} \mathbf{if}\;z \leq -1.4181977682475246 \cdot 10^{+112}:\\ \;\;\;\;\left|-\frac{x}{y} \cdot z\right|\\ \mathbf{elif}\;z \leq 2.5807709735402435 \cdot 10^{+53}:\\ \;\;\;\;\left|\frac{x}{y} + \frac{4}{y}\right|\\ \mathbf{elif}\;z \leq 3.427787592458121 \cdot 10^{+104} \lor \neg \left(z \leq 4.3750636535943824 \cdot 10^{+136}\right):\\ \;\;\;\;\left|-\frac{x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array}\]
Alternative 5
Error12.6
Cost7754
\[\begin{array}{l} \mathbf{if}\;z \leq -1.4181977682475246 \cdot 10^{+112}:\\ \;\;\;\;\left|-\frac{x}{y} \cdot z\right|\\ \mathbf{elif}\;z \leq 3.3923524753239416 \cdot 10^{+52}:\\ \;\;\;\;\left|\frac{x + 4}{y}\right|\\ \mathbf{elif}\;z \leq 1.825148986977509 \cdot 10^{+103} \lor \neg \left(z \leq 4.3750636535943824 \cdot 10^{+136}\right):\\ \;\;\;\;\left|-\frac{x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array}\]
Alternative 6
Error13.4
Cost7754
\[\begin{array}{l} \mathbf{if}\;z \leq -4.5649567343194794 \cdot 10^{+114}:\\ \;\;\;\;\left|-\frac{x \cdot z}{y}\right|\\ \mathbf{elif}\;z \leq 2.2794347711400523 \cdot 10^{+52}:\\ \;\;\;\;\left|\frac{x + 4}{y}\right|\\ \mathbf{elif}\;z \leq 1.69241875073521 \cdot 10^{+104} \lor \neg \left(z \leq 2.3853971263658353 \cdot 10^{+137}\right):\\ \;\;\;\;\left|-\frac{x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array}\]
Alternative 7
Error18.0
Cost6720
\[\left|\frac{x + 4}{y}\right|\]
Alternative 8
Error18.7
Cost6920
\[\begin{array}{l} \mathbf{if}\;x \leq -10.54664642924945 \lor \neg \left(x \leq 4.092370307541661\right):\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array}\]
Alternative 9
Error32.4
Cost6592
\[\left|\frac{4}{y}\right|\]
Alternative 10
Error60.5
Cost64
\[1\]

Error

Time

Derivation

  1. Split input into 2 regimes
  2. if x < -1.9291044923307063e73 or 3.9848049043978355e61 < x

    1. Initial program 0.1

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

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

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

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

    if -1.9291044923307063e73 < x < 3.9848049043978355e61

    1. Initial program 2.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.9291044923307063 \cdot 10^{+73} \lor \neg \left(x \leq 3.9848049043978355 \cdot 10^{+61}\right):\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \end{array}\]

Reproduce

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