fabs fraction 1

Percentage Accurate: 91.9% → 99.6%
Time: 6.3s
Alternatives: 8
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \end{array} \]
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
double code(double x, double y, double z) {
	return fabs((((x + 4.0) / y) - ((x / y) * z)));
}
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
public static double code(double x, double y, double z) {
	return Math.abs((((x + 4.0) / y) - ((x / y) * z)));
}
def code(x, y, z):
	return math.fabs((((x + 4.0) / y) - ((x / y) * z)))
function code(x, y, z)
	return abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z)))
end
function tmp = code(x, y, z)
	tmp = abs((((x + 4.0) / y) - ((x / y) * z)));
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]
\begin{array}{l}

\\
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 91.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \end{array} \]
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
double code(double x, double y, double z) {
	return fabs((((x + 4.0) / y) - ((x / y) * z)));
}
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
public static double code(double x, double y, double z) {
	return Math.abs((((x + 4.0) / y) - ((x / y) * z)));
}
def code(x, y, z):
	return math.fabs((((x + 4.0) / y) - ((x / y) * z)))
function code(x, y, z)
	return abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z)))
end
function tmp = code(x, y, z)
	tmp = abs((((x + 4.0) / y) - ((x / y) * z)));
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]
\begin{array}{l}

\\
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\end{array}

Alternative 1: 99.6% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 6.5 \cdot 10^{-53}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}} - \frac{x + 4}{y}\right|\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= y 6.5e-53)
   (fabs (/ (- (+ x 4.0) (* x z)) y))
   (fabs (- (/ x (/ y z)) (/ (+ x 4.0) y)))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if (y <= 6.5e-53) {
		tmp = fabs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = fabs(((x / (y / z)) - ((x + 4.0) / y)));
	}
	return tmp;
}
NOTE: y should be positive before calling this 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 (y <= 6.5d-53) then
        tmp = abs((((x + 4.0d0) - (x * z)) / y))
    else
        tmp = abs(((x / (y / z)) - ((x + 4.0d0) / y)))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 6.5e-53) {
		tmp = Math.abs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = Math.abs(((x / (y / z)) - ((x + 4.0) / y)));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if y <= 6.5e-53:
		tmp = math.fabs((((x + 4.0) - (x * z)) / y))
	else:
		tmp = math.fabs(((x / (y / z)) - ((x + 4.0) / y)))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if (y <= 6.5e-53)
		tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y));
	else
		tmp = abs(Float64(Float64(x / Float64(y / z)) - Float64(Float64(x + 4.0) / y)));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 6.5e-53)
		tmp = abs((((x + 4.0) - (x * z)) / y));
	else
		tmp = abs(((x / (y / z)) - ((x + 4.0) / y)));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[y, 6.5e-53], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.5 \cdot 10^{-53}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 6.4999999999999997e-53

    1. Initial program 91.6%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/94.6%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/92.0%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified92.0%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in x around 0 95.3%

      \[\leadsto \left|\color{blue}{x \cdot \left(\frac{1}{y} - \frac{z}{y}\right) + 4 \cdot \frac{1}{y}}\right| \]
    5. Step-by-step derivation
      1. sub-neg95.3%

        \[\leadsto \left|x \cdot \color{blue}{\left(\frac{1}{y} + \left(-\frac{z}{y}\right)\right)} + 4 \cdot \frac{1}{y}\right| \]
      2. +-commutative95.3%

        \[\leadsto \left|x \cdot \color{blue}{\left(\left(-\frac{z}{y}\right) + \frac{1}{y}\right)} + 4 \cdot \frac{1}{y}\right| \]
      3. distribute-lft-in92.0%

        \[\leadsto \left|\color{blue}{\left(x \cdot \left(-\frac{z}{y}\right) + x \cdot \frac{1}{y}\right)} + 4 \cdot \frac{1}{y}\right| \]
      4. associate-+r+92.0%

        \[\leadsto \left|\color{blue}{x \cdot \left(-\frac{z}{y}\right) + \left(x \cdot \frac{1}{y} + 4 \cdot \frac{1}{y}\right)}\right| \]
      5. distribute-rgt-in92.0%

        \[\leadsto \left|x \cdot \left(-\frac{z}{y}\right) + \color{blue}{\frac{1}{y} \cdot \left(x + 4\right)}\right| \]
      6. associate-*l/92.0%

        \[\leadsto \left|x \cdot \left(-\frac{z}{y}\right) + \color{blue}{\frac{1 \cdot \left(x + 4\right)}{y}}\right| \]
      7. *-lft-identity92.0%

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

        \[\leadsto \left|\color{blue}{\frac{x + 4}{y} + x \cdot \left(-\frac{z}{y}\right)}\right| \]
      9. distribute-rgt-neg-out92.0%

        \[\leadsto \left|\frac{x + 4}{y} + \color{blue}{\left(-x \cdot \frac{z}{y}\right)}\right| \]
      10. sub-neg92.0%

        \[\leadsto \left|\color{blue}{\frac{x + 4}{y} - x \cdot \frac{z}{y}}\right| \]
      11. associate-*r/94.6%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      12. div-sub97.9%

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

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

    if 6.4999999999999997e-53 < y

    1. Initial program 94.8%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/93.5%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/99.9%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Step-by-step derivation
      1. clear-num99.9%

        \[\leadsto \left|\frac{x + 4}{y} - x \cdot \color{blue}{\frac{1}{\frac{y}{z}}}\right| \]
      2. un-div-inv99.9%

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

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

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

