Average Error: 1.5 → 0.3
Time: 3.6s
Precision: binary64
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
\[\begin{array}{l} t_0 := \left|\frac{x + 4}{y} - \frac{z}{\frac{y}{x}}\right|\\ \mathbf{if}\;x \leq -2185000095642.6838:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.0714748415762229 \cdot 10^{-116}:\\ \;\;\;\;\left|\frac{4 + x \cdot \left(1 - z\right)}{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) (/ z (/ y x))))))
   (if (<= x -2185000095642.6838)
     t_0
     (if (<= x 1.0714748415762229e-116)
       (fabs (/ (+ 4.0 (* x (- 1.0 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) - (z / (y / x))));
	double tmp;
	if (x <= -2185000095642.6838) {
		tmp = t_0;
	} else if (x <= 1.0714748415762229e-116) {
		tmp = fabs(((4.0 + (x * (1.0 - 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) - (z / (y / x))))
    if (x <= (-2185000095642.6838d0)) then
        tmp = t_0
    else if (x <= 1.0714748415762229d-116) then
        tmp = abs(((4.0d0 + (x * (1.0d0 - 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) - (z / (y / x))));
	double tmp;
	if (x <= -2185000095642.6838) {
		tmp = t_0;
	} else if (x <= 1.0714748415762229e-116) {
		tmp = Math.abs(((4.0 + (x * (1.0 - 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) - (z / (y / x))))
	tmp = 0
	if x <= -2185000095642.6838:
		tmp = t_0
	elif x <= 1.0714748415762229e-116:
		tmp = math.fabs(((4.0 + (x * (1.0 - 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(z / Float64(y / x))))
	tmp = 0.0
	if (x <= -2185000095642.6838)
		tmp = t_0;
	elseif (x <= 1.0714748415762229e-116)
		tmp = abs(Float64(Float64(4.0 + Float64(x * Float64(1.0 - 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) - (z / (y / x))));
	tmp = 0.0;
	if (x <= -2185000095642.6838)
		tmp = t_0;
	elseif (x <= 1.0714748415762229e-116)
		tmp = abs(((4.0 + (x * (1.0 - 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[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -2185000095642.6838], t$95$0, If[LessEqual[x, 1.0714748415762229e-116], N[Abs[N[(N[(4.0 + N[(x * N[(1.0 - z), $MachinePrecision]), $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{z}{\frac{y}{x}}\right|\\
\mathbf{if}\;x \leq -2185000095642.6838:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 1.0714748415762229 \cdot 10^{-116}:\\
\;\;\;\;\left|\frac{4 + x \cdot \left(1 - z\right)}{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 < -2185000095642.68384 or 1.0714748415762229e-116 < x

    1. Initial program 0.5

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

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

    if -2185000095642.68384 < x < 1.0714748415762229e-116

    1. Initial program 2.5

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

      \[\leadsto \left|\color{blue}{4 \cdot \frac{1}{y} + \left(\frac{1}{y} - \frac{z}{y}\right) \cdot x}\right| \]
    3. Taylor expanded in y around 0 0.1

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

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

Reproduce

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