Average Error: 1.6 → 0.1
Time: 6.4s
Precision: binary64
Cost: 7304
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\]
\[\begin{array}{l} \mathbf{if}\;x \leq -548550455324647.94 \lor \neg \left(x \leq 1.6983471831252163 \cdot 10^{+25}\right):\\ \;\;\;\;\left|\frac{x}{y} - \frac{x}{y} \cdot z\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 -548550455324647.94 \lor \neg \left(x \leq 1.6983471831252163 \cdot 10^{+25}\right):\\
\;\;\;\;\left|\frac{x}{y} - \frac{x}{y} \cdot z\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 -548550455324647.94) (not (<= x 1.6983471831252163e+25)))
   (fabs (- (/ x y) (* (/ x y) 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 <= -548550455324647.94) || !(x <= 1.6983471831252163e+25)) {
		tmp = fabs((x / y) - ((x / y) * 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
Error2.3
Cost7304
\[\begin{array}{l} \mathbf{if}\;z \leq -13091502411.24689 \lor \neg \left(z \leq 2.5687676999185847\right):\\ \;\;\;\;\left|\frac{4}{y} - \frac{x}{y} \cdot z\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y} + \frac{4}{y}\right|\\ \end{array}\]
Alternative 2
Error9.2
Cost7304
\[\begin{array}{l} \mathbf{if}\;x \leq -1.3934540579464493 \cdot 10^{-34} \lor \neg \left(x \leq 7.633301677712175 \cdot 10^{-32}\right):\\ \;\;\;\;\left|\frac{x}{y} - \frac{x}{y} \cdot z\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y} + \frac{4}{y}\right|\\ \end{array}\]
Alternative 3
Error9.2
Cost7176
\[\begin{array}{l} \mathbf{if}\;x \leq -1.3934540579464493 \cdot 10^{-34} \lor \neg \left(x \leq 7.633301677712175 \cdot 10^{-32}\right):\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y} + \frac{4}{y}\right|\\ \end{array}\]
Alternative 4
Error11.4
Cost7818
\[\begin{array}{l} \mathbf{if}\;z \leq -4.590732991688508 \cdot 10^{+151}:\\ \;\;\;\;\left|-\frac{x}{y} \cdot z\right|\\ \mathbf{elif}\;z \leq -6.706000536155162 \cdot 10^{+142}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;z \leq -1.2839354414049617 \cdot 10^{+48} \lor \neg \left(z \leq 4.8117962760082794 \cdot 10^{+42}\right):\\ \;\;\;\;\left|-\frac{x}{y} \cdot z\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y} + \frac{4}{y}\right|\\ \end{array}\]
Alternative 5
Error23.4
Cost7112
\[\begin{array}{l} \mathbf{if}\;x \leq -7.687075550799982 \cdot 10^{-36} \lor \neg \left(x \leq 3.1747198910273813 \cdot 10^{-18}\right):\\ \;\;\;\;\left|-\frac{x}{y} \cdot z\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array}\]
Alternative 6
Error33.0
Cost6592
\[\left|\frac{4}{y}\right|\]
Alternative 7
Error60.5
Cost64
\[1\]

Error

Derivation

  1. Split input into 2 regimes
  2. if x < -548550455324647.938 or 1.6983471831252163e25 < x

    1. Initial program 0.1

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

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

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

    if -548550455324647.938 < x < 1.6983471831252163e25

    1. Initial program 2.5

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

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

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

Reproduce

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