Average Error: 1.7 → 0.3
Time: 8.4s
Precision: binary64
Cost: 7368
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
\[\begin{array}{l} t_0 := \left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\\ \mathbf{if}\;x \leq -11.134054139803297:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.6073609483611617 \cdot 10^{-123}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z)))))
   (if (<= x -11.134054139803297)
     t_0
     (if (<= x 2.6073609483611617e-123)
       (fabs (/ (- (+ x 4.0) (* x z)) y))
       t_0))))
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 t_0 = fabs((((x + 4.0) / y) - ((x / y) * z)));
	double tmp;
	if (x <= -11.134054139803297) {
		tmp = t_0;
	} else if (x <= 2.6073609483611617e-123) {
		tmp = fabs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = t_0;
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = abs((((x + 4.0d0) / y) - ((x / y) * z)))
    if (x <= (-11.134054139803297d0)) then
        tmp = t_0
    else if (x <= 2.6073609483611617d-123) then
        tmp = abs((((x + 4.0d0) - (x * z)) / y))
    else
        tmp = t_0
    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 t_0 = Math.abs((((x + 4.0) / y) - ((x / y) * z)));
	double tmp;
	if (x <= -11.134054139803297) {
		tmp = t_0;
	} else if (x <= 2.6073609483611617e-123) {
		tmp = Math.abs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	return math.fabs((((x + 4.0) / y) - ((x / y) * z)))
def code(x, y, z):
	t_0 = math.fabs((((x + 4.0) / y) - ((x / y) * z)))
	tmp = 0
	if x <= -11.134054139803297:
		tmp = t_0
	elif x <= 2.6073609483611617e-123:
		tmp = math.fabs((((x + 4.0) - (x * z)) / y))
	else:
		tmp = t_0
	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)
	t_0 = abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z)))
	tmp = 0.0
	if (x <= -11.134054139803297)
		tmp = t_0;
	elseif (x <= 2.6073609483611617e-123)
		tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y));
	else
		tmp = t_0;
	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)
	t_0 = abs((((x + 4.0) / y) - ((x / y) * z)));
	tmp = 0.0;
	if (x <= -11.134054139803297)
		tmp = t_0;
	elseif (x <= 2.6073609483611617e-123)
		tmp = abs((((x + 4.0) - (x * z)) / y));
	else
		tmp = t_0;
	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_] := Block[{t$95$0 = N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -11.134054139803297], t$95$0, If[LessEqual[x, 2.6073609483611617e-123], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
t_0 := \left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|\\
\mathbf{if}\;x \leq -11.134054139803297:\\
\;\;\;\;t_0\\

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\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 < -11.134054139803297 or 2.60736094836116166e-123 < x

    1. Initial program 0.5

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

    if -11.134054139803297 < x < 2.60736094836116166e-123

    1. Initial program 3.1

      \[\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.3

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

Alternatives

Alternative 1
Error19.3
Cost7252
\[\begin{array}{l} t_0 := \frac{4}{\left|y\right|}\\ t_1 := \left|\frac{x}{y}\right|\\ t_2 := \left|\frac{x}{y} \cdot z\right|\\ \mathbf{if}\;x \leq -5.5 \cdot 10^{+31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.9794420330140266 \cdot 10^{-8}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.313683191112133 \cdot 10^{-58}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.2264613284410626 \cdot 10^{-34}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 5.4703494810948347 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error19.3
Cost7252
\[\begin{array}{l} t_0 := \frac{4}{\left|y\right|}\\ t_1 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -5.5 \cdot 10^{+31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.9794420330140266 \cdot 10^{-8}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;x \leq 1.313683191112133 \cdot 10^{-58}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.2264613284410626 \cdot 10^{-34}:\\ \;\;\;\;\left|\frac{x}{y} \cdot z\right|\\ \mathbf{elif}\;x \leq 5.4703494810948347 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error9.3
Cost7240
\[\begin{array}{l} \mathbf{if}\;x \leq -2.9794420330140266 \cdot 10^{-8}:\\ \;\;\;\;\left|x \cdot \frac{z + -1}{y}\right|\\ \mathbf{elif}\;x \leq 1.313683191112133 \cdot 10^{-58}:\\ \;\;\;\;\left|\frac{x + 4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \left(\frac{1}{y} - \frac{z}{y}\right)\right|\\ \end{array} \]
Alternative 4
Error1.9
Cost7236
\[\begin{array}{l} \mathbf{if}\;x \leq -9039443606992.223:\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{z}{\frac{y}{x}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \end{array} \]
Alternative 5
Error9.3
Cost7112
\[\begin{array}{l} t_0 := \left|x \cdot \frac{z + -1}{y}\right|\\ \mathbf{if}\;x \leq -2.9794420330140266 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.313683191112133 \cdot 10^{-58}:\\ \;\;\;\;\left|\frac{x + 4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error1.9
Cost7108
\[\begin{array}{l} \mathbf{if}\;x \leq -9039443606992.223:\\ \;\;\;\;\left|x \cdot \frac{z + -1}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \end{array} \]
Alternative 7
Error11.3
Cost6984
\[\begin{array}{l} t_0 := \left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{if}\;z \leq -2.0145836318104272 \cdot 10^{+44}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.622611376908689 \cdot 10^{+19}:\\ \;\;\;\;\left|\frac{x + 4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error19.0
Cost6856
\[\begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -11.134054139803297:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5.4703494810948347 \cdot 10^{-8}:\\ \;\;\;\;\frac{4}{\left|y\right|}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Error32.6
Cost6592
\[\frac{4}{\left|y\right|} \]

Error

Reproduce

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