?

Average Accuracy: 77.1% → 78.5%
Time: 11.9s
Precision: binary64
Cost: 8648

?

\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
\[\begin{array}{l} t_0 := \frac{x + 4}{y}\\ t_1 := t_0 - \frac{x}{y} \cdot z\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+71}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}} - t_0\right|\\ \mathbf{elif}\;t_1 \leq 3 \cdot 10^{-203}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|t_1\right|\\ \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 (/ (+ x 4.0) y)) (t_1 (- t_0 (* (/ x y) z))))
   (if (<= t_1 -1e+71)
     (fabs (- (/ z (/ y x)) t_0))
     (if (<= t_1 3e-203) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs t_1)))))
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 = (x + 4.0) / y;
	double t_1 = t_0 - ((x / y) * z);
	double tmp;
	if (t_1 <= -1e+71) {
		tmp = fabs(((z / (y / x)) - t_0));
	} else if (t_1 <= 3e-203) {
		tmp = fabs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = fabs(t_1);
	}
	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) :: t_1
    real(8) :: tmp
    t_0 = (x + 4.0d0) / y
    t_1 = t_0 - ((x / y) * z)
    if (t_1 <= (-1d+71)) then
        tmp = abs(((z / (y / x)) - t_0))
    else if (t_1 <= 3d-203) then
        tmp = abs((((x + 4.0d0) - (x * z)) / y))
    else
        tmp = abs(t_1)
    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 = (x + 4.0) / y;
	double t_1 = t_0 - ((x / y) * z);
	double tmp;
	if (t_1 <= -1e+71) {
		tmp = Math.abs(((z / (y / x)) - t_0));
	} else if (t_1 <= 3e-203) {
		tmp = Math.abs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = Math.abs(t_1);
	}
	return tmp;
}
def code(x, y, z):
	return math.fabs((((x + 4.0) / y) - ((x / y) * z)))
def code(x, y, z):
	t_0 = (x + 4.0) / y
	t_1 = t_0 - ((x / y) * z)
	tmp = 0
	if t_1 <= -1e+71:
		tmp = math.fabs(((z / (y / x)) - t_0))
	elif t_1 <= 3e-203:
		tmp = math.fabs((((x + 4.0) - (x * z)) / y))
	else:
		tmp = math.fabs(t_1)
	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 = Float64(Float64(x + 4.0) / y)
	t_1 = Float64(t_0 - Float64(Float64(x / y) * z))
	tmp = 0.0
	if (t_1 <= -1e+71)
		tmp = abs(Float64(Float64(z / Float64(y / x)) - t_0));
	elseif (t_1 <= 3e-203)
		tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y));
	else
		tmp = abs(t_1);
	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 = (x + 4.0) / y;
	t_1 = t_0 - ((x / y) * z);
	tmp = 0.0;
	if (t_1 <= -1e+71)
		tmp = abs(((z / (y / x)) - t_0));
	elseif (t_1 <= 3e-203)
		tmp = abs((((x + 4.0) - (x * z)) / y));
	else
		tmp = abs(t_1);
	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[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+71], N[Abs[N[(N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, 3e-203], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[t$95$1], $MachinePrecision]]]]]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
t_0 := \frac{x + 4}{y}\\
t_1 := t_0 - \frac{x}{y} \cdot z\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{+71}:\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}} - t_0\right|\\

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

\mathbf{else}:\\
\;\;\;\;\left|t_1\right|\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 3 regimes
  2. if (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z)) < -1e71

    1. Initial program 60.4%

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

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

      [Start]60.4

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

      *-commutative [=>]60.4

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

      clear-num [=>]60.3

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

      un-div-inv [=>]60.4

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

    if -1e71 < (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z)) < 3.0000000000000001e-203

    1. Initial program 92.9%

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

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

      [Start]92.9

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

      associate-*l/ [=>]99.9

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

      sub-div [=>]99.9

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

    if 3.0000000000000001e-203 < (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))

    1. Initial program 74.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  3. Recombined 3 regimes into one program.
  4. Final simplification77.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + 4}{y} - \frac{x}{y} \cdot z \leq -1 \cdot 10^{+71}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}} - \frac{x + 4}{y}\right|\\ \mathbf{elif}\;\frac{x + 4}{y} - \frac{x}{y} \cdot z \leq 3 \cdot 10^{-203}:\\ \;\;\;\;\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
Accuracy78.4%
Cost8649
\[\begin{array}{l} t_0 := \frac{x + 4}{y} - \frac{x}{y} \cdot z\\ \mathbf{if}\;t_0 \leq -5 \cdot 10^{+98} \lor \neg \left(t_0 \leq 3 \cdot 10^{-203}\right):\\ \;\;\;\;\left|t_0\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \end{array} \]
Alternative 2
Accuracy54.8%
Cost7381
\[\begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -10.5:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-41}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 30500000 \lor \neg \left(x \leq 9.4 \cdot 10^{+203}\right) \land x \leq 4.3 \cdot 10^{+300}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Accuracy54.8%
Cost7381
\[\begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -10.6:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{-41}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 32000000:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{+203} \lor \neg \left(x \leq 4.3 \cdot 10^{+300}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \end{array} \]
Alternative 4
Accuracy65.0%
Cost7112
\[\begin{array}{l} \mathbf{if}\;z \leq -2.7 \cdot 10^{+39}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+140}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \left(x \cdot \frac{1}{y}\right)\right|\\ \end{array} \]
Alternative 5
Accuracy76.8%
Cost7108
\[\begin{array}{l} \mathbf{if}\;x \leq 2.75 \cdot 10^{+16}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(z + -1\right)\right|\\ \end{array} \]
Alternative 6
Accuracy65.0%
Cost6984
\[\begin{array}{l} \mathbf{if}\;z \leq -3.7 \cdot 10^{+40}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{+140}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y} \cdot z\right|\\ \end{array} \]
Alternative 7
Accuracy56.5%
Cost6857
\[\begin{array}{l} \mathbf{if}\;x \leq -10.5 \lor \neg \left(x \leq 4\right):\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array} \]
Alternative 8
Accuracy39.9%
Cost6592
\[\left|\frac{4}{y}\right| \]

Error

Reproduce?

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