Alternative 2: 99.6% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 3.5 \cdot 10^{-53}:\\ \;\;\;\;\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} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= y 3.5e-53)
   (fabs (/ (- (+ x 4.0) (* x z)) y))
   (fabs (- (/ (+ x 4.0) y) (* x (/ z y))))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if (y <= 3.5e-53) {
		tmp = fabs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = fabs((((x + 4.0) / y) - (x * (z / y))));
	}
	return tmp;
}
NOTE: y should be positive before calling this 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 (y <= 3.5d-53) then
        tmp = abs((((x + 4.0d0) - (x * z)) / y))
    else
        tmp = abs((((x + 4.0d0) / y) - (x * (z / y))))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= 3.5e-53) {
		tmp = Math.abs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = Math.abs((((x + 4.0) / y) - (x * (z / y))));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if y <= 3.5e-53:
		tmp = math.fabs((((x + 4.0) - (x * z)) / y))
	else:
		tmp = math.fabs((((x + 4.0) / y) - (x * (z / y))))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if (y <= 3.5e-53)
		tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y));
	else
		tmp = abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(x * Float64(z / y))));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 3.5e-53)
		tmp = abs((((x + 4.0) - (x * z)) / y));
	else
		tmp = abs((((x + 4.0) / y) - (x * (z / y))));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[y, 3.5e-53], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.5 \cdot 10^{-53}:\\
