?

Average Error: 1.5 → 0.1
Time: 8.9s
Precision: binary64
Cost: 7369

?

\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
\[\begin{array}{l} \mathbf{if}\;x \leq -1.3 \cdot 10^{-5} \lor \neg \left(x \leq 5 \cdot 10^{-24}\right):\\ \;\;\;\;\left|\frac{x + 4}{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 -1.3e-5) (not (<= x 5e-24)))
   (fabs (- (/ (+ x 4.0) 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 <= -1.3e-5) || !(x <= 5e-24)) {
		tmp = fabs((((x + 4.0) / y) - ((x / y) * z)));
	} else {
		tmp = fabs((((x + 4.0) - (x * z)) / y));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = abs((((x + 4.0d0) / y) - ((x / y) * z)))
end function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x <= (-1.3d-5)) .or. (.not. (x <= 5d-24))) then
        tmp = abs((((x + 4.0d0) / y) - ((x / y) * z)))
    else
        tmp = abs((((x + 4.0d0) - (x * z)) / y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	return Math.abs((((x + 4.0) / y) - ((x / y) * z)));
}
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -1.3e-5) || !(x <= 5e-24)) {
		tmp = Math.abs((((x + 4.0) / y) - ((x / y) * z)));
	} else {
		tmp = Math.abs((((x + 4.0) - (x * z)) / y));
	}
	return tmp;
}
def code(x, y, z):
	return math.fabs((((x + 4.0) / y) - ((x / y) * z)))
def code(x, y, z):
	tmp = 0
	if (x <= -1.3e-5) or not (x <= 5e-24):
		tmp = math.fabs((((x + 4.0) / y) - ((x / y) * z)))
	else:
		tmp = math.fabs((((x + 4.0) - (x * z)) / y))
	return tmp
function code(x, y, z)
	return abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z)))
end
function code(x, y, z)
	tmp = 0.0
	if ((x <= -1.3e-5) || !(x <= 5e-24))
		tmp = abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z)));
	else
		tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y));
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = abs((((x + 4.0) / y) - ((x / y) * z)));
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -1.3e-5) || ~((x <= 5e-24)))
		tmp = abs((((x + 4.0) / y) - ((x / y) * z)));
	else
		tmp = abs((((x + 4.0) - (x * z)) / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_, y_, z_] := If[Or[LessEqual[x, -1.3e-5], N[Not[LessEqual[x, 5e-24]], $MachinePrecision]], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
\mathbf{if}\;x \leq -1.3 \cdot 10^{-5} \lor \neg \left(x \leq 5 \cdot 10^{-24}\right):\\
\;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 2 regimes
  2. if x < -1.29999999999999992e-5 or 4.9999999999999998e-24 < x

    1. Initial program 0.1

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

    if -1.29999999999999992e-5 < x < 4.9999999999999998e-24

    1. Initial program 2.4

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

      \[\leadsto \left|\color{blue}{\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 -1.3 \cdot 10^{-5} \lor \neg \left(x \leq 5 \cdot 10^{-24}\right):\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \end{array} \]

Alternatives

Alternative 1
Error0.1
Cost7241
\[\begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{+26} \lor \neg \left(x \leq 2 \cdot 10^{+20}\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} \]
Alternative 2
Error9.9
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -6.1 \cdot 10^{-72} \lor \neg \left(x \leq 5 \cdot 10^{-36}\right):\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{4}{\left|y\right|}\\ \end{array} \]
Alternative 3
Error19.4
Cost6988
\[\begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -4.4 \cdot 10^{+19}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.95 \cdot 10^{-66}:\\ \;\;\;\;\left|\frac{x}{y} \cdot z\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\frac{4}{\left|y\right|}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error12.0
Cost6985
\[\begin{array}{l} \mathbf{if}\;z \leq -3.2 \cdot 10^{+27} \lor \neg \left(z \leq 1.5 \cdot 10^{+131}\right):\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y}\right|\\ \end{array} \]
Alternative 5
Error19.0
Cost6857
\[\begin{array}{l} \mathbf{if}\;x \leq -1.55 \lor \neg \left(x \leq 4\right):\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{4}{\left|y\right|}\\ \end{array} \]
Alternative 6
Error32.4
Cost6592
\[\frac{4}{\left|y\right|} \]

Error

Reproduce?

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