Average Error: 1.6 → 0.4
Time: 9.0s
Precision: binary64
Cost: 7368
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
\[\begin{array}{l} t_0 := \frac{x + 4}{y}\\ \mathbf{if}\;x \leq -4.6541639256961256 \cdot 10^{-110}:\\ \;\;\;\;\left|t_0 - \frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;x \leq 10^{+34}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|t_0 - x \cdot \frac{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
 (let* ((t_0 (/ (+ x 4.0) y)))
   (if (<= x -4.6541639256961256e-110)
     (fabs (- t_0 (/ x (/ y z))))
     (if (<= x 1e+34)
       (fabs (/ (- (+ x 4.0) (* x z)) y))
       (fabs (- t_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 t_0 = (x + 4.0) / y;
	double tmp;
	if (x <= -4.6541639256961256e-110) {
		tmp = fabs((t_0 - (x / (y / z))));
	} else if (x <= 1e+34) {
		tmp = fabs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = fabs((t_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) :: t_0
    real(8) :: tmp
    t_0 = (x + 4.0d0) / y
    if (x <= (-4.6541639256961256d-110)) then
        tmp = abs((t_0 - (x / (y / z))))
    else if (x <= 1d+34) then
        tmp = abs((((x + 4.0d0) - (x * z)) / y))
    else
        tmp = abs((t_0 - (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 t_0 = (x + 4.0) / y;
	double tmp;
	if (x <= -4.6541639256961256e-110) {
		tmp = Math.abs((t_0 - (x / (y / z))));
	} else if (x <= 1e+34) {
		tmp = Math.abs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = Math.abs((t_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):
	t_0 = (x + 4.0) / y
	tmp = 0
	if x <= -4.6541639256961256e-110:
		tmp = math.fabs((t_0 - (x / (y / z))))
	elif x <= 1e+34:
		tmp = math.fabs((((x + 4.0) - (x * z)) / y))
	else:
		tmp = math.fabs((t_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)
	t_0 = Float64(Float64(x + 4.0) / y)
	tmp = 0.0
	if (x <= -4.6541639256961256e-110)
		tmp = abs(Float64(t_0 - Float64(x / Float64(y / z))));
	elseif (x <= 1e+34)
		tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y));
	else
		tmp = abs(Float64(t_0 - Float64(x * Float64(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)
	t_0 = (x + 4.0) / y;
	tmp = 0.0;
	if (x <= -4.6541639256961256e-110)
		tmp = abs((t_0 - (x / (y / z))));
	elseif (x <= 1e+34)
		tmp = abs((((x + 4.0) - (x * z)) / y));
	else
		tmp = abs((t_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_] := Block[{t$95$0 = N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[x, -4.6541639256961256e-110], N[Abs[N[(t$95$0 - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1e+34], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(t$95$0 - N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
t_0 := \frac{x + 4}{y}\\
\mathbf{if}\;x \leq -4.6541639256961256 \cdot 10^{-110}:\\
\;\;\;\;\left|t_0 - \frac{x}{\frac{y}{z}}\right|\\

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

\mathbf{else}:\\
\;\;\;\;\left|t_0 - x \cdot \frac{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 3 regimes
  2. if x < -4.6541639256961256e-110

    1. Initial program 0.7

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

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

    if -4.6541639256961256e-110 < x < 9.99999999999999946e33

    1. Initial program 2.6

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

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{z}{\frac{y}{x}}}\right| \]
    3. Applied egg-rr5.9

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

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

    if 9.99999999999999946e33 < x

    1. Initial program 0.1

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

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{z}{\frac{y}{x}}}\right| \]
    3. Applied egg-rr0.1

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

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

Alternatives

Alternative 1
Error0.1
Cost7368
\[\begin{array}{l} t_0 := \frac{x + 4}{y}\\ \mathbf{if}\;x \leq -4.038698827692165 \cdot 10^{-37}:\\ \;\;\;\;\left|t_0 - \frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \leq 10^{+34}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|t_0 - x \cdot \frac{z}{y}\right|\\ \end{array} \]
Alternative 2
Error1.6
Cost7236
\[\begin{array}{l} \mathbf{if}\;y \leq 10^{-40}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|\\ \end{array} \]
Alternative 3
Error19.5
Cost7120
\[\begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -2.5 \cdot 10^{+66}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{+28}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -358279.2040577703:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.0183503999642145:\\ \;\;\;\;\frac{4}{\left|y\right|}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error19.5
Cost7120
\[\begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -2.5 \cdot 10^{+66}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{+28}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;x \leq -358279.2040577703:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.0183503999642145:\\ \;\;\;\;\frac{4}{\left|y\right|}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error9.1
Cost7112
\[\begin{array}{l} t_0 := \left|\frac{1 - z}{\frac{y}{x}}\right|\\ \mathbf{if}\;x \leq -4.038698827692165 \cdot 10^{-37}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.0183503999642145:\\ \;\;\;\;\left|\frac{-4}{y} - \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error1.7
Cost7108
\[\begin{array}{l} \mathbf{if}\;x \leq 10^{+40}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\ \end{array} \]
Alternative 7
Error1.7
Cost7108
\[\begin{array}{l} \mathbf{if}\;x \leq 10^{+34}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y} - \frac{z}{\frac{y}{x}}\right|\\ \end{array} \]
Alternative 8
Error11.6
Cost6984
\[\begin{array}{l} \mathbf{if}\;z \leq -2.8330409732078132 \cdot 10^{+62}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;z \leq 1.524302918986109 \cdot 10^{+54}:\\ \;\;\;\;\left|\frac{x + 4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]
Alternative 9
Error19.0
Cost6856
\[\begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -358279.2040577703:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.0183503999642145:\\ \;\;\;\;\frac{4}{\left|y\right|}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 10
Error47.0
Cost6592
\[\left|\frac{x}{y}\right| \]

Error

Reproduce

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