\;\;\;\;\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}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 3.49999999999999993e-53

    1. Initial program 91.6%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/94.6%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/92.0%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified92.0%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in x around 0 95.3%

      \[\leadsto \left|\color{blue}{x \cdot \left(\frac{1}{y} - \frac{z}{y}\right) + 4 \cdot \frac{1}{y}}\right| \]
    5. Step-by-step derivation
      1. sub-neg95.3%

        \[\leadsto \left|x \cdot \color{blue}{\left(\frac{1}{y} + \left(-\frac{z}{y}\right)\right)} + 4 \cdot \frac{1}{y}\right| \]
      2. +-commutative95.3%

        \[\leadsto \left|x \cdot \color{blue}{\left(\left(-\frac{z}{y}\right) + \frac{1}{y}\right)} + 4 \cdot \frac{1}{y}\right| \]
      3. distribute-lft-in92.0%

        \[\leadsto \left|\color{blue}{\left(x \cdot \left(-\frac{z}{y}\right) + x \cdot \frac{1}{y}\right)} + 4 \cdot \frac{1}{y}\right| \]
      4. associate-+r+92.0%

        \[\leadsto \left|\color{blue}{x \cdot \left(-\frac{z}{y}\right) + \left(x \cdot \frac{1}{y} + 4 \cdot \frac{1}{y}\right)}\right| \]
      5. distribute-rgt-in92.0%

        \[\leadsto \left|x \cdot \left(-\frac{z}{y}\right) + \color{blue}{\frac{1}{y} \cdot \left(x + 4\right)}\right| \]
      6. associate-*l/92.0%

        \[\leadsto \left|x \cdot \left(-\frac{z}{y}\right) + \color{blue}{\frac{1 \cdot \left(x + 4\right)}{y}}\right| \]
      7. *-lft-identity92.0%

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

        \[\leadsto \left|\color{blue}{\frac{x + 4}{y} + x \cdot \left(-\frac{z}{y}\right)}\right| \]
      9. distribute-rgt-neg-out92.0%

        \[\leadsto \left|\frac{x + 4}{y} + \color{blue}{\left(-x \cdot \frac{z}{y}\right)}\right| \]
      10. sub-neg92.0%

        \[\leadsto \left|\color{blue}{\frac{x + 4}{y} - x \cdot \frac{z}{y}}\right| \]
      11. associate-*r/94.6%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      12. div-sub97.9%

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

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

    if 3.49999999999999993e-53 < y

    1. Initial program 94.8%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/93.5%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/99.9%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified99.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 3.5 \cdot 10^{-53}:\\ \;\;\;\;\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: 86.9% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq -18000 \lor \neg \left(x \leq 450000000\right):\\ \;\;\;\;\left|\frac{x}{\frac{y}{1 - z}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y} + \frac{x}{y}\right|\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -18000.0) (not (<= x 450000000.0)))
   (fabs (/ x (/ y (- 1.0 z))))
   (fabs (+ (/ 4.0 y) (/ x y)))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -18000.0) || !(x <= 450000000.0)) {
		tmp = fabs((x / (y / (1.0 - z))));
	} else {
		tmp = fabs(((4.0 / y) + (x / y)));
	}
	return tmp;
}
NOTE: y should be positive before calling this 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 <= (-18000.0d0)) .or. (.not. (x <= 450000000.0d0))) then
        tmp = abs((x / (y / (1.0d0 - z))))
    else
        tmp = abs(((4.0d0 / y) + (x / y)))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -18000.0) || !(x <= 450000000.0)) {
		tmp = Math.abs((x / (y / (1.0 - z))));
	} else {
		tmp = Math.abs(((4.0 / y) + (x / y)));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if (x <= -18000.0) or not (x <= 450000000.0):
		tmp = math.fabs((x / (y / (1.0 - z))))
	else:
		tmp = math.fabs(((4.0 / y) + (x / y)))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if ((x <= -18000.0) || !(x <= 450000000.0))
		tmp = abs(Float64(x / Float64(y / Float64(1.0 - z))));
	else
		tmp = abs(Float64(Float64(4.0 / y) + Float64(x / y)));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -18000.0) || ~((x <= 450000000.0)))
		tmp = abs((x / (y / (1.0 - z))));
	else
		tmp = abs(((4.0 / y) + (x / y)));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[Or[LessEqual[x, -18000.0], N[Not[LessEqual[x, 450000000.0]], $MachinePrecision]], N[Abs[N[(x / N[(y / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(4.0 / y), $MachinePrecision] + N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -18000 \lor \neg \left(x \leq 450000000\right):\\
\;\;\;\;\left|\frac{x}{\frac{y}{1 - z}}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{4}{y} + \frac{x}{y}\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -18000 or 4.5e8 < x

    1. Initial program 89.3%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/87.3%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/94.6%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified94.6%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in x around 0 99.8%

      \[\leadsto \left|\color{blue}{x \cdot \left(\frac{1}{y} - \frac{z}{y}\right) + 4 \cdot \frac{1}{y}}\right| \]
    5. Step-by-step derivation
      1. sub-neg99.8%

        \[\leadsto \left|x \cdot \color{blue}{\left(\frac{1}{y} + \left(-\frac{z}{y}\right)\right)} + 4 \cdot \frac{1}{y}\right| \]
      2. +-commutative99.8%

        \[\leadsto \left|x \cdot \color{blue}{\left(\left(-\frac{z}{y}\right) + \frac{1}{y}\right)} + 4 \cdot \frac{1}{y}\right| \]
      3. distribute-lft-in94.5%

        \[\leadsto \left|\color{blue}{\left(x \cdot \left(-\frac{z}{y}\right) + x \cdot \frac{1}{y}\right)} + 4 \cdot \frac{1}{y}\right| \]
      4. associate-+r+94.5%

        \[\leadsto \left|\color{blue}{x \cdot \left(-\frac{z}{y}\right) + \left(x \cdot \frac{1}{y} + 4 \cdot \frac{1}{y}\right)}\right| \]
      5. distribute-rgt-in94.5%

        \[\leadsto \left|x \cdot \left(-\frac{z}{y}\right) + \color{blue}{\frac{1}{y} \cdot \left(x + 4\right)}\right| \]
      6. associate-*l/94.6%

        \[\leadsto \left|x \cdot \left(-\frac{z}{y}\right) + \color{blue}{\frac{1 \cdot \left(x + 4\right)}{y}}\right| \]
      7. *-lft-identity94.6%

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

        \[\leadsto \left|\color{blue}{\frac{x + 4}{y} + x \cdot \left(-\frac{z}{y}\right)}\right| \]
      9. distribute-rgt-neg-out94.6%

        \[\leadsto \left|\frac{x + 4}{y} + \color{blue}{\left(-x \cdot \frac{z}{y}\right)}\right| \]
      10. sub-neg94.6%

        \[\leadsto \left|\color{blue}{\frac{x + 4}{y} - x \cdot \frac{z}{y}}\right| \]
      11. associate-*r/87.3%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      12. div-sub92.6%

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

      \[\leadsto \left|\color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}}\right| \]
    7. Taylor expanded in x around inf 92.5%

      \[\leadsto \left|\color{blue}{\frac{x \cdot \left(1 - z\right)}{y}}\right| \]
    8. Step-by-step derivation
      1. associate-/l*99.7%

        \[\leadsto \left|\color{blue}{\frac{x}{\frac{y}{1 - z}}}\right| \]
    9. Simplified99.7%

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

    if -18000 < x < 4.5e8

    1. Initial program 95.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/99.9%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/94.0%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified94.0%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in z around 0 81.6%

      \[\leadsto \left|\color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}}\right| \]
    5. Step-by-step derivation
      1. associate-*r/81.6%

        \[\leadsto \left|\color{blue}{\frac{4 \cdot 1}{y}} + \frac{x}{y}\right| \]
      2. metadata-eval81.6%

        \[\leadsto \left|\frac{\color{blue}{4}}{y} + \frac{x}{y}\right| \]
    6. Simplified81.6%

      \[\leadsto \left|\color{blue}{\frac{4}{y} + \frac{x}{y}}\right| \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -18000 \lor \neg \left(x \leq 450000000\right):\\ \;\;\;\;\left|\frac{x}{\frac{y}{1 - z}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y} + \frac{x}{y}\right|\\ \end{array} \]

Alternative 4: 97.9% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 4.2 \cdot 10^{+14}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{1 - z}}\right|\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= x 4.2e+14)
   (fabs (/ (- (+ x 4.0) (* x z)) y))
   (fabs (/ x (/ y (- 1.0 z))))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if (x <= 4.2e+14) {
		tmp = fabs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = fabs((x / (y / (1.0 - z))));
	}
	return tmp;
}
NOTE: y should be positive before calling this 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 <= 4.2d+14) then
        tmp = abs((((x + 4.0d0) - (x * z)) / y))
    else
        tmp = abs((x / (y / (1.0d0 - z))))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= 4.2e+14) {
		tmp = Math.abs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = Math.abs((x / (y / (1.0 - z))));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if x <= 4.2e+14:
		tmp = math.fabs((((x + 4.0) - (x * z)) / y))
	else:
		tmp = math.fabs((x / (y / (1.0 - z))))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if (x <= 4.2e+14)
		tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y));
	else
		tmp = abs(Float64(x / Float64(y / Float64(1.0 - z))));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= 4.2e+14)
		tmp = abs((((x + 4.0) - (x * z)) / y));
	else
		tmp = abs((x / (y / (1.0 - z))));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[x, 4.2e+14], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / N[(y / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.2 \cdot 10^{+14}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{1 - z}}\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 4.2e14

    1. Initial program 93.8%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/96.5%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/94.0%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified94.0%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in x around 0 95.5%

      \[\leadsto \left|\color{blue}{x \cdot \left(\frac{1}{y} - \frac{z}{y}\right) + 4 \cdot \frac{1}{y}}\right| \]
    5. Step-by-step derivation
      1. sub-neg95.5%

        \[\leadsto \left|x \cdot \color{blue}{\left(\frac{1}{y} + \left(-\frac{z}{y}\right)\right)} + 4 \cdot \frac{1}{y}\right| \]
      2. +-commutative95.5%

        \[\leadsto \left|x \cdot \color{blue}{\left(\left(-\frac{z}{y}\right) + \frac{1}{y}\right)} + 4 \cdot \frac{1}{y}\right| \]
      3. distribute-lft-in94.0%

        \[\leadsto \left|\color{blue}{\left(x \cdot \left(-\frac{z}{y}\right) + x \cdot \frac{1}{y}\right)} + 4 \cdot \frac{1}{y}\right| \]
      4. associate-+r+94.0%

        \[\leadsto \left|\color{blue}{x \cdot \left(-\frac{z}{y}\right) + \left(x \cdot \frac{1}{y} + 4 \cdot \frac{1}{y}\right)}\right| \]
      5. distribute-rgt-in94.0%

        \[\leadsto \left|x \cdot \left(-\frac{z}{y}\right) + \color{blue}{\frac{1}{y} \cdot \left(x + 4\right)}\right| \]
      6. associate-*l/94.0%

        \[\leadsto \left|x \cdot \left(-\frac{z}{y}\right) + \color{blue}{\frac{1 \cdot \left(x + 4\right)}{y}}\right| \]
      7. *-lft-identity94.0%

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

        \[\leadsto \left|\color{blue}{\frac{x + 4}{y} + x \cdot \left(-\frac{z}{y}\right)}\right| \]
      9. distribute-rgt-neg-out94.0%

        \[\leadsto \left|\frac{x + 4}{y} + \color{blue}{\left(-x \cdot \frac{z}{y}\right)}\right| \]
      10. sub-neg94.0%

        \[\leadsto \left|\color{blue}{\frac{x + 4}{y} - x \cdot \frac{z}{y}}\right| \]
      11. associate-*r/96.5%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      12. div-sub98.0%

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

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

    if 4.2e14 < x

    1. Initial program 88.4%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/87.4%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/94.9%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified94.9%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in x around 0 99.7%

      \[\leadsto \left|\color{blue}{x \cdot \left(\frac{1}{y} - \frac{z}{y}\right) + 4 \cdot \frac{1}{y}}\right| \]
    5. Step-by-step derivation
      1. sub-neg99.7%

        \[\leadsto \left|x \cdot \color{blue}{\left(\frac{1}{y} + \left(-\frac{z}{y}\right)\right)} + 4 \cdot \frac{1}{y}\right| \]
      2. +-commutative99.7%

        \[\leadsto \left|x \cdot \color{blue}{\left(\left(-\frac{z}{y}\right) + \frac{1}{y}\right)} + 4 \cdot \frac{1}{y}\right| \]
      3. distribute-lft-in94.8%

        \[\leadsto \left|\color{blue}{\left(x \cdot \left(-\frac{z}{y}\right) + x \cdot \frac{1}{y}\right)} + 4 \cdot \frac{1}{y}\right| \]
      4. associate-+r+94.8%

        \[\leadsto \left|\color{blue}{x \cdot \left(-\frac{z}{y}\right) + \left(x \cdot \frac{1}{y} + 4 \cdot \frac{1}{y}\right)}\right| \]
      5. distribute-rgt-in94.8%

        \[\leadsto \left|x \cdot \left(-\frac{z}{y}\right) + \color{blue}{\frac{1}{y} \cdot \left(x + 4\right)}\right| \]
      6. associate-*l/94.9%

        \[\leadsto \left|x \cdot \left(-\frac{z}{y}\right) + \color{blue}{\frac{1 \cdot \left(x + 4\right)}{y}}\right| \]
      7. *-lft-identity94.9%

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

        \[\leadsto \left|\color{blue}{\frac{x + 4}{y} + x \cdot \left(-\frac{z}{y}\right)}\right| \]
      9. distribute-rgt-neg-out94.9%

        \[\leadsto \left|\frac{x + 4}{y} + \color{blue}{\left(-x \cdot \frac{z}{y}\right)}\right| \]
      10. sub-neg94.9%

        \[\leadsto \left|\color{blue}{\frac{x + 4}{y} - x \cdot \frac{z}{y}}\right| \]
      11. associate-*r/87.4%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      12. div-sub92.3%

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

      \[\leadsto \left|\color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}}\right| \]
    7. Taylor expanded in x around inf 92.3%

      \[\leadsto \left|\color{blue}{\frac{x \cdot \left(1 - z\right)}{y}}\right| \]
    8. Step-by-step derivation
      1. associate-/l*99.9%

        \[\leadsto \left|\color{blue}{\frac{x}{\frac{y}{1 - z}}}\right| \]
    9. Simplified99.9%

      \[\leadsto \left|\color{blue}{\frac{x}{\frac{y}{1 - z}}}\right| \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.5%

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

Alternative 5: 84.4% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;z \leq -1.8 \cdot 10^{+136} \lor \neg \left(z \leq 8.2 \cdot 10^{+49}\right):\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y}\right|\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -1.8e+136) (not (<= z 8.2e+49)))
   (fabs (/ x (/ y z)))
   (fabs (/ (+ x 4.0) y))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.8e+136) || !(z <= 8.2e+49)) {
		tmp = fabs((x / (y / z)));
	} else {
		tmp = fabs(((x + 4.0) / y));
	}
	return tmp;
}
NOTE: y should be positive before calling this 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 ((z <= (-1.8d+136)) .or. (.not. (z <= 8.2d+49))) then
        tmp = abs((x / (y / z)))
    else
        tmp = abs(((x + 4.0d0) / y))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.8e+136) || !(z <= 8.2e+49)) {
		tmp = Math.abs((x / (y / z)));
	} else {
		tmp = Math.abs(((x + 4.0) / y));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if (z <= -1.8e+136) or not (z <= 8.2e+49):
		tmp = math.fabs((x / (y / z)))
	else:
		tmp = math.fabs(((x + 4.0) / y))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if ((z <= -1.8e+136) || !(z <= 8.2e+49))
		tmp = abs(Float64(x / Float64(y / z)));
	else
		tmp = abs(Float64(Float64(x + 4.0) / y));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -1.8e+136) || ~((z <= 8.2e+49)))
		tmp = abs((x / (y / z)));
	else
		tmp = abs(((x + 4.0) / y));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[Or[LessEqual[z, -1.8e+136], N[Not[LessEqual[z, 8.2e+49]], $MachinePrecision]], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8 \cdot 10^{+136} \lor \neg \left(z \leq 8.2 \cdot 10^{+49}\right):\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{x + 4}{y}\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.80000000000000003e136 or 8.2e49 < z

    1. Initial program 89.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/88.0%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/87.8%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified87.8%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in z around inf 68.6%

      \[\leadsto \left|\color{blue}{-1 \cdot \frac{x \cdot z}{y}}\right| \]
    5. Step-by-step derivation
      1. associate-*r/68.6%

        \[\leadsto \left|\color{blue}{\frac{-1 \cdot \left(x \cdot z\right)}{y}}\right| \]
      2. neg-mul-168.6%

        \[\leadsto \left|\frac{\color{blue}{-x \cdot z}}{y}\right| \]
      3. distribute-lft-neg-in68.6%

        \[\leadsto \left|\frac{\color{blue}{\left(-x\right) \cdot z}}{y}\right| \]
      4. associate-*l/71.2%

        \[\leadsto \left|\color{blue}{\frac{-x}{y} \cdot z}\right| \]
      5. *-commutative71.2%

        \[\leadsto \left|\color{blue}{z \cdot \frac{-x}{y}}\right| \]
    6. Simplified71.2%

      \[\leadsto \left|\color{blue}{z \cdot \frac{-x}{y}}\right| \]
    7. Step-by-step derivation
      1. *-commutative71.2%

        \[\leadsto \left|\color{blue}{\frac{-x}{y} \cdot z}\right| \]
      2. distribute-frac-neg71.2%

        \[\leadsto \left|\color{blue}{\left(-\frac{x}{y}\right)} \cdot z\right| \]
      3. distribute-lft-neg-in71.2%

        \[\leadsto \left|\color{blue}{-\frac{x}{y} \cdot z}\right| \]
      4. associate-/r/75.8%

        \[\leadsto \left|-\color{blue}{\frac{x}{\frac{y}{z}}}\right| \]
      5. distribute-neg-frac75.8%

        \[\leadsto \left|\color{blue}{\frac{-x}{\frac{y}{z}}}\right| \]
      6. add-sqr-sqrt38.2%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{\frac{y}{z}}\right| \]
      7. sqrt-unprod59.9%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}{\frac{y}{z}}\right| \]
      8. sqr-neg59.9%

        \[\leadsto \left|\frac{\sqrt{\color{blue}{x \cdot x}}}{\frac{y}{z}}\right| \]
      9. sqrt-unprod37.4%

        \[\leadsto \left|\frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{\frac{y}{z}}\right| \]
      10. add-sqr-sqrt75.8%

        \[\leadsto \left|\frac{\color{blue}{x}}{\frac{y}{z}}\right| \]
    8. Applied egg-rr75.8%

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

    if -1.80000000000000003e136 < z < 8.2e49

    1. Initial program 94.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/97.6%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/97.6%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified97.6%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in z around 0 95.5%

      \[\leadsto \left|\color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}}\right| \]
    5. Step-by-step derivation
      1. +-commutative95.5%

        \[\leadsto \left|\color{blue}{\frac{x}{y} + 4 \cdot \frac{1}{y}}\right| \]
      2. *-rgt-identity95.5%

        \[\leadsto \left|\frac{\color{blue}{x \cdot 1}}{y} + 4 \cdot \frac{1}{y}\right| \]
      3. associate-*r/95.4%

        \[\leadsto \left|\color{blue}{x \cdot \frac{1}{y}} + 4 \cdot \frac{1}{y}\right| \]
      4. distribute-rgt-in95.4%

        \[\leadsto \left|\color{blue}{\frac{1}{y} \cdot \left(x + 4\right)}\right| \]
      5. associate-*l/95.5%

        \[\leadsto \left|\color{blue}{\frac{1 \cdot \left(x + 4\right)}{y}}\right| \]
      6. *-lft-identity95.5%

        \[\leadsto \left|\frac{\color{blue}{x + 4}}{y}\right| \]
    6. Simplified95.5%

      \[\leadsto \left|\color{blue}{\frac{x + 4}{y}}\right| \]
  3. Recombined 2 regimes into one program.
  4. Final simplification88.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.8 \cdot 10^{+136} \lor \neg \left(z \leq 8.2 \cdot 10^{+49}\right):\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y}\right|\\ \end{array} \]

Alternative 6: 68.4% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \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} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -10.5) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 y))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -10.5) || !(x <= 4.0)) {
		tmp = fabs((x / y));
	} else {
		tmp = fabs((4.0 / y));
	}
	return tmp;
}
NOTE: y should be positive before calling this 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 <= (-10.5d0)) .or. (.not. (x <= 4.0d0))) then
        tmp = abs((x / y))
    else
        tmp = abs((4.0d0 / y))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -10.5) || !(x <= 4.0)) {
		tmp = Math.abs((x / y));
	} else {
		tmp = Math.abs((4.0 / y));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if (x <= -10.5) or not (x <= 4.0):
		tmp = math.fabs((x / y))
	else:
		tmp = math.fabs((4.0 / y))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if ((x <= -10.5) || !(x <= 4.0))
		tmp = abs(Float64(x / y));
	else
		tmp = abs(Float64(4.0 / y));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -10.5) || ~((x <= 4.0)))
		tmp = abs((x / y));
	else
		tmp = abs((4.0 / y));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[Or[LessEqual[x, -10.5], N[Not[LessEqual[x, 4.0]], $MachinePrecision]], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\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}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -10.5 or 4 < x

    1. Initial program 89.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/87.8%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/94.8%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified94.8%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in z around 0 67.0%

      \[\leadsto \left|\color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}}\right| \]
    5. Step-by-step derivation
      1. associate-*r/67.0%

        \[\leadsto \left|\color{blue}{\frac{4 \cdot 1}{y}} + \frac{x}{y}\right| \]
      2. metadata-eval67.0%

        \[\leadsto \left|\frac{\color{blue}{4}}{y} + \frac{x}{y}\right| \]
    6. Simplified67.0%

      \[\leadsto \left|\color{blue}{\frac{4}{y} + \frac{x}{y}}\right| \]
    7. Taylor expanded in x around inf 65.2%

      \[\leadsto \left|\color{blue}{\frac{x}{y}}\right| \]

    if -10.5 < x < 4

    1. Initial program 94.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/99.9%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/93.8%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified93.8%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in x around 0 80.8%

      \[\leadsto \left|\color{blue}{\frac{4}{y}}\right| \]
  3. Recombined 2 regimes into one program.
  4. Final simplification73.6%

    \[\leadsto \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 7: 69.0% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq -2.05 \cdot 10^{-39}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= x -2.05e-39)
   (fabs (* z (/ x y)))
   (if (<= x 4.0) (fabs (/ 4.0 y)) (fabs (/ x y)))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if (x <= -2.05e-39) {
		tmp = fabs((z * (x / y)));
	} else if (x <= 4.0) {
		tmp = fabs((4.0 / y));
	} else {
		tmp = fabs((x / y));
	}
	return tmp;
}
NOTE: y should be positive before calling this 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 <= (-2.05d-39)) then
        tmp = abs((z * (x / y)))
    else if (x <= 4.0d0) then
        tmp = abs((4.0d0 / y))
    else
        tmp = abs((x / y))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -2.05e-39) {
		tmp = Math.abs((z * (x / y)));
	} else if (x <= 4.0) {
		tmp = Math.abs((4.0 / y));
	} else {
		tmp = Math.abs((x / y));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if x <= -2.05e-39:
		tmp = math.fabs((z * (x / y)))
	elif x <= 4.0:
		tmp = math.fabs((4.0 / y))
	else:
		tmp = math.fabs((x / y))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if (x <= -2.05e-39)
		tmp = abs(Float64(z * Float64(x / y)));
	elseif (x <= 4.0)
		tmp = abs(Float64(4.0 / y));
	else
		tmp = abs(Float64(x / y));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -2.05e-39)
		tmp = abs((z * (x / y)));
	elseif (x <= 4.0)
		tmp = abs((4.0 / y));
	else
		tmp = abs((x / y));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[x, -2.05e-39], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.05 \cdot 10^{-39}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\

\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\left|\frac{4}{y}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{x}{y}\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.05e-39

    1. Initial program 91.6%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/88.9%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/94.9%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified94.9%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in z around inf 52.9%

      \[\leadsto \left|\color{blue}{-1 \cdot \frac{x \cdot z}{y}}\right| \]
    5. Step-by-step derivation
      1. associate-*r/52.9%

        \[\leadsto \left|\color{blue}{\frac{-1 \cdot \left(x \cdot z\right)}{y}}\right| \]
      2. neg-mul-152.9%

        \[\leadsto \left|\frac{\color{blue}{-x \cdot z}}{y}\right| \]
      3. distribute-lft-neg-in52.9%

        \[\leadsto \left|\frac{\color{blue}{\left(-x\right) \cdot z}}{y}\right| \]
      4. associate-*l/65.1%

        \[\leadsto \left|\color{blue}{\frac{-x}{y} \cdot z}\right| \]
      5. *-commutative65.1%

        \[\leadsto \left|\color{blue}{z \cdot \frac{-x}{y}}\right| \]
    6. Simplified65.1%

      \[\leadsto \left|\color{blue}{z \cdot \frac{-x}{y}}\right| \]
    7. Step-by-step derivation
      1. clear-num65.0%

        \[\leadsto \left|z \cdot \color{blue}{\frac{1}{\frac{y}{-x}}}\right| \]
      2. un-div-inv65.1%

        \[\leadsto \left|\color{blue}{\frac{z}{\frac{y}{-x}}}\right| \]
      3. add-sqr-sqrt65.0%

        \[\leadsto \left|\frac{z}{\frac{y}{\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}}\right| \]
      4. sqrt-unprod55.2%

        \[\leadsto \left|\frac{z}{\frac{y}{\color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}}}\right| \]
      5. sqr-neg55.2%

        \[\leadsto \left|\frac{z}{\frac{y}{\sqrt{\color{blue}{x \cdot x}}}}\right| \]
      6. sqrt-unprod0.0%

        \[\leadsto \left|\frac{z}{\frac{y}{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}}\right| \]
      7. add-sqr-sqrt65.1%

        \[\leadsto \left|\frac{z}{\frac{y}{\color{blue}{x}}}\right| \]
    8. Applied egg-rr65.1%

      \[\leadsto \left|\color{blue}{\frac{z}{\frac{y}{x}}}\right| \]
    9. Step-by-step derivation
      1. clear-num65.0%

        \[\leadsto \left|\color{blue}{\frac{1}{\frac{\frac{y}{x}}{z}}}\right| \]
      2. associate-/r/65.0%

        \[\leadsto \left|\color{blue}{\frac{1}{\frac{y}{x}} \cdot z}\right| \]
      3. clear-num65.1%

        \[\leadsto \left|\color{blue}{\frac{x}{y}} \cdot z\right| \]
    10. Applied egg-rr65.1%

      \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z}\right| \]

    if -2.05e-39 < x < 4

    1. Initial program 94.6%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/100.0%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/93.5%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified93.5%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in x around 0 82.9%

      \[\leadsto \left|\color{blue}{\frac{4}{y}}\right| \]

    if 4 < x

    1. Initial program 88.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. associate-*l/88.0%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. associate-*r/95.2%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
    3. Simplified95.2%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
    4. Taylor expanded in z around 0 70.0%

      \[\leadsto \left|\color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}}\right| \]
    5. Step-by-step derivation
      1. associate-*r/70.0%

        \[\leadsto \left|\color{blue}{\frac{4 \cdot 1}{y}} + \frac{x}{y}\right| \]
      2. metadata-eval70.0%

        \[\leadsto \left|\frac{\color{blue}{4}}{y} + \frac{x}{y}\right| \]
    6. Simplified70.0%

      \[\leadsto \left|\color{blue}{\frac{4}{y} + \frac{x}{y}}\right| \]
    7. Taylor expanded in x around inf 68.2%

      \[\leadsto \left|\color{blue}{\frac{x}{y}}\right| \]
  3. Recombined 3 regimes into one program.
  4. Final simplification75.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.05 \cdot 10^{-39}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 8: 40.0% accurate, 1.1× speedup?

\[\begin{array}{l} y = |y|\\ \\ \left|\frac{4}{y}\right| \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z) :precision binary64 (fabs (/ 4.0 y)))
y = abs(y);
double code(double x, double y, double z) {
	return fabs((4.0 / y));
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = abs((4.0d0 / y))
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	return Math.abs((4.0 / y));
}
y = abs(y)
def code(x, y, z):
	return math.fabs((4.0 / y))
y = abs(y)
function code(x, y, z)
	return abs(Float64(4.0 / y))
end
y = abs(y)
function tmp = code(x, y, z)
	tmp = abs((4.0 / y));
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\left|\frac{4}{y}\right|
\end{array}
Derivation
  1. Initial program 92.5%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Step-by-step derivation
    1. associate-*l/94.3%

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
    2. associate-*r/94.2%

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
  3. Simplified94.2%

    \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - x \cdot \frac{z}{y}\right|} \]
  4. Taylor expanded in x around 0 46.0%

    \[\leadsto \left|\color{blue}{\frac{4}{y}}\right| \]
  5. Final simplification46.0%

    \[\leadsto \left|\frac{4}{y}\right| \]

Reproduce

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