fabs fraction 1

Percentage Accurate: 91.6% → 99.2%
Time: 8.3s
Alternatives: 15
Speedup: 0.5×

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 15 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.6% 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.2% accurate, 0.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;y\_m \leq 1.15 \cdot 10^{-108}:\\ \;\;\;\;\left|\frac{-1}{y\_m} \cdot \mathsf{fma}\left(x, z, -4 - x\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y\_m}, \frac{-4 - x}{y\_m}\right)\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= y_m 1.15e-108)
   (fabs (* (/ -1.0 y_m) (fma x z (- -4.0 x))))
   (fabs (fma x (/ z y_m) (/ (- -4.0 x) y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (y_m <= 1.15e-108) {
		tmp = fabs(((-1.0 / y_m) * fma(x, z, (-4.0 - x))));
	} else {
		tmp = fabs(fma(x, (z / y_m), ((-4.0 - x) / y_m)));
	}
	return tmp;
}
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (y_m <= 1.15e-108)
		tmp = abs(Float64(Float64(-1.0 / y_m) * fma(x, z, Float64(-4.0 - x))));
	else
		tmp = abs(fma(x, Float64(z / y_m), Float64(Float64(-4.0 - x) / y_m)));
	end
	return tmp
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[y$95$m, 1.15e-108], N[Abs[N[(N[(-1.0 / y$95$m), $MachinePrecision] * N[(x * z + N[(-4.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision] + N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 1.15 \cdot 10^{-108}:\\
\;\;\;\;\left|\frac{-1}{y\_m} \cdot \mathsf{fma}\left(x, z, -4 - x\right)\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y\_m}, \frac{-4 - x}{y\_m}\right)\right|\\


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

    1. Initial program 88.4%

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

      \[\leadsto \color{blue}{\left|\frac{-1}{y} \cdot \mathsf{fma}\left(x, z, -4 - x\right)\right|} \]
    3. Add Preprocessing

    if 1.14999999999999998e-108 < y

    1. Initial program 94.4%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub94.4%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac99.9%

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in99.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg99.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval99.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 97.4% accurate, 0.3× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \frac{x + 4}{y\_m}\\ t_1 := \left|z \cdot \frac{x}{y\_m} - t\_0\right|\\ \mathbf{if}\;t\_1 \leq 4 \cdot 10^{+117}:\\ \;\;\;\;\left|t\_0 - \frac{x}{\frac{y\_m}{z}}\right|\\ \mathbf{elif}\;t\_1 \leq \infty:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{-1}{y\_m} \cdot \left(x \cdot z\right)\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (let* ((t_0 (/ (+ x 4.0) y_m)) (t_1 (fabs (- (* z (/ x y_m)) t_0))))
   (if (<= t_1 4e+117)
     (fabs (- t_0 (/ x (/ y_m z))))
     (if (<= t_1 INFINITY) t_1 (fabs (* (/ -1.0 y_m) (* x z)))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = (x + 4.0) / y_m;
	double t_1 = fabs(((z * (x / y_m)) - t_0));
	double tmp;
	if (t_1 <= 4e+117) {
		tmp = fabs((t_0 - (x / (y_m / z))));
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = t_1;
	} else {
		tmp = fabs(((-1.0 / y_m) * (x * z)));
	}
	return tmp;
}
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double t_0 = (x + 4.0) / y_m;
	double t_1 = Math.abs(((z * (x / y_m)) - t_0));
	double tmp;
	if (t_1 <= 4e+117) {
		tmp = Math.abs((t_0 - (x / (y_m / z))));
	} else if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else {
		tmp = Math.abs(((-1.0 / y_m) * (x * z)));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	t_0 = (x + 4.0) / y_m
	t_1 = math.fabs(((z * (x / y_m)) - t_0))
	tmp = 0
	if t_1 <= 4e+117:
		tmp = math.fabs((t_0 - (x / (y_m / z))))
	elif t_1 <= math.inf:
		tmp = t_1
	else:
		tmp = math.fabs(((-1.0 / y_m) * (x * z)))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	t_0 = Float64(Float64(x + 4.0) / y_m)
	t_1 = abs(Float64(Float64(z * Float64(x / y_m)) - t_0))
	tmp = 0.0
	if (t_1 <= 4e+117)
		tmp = abs(Float64(t_0 - Float64(x / Float64(y_m / z))));
	elseif (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = abs(Float64(Float64(-1.0 / y_m) * Float64(x * z)));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	t_0 = (x + 4.0) / y_m;
	t_1 = abs(((z * (x / y_m)) - t_0));
	tmp = 0.0;
	if (t_1 <= 4e+117)
		tmp = abs((t_0 - (x / (y_m / z))));
	elseif (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = abs(((-1.0 / y_m) * (x * z)));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, 4e+117], N[Abs[N[(t$95$0 - N[(x / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, Infinity], t$95$1, N[Abs[N[(N[(-1.0 / y$95$m), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := \frac{x + 4}{y\_m}\\
t_1 := \left|z \cdot \frac{x}{y\_m} - t\_0\right|\\
\mathbf{if}\;t\_1 \leq 4 \cdot 10^{+117}:\\
\;\;\;\;\left|t\_0 - \frac{x}{\frac{y\_m}{z}}\right|\\

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))) < 4.0000000000000002e117

    1. Initial program 93.4%

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

        \[\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. clear-num99.9%

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

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

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

    if 4.0000000000000002e117 < (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))) < +inf.0

    1. Initial program 99.9%

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

    if +inf.0 < (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)))

    1. Initial program 0.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Simplified100.0%

      \[\leadsto \color{blue}{\left|\frac{-1}{y} \cdot \mathsf{fma}\left(x, z, -4 - x\right)\right|} \]
    3. Add Preprocessing
    4. Taylor expanded in z around inf 82.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left|z \cdot \frac{x}{y} - \frac{x + 4}{y}\right| \leq 4 \cdot 10^{+117}:\\ \;\;\;\;\left|\frac{x + 4}{y} - \frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;\left|z \cdot \frac{x}{y} - \frac{x + 4}{y}\right| \leq \infty:\\ \;\;\;\;\left|z \cdot \frac{x}{y} - \frac{x + 4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{-1}{y} \cdot \left(x \cdot z\right)\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 95.6% accurate, 0.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \left|z \cdot \frac{x}{y\_m} - \frac{x + 4}{y\_m}\right|\\ \mathbf{if}\;t\_0 \leq \infty:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{-1}{y\_m} \cdot \left(x \cdot z\right)\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (let* ((t_0 (fabs (- (* z (/ x y_m)) (/ (+ x 4.0) y_m)))))
   (if (<= t_0 INFINITY) t_0 (fabs (* (/ -1.0 y_m) (* x z))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = fabs(((z * (x / y_m)) - ((x + 4.0) / y_m)));
	double tmp;
	if (t_0 <= ((double) INFINITY)) {
		tmp = t_0;
	} else {
		tmp = fabs(((-1.0 / y_m) * (x * z)));
	}
	return tmp;
}
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double t_0 = Math.abs(((z * (x / y_m)) - ((x + 4.0) / y_m)));
	double tmp;
	if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = t_0;
	} else {
		tmp = Math.abs(((-1.0 / y_m) * (x * z)));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	t_0 = math.fabs(((z * (x / y_m)) - ((x + 4.0) / y_m)))
	tmp = 0
	if t_0 <= math.inf:
		tmp = t_0
	else:
		tmp = math.fabs(((-1.0 / y_m) * (x * z)))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	t_0 = abs(Float64(Float64(z * Float64(x / y_m)) - Float64(Float64(x + 4.0) / y_m)))
	tmp = 0.0
	if (t_0 <= Inf)
		tmp = t_0;
	else
		tmp = abs(Float64(Float64(-1.0 / y_m) * Float64(x * z)));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	t_0 = abs(((z * (x / y_m)) - ((x + 4.0) / y_m)));
	tmp = 0.0;
	if (t_0 <= Inf)
		tmp = t_0;
	else
		tmp = abs(((-1.0 / y_m) * (x * z)));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[Abs[N[(N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], t$95$0, N[Abs[N[(N[(-1.0 / y$95$m), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := \left|z \cdot \frac{x}{y\_m} - \frac{x + 4}{y\_m}\right|\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))) < +inf.0

    1. Initial program 96.3%

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

    if +inf.0 < (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)))

    1. Initial program 0.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Simplified100.0%

      \[\leadsto \color{blue}{\left|\frac{-1}{y} \cdot \mathsf{fma}\left(x, z, -4 - x\right)\right|} \]
    3. Add Preprocessing
    4. Taylor expanded in z around inf 82.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left|z \cdot \frac{x}{y} - \frac{x + 4}{y}\right| \leq \infty:\\ \;\;\;\;\left|z \cdot \frac{x}{y} - \frac{x + 4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{-1}{y} \cdot \left(x \cdot z\right)\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 99.0% accurate, 0.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;y\_m \leq 4 \cdot 10^{-109}:\\ \;\;\;\;\left|\frac{-1}{y\_m} \cdot \mathsf{fma}\left(x, z, -4 - x\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y\_m} - \frac{x}{\frac{y\_m}{z}}\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= y_m 4e-109)
   (fabs (* (/ -1.0 y_m) (fma x z (- -4.0 x))))
   (fabs (- (/ (+ x 4.0) y_m) (/ x (/ y_m z))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (y_m <= 4e-109) {
		tmp = fabs(((-1.0 / y_m) * fma(x, z, (-4.0 - x))));
	} else {
		tmp = fabs((((x + 4.0) / y_m) - (x / (y_m / z))));
	}
	return tmp;
}
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (y_m <= 4e-109)
		tmp = abs(Float64(Float64(-1.0 / y_m) * fma(x, z, Float64(-4.0 - x))));
	else
		tmp = abs(Float64(Float64(Float64(x + 4.0) / y_m) - Float64(x / Float64(y_m / z))));
	end
	return tmp
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[y$95$m, 4e-109], N[Abs[N[(N[(-1.0 / y$95$m), $MachinePrecision] * N[(x * z + N[(-4.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision] - N[(x / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 4 \cdot 10^{-109}:\\
\;\;\;\;\left|\frac{-1}{y\_m} \cdot \mathsf{fma}\left(x, z, -4 - x\right)\right|\\

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


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

    1. Initial program 88.4%

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

      \[\leadsto \color{blue}{\left|\frac{-1}{y} \cdot \mathsf{fma}\left(x, z, -4 - x\right)\right|} \]
    3. Add Preprocessing

    if 4e-109 < y

    1. Initial program 94.4%

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

        \[\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. clear-num99.8%

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

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

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

Alternative 5: 89.0% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -7.2 \cdot 10^{-17} \lor \neg \left(x \leq 8.5 \cdot 10^{+22}\right):\\ \;\;\;\;\left|\frac{x}{y\_m} - \frac{x}{\frac{y\_m}{z}}\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x + 4\right) - x \cdot z}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (or (<= x -7.2e-17) (not (<= x 8.5e+22)))
   (fabs (- (/ x y_m) (/ x (/ y_m z))))
   (/ (- (+ x 4.0) (* x z)) y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if ((x <= -7.2e-17) || !(x <= 8.5e+22)) {
		tmp = fabs(((x / y_m) - (x / (y_m / z))));
	} else {
		tmp = ((x + 4.0) - (x * z)) / y_m;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x <= (-7.2d-17)) .or. (.not. (x <= 8.5d+22))) then
        tmp = abs(((x / y_m) - (x / (y_m / z))))
    else
        tmp = ((x + 4.0d0) - (x * z)) / y_m
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if ((x <= -7.2e-17) || !(x <= 8.5e+22)) {
		tmp = Math.abs(((x / y_m) - (x / (y_m / z))));
	} else {
		tmp = ((x + 4.0) - (x * z)) / y_m;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if (x <= -7.2e-17) or not (x <= 8.5e+22):
		tmp = math.fabs(((x / y_m) - (x / (y_m / z))))
	else:
		tmp = ((x + 4.0) - (x * z)) / y_m
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if ((x <= -7.2e-17) || !(x <= 8.5e+22))
		tmp = abs(Float64(Float64(x / y_m) - Float64(x / Float64(y_m / z))));
	else
		tmp = Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y_m);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if ((x <= -7.2e-17) || ~((x <= 8.5e+22)))
		tmp = abs(((x / y_m) - (x / (y_m / z))));
	else
		tmp = ((x + 4.0) - (x * z)) / y_m;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[Or[LessEqual[x, -7.2e-17], N[Not[LessEqual[x, 8.5e+22]], $MachinePrecision]], N[Abs[N[(N[(x / y$95$m), $MachinePrecision] - N[(x / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.2 \cdot 10^{-17} \lor \neg \left(x \leq 8.5 \cdot 10^{+22}\right):\\
\;\;\;\;\left|\frac{x}{y\_m} - \frac{x}{\frac{y\_m}{z}}\right|\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(x + 4\right) - x \cdot z}{y\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -7.1999999999999999e-17 or 8.49999999999999979e22 < x

    1. Initial program 87.0%

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

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

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

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

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

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

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

    if -7.1999999999999999e-17 < x < 8.49999999999999979e22

    1. Initial program 93.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub93.0%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac95.2%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative95.2%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in95.2%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg95.2%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval95.2%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified95.2%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine95.2%

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv93.0%

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt46.2%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/48.5%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div48.5%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr48.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7.2 \cdot 10^{-17} \lor \neg \left(x \leq 8.5 \cdot 10^{+22}\right):\\ \;\;\;\;\left|\frac{x}{y} - \frac{x}{\frac{y}{z}}\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x + 4\right) - x \cdot z}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 79.5% accurate, 6.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -7400:\\ \;\;\;\;\frac{x}{y\_m} \cdot \left(-1 + z\right)\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\frac{4 - x \cdot z}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(1 - z\right)}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x -7400.0)
   (* (/ x y_m) (+ -1.0 z))
   (if (<= x 4.0) (/ (- 4.0 (* x z)) y_m) (/ (* x (- 1.0 z)) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -7400.0) {
		tmp = (x / y_m) * (-1.0 + z);
	} else if (x <= 4.0) {
		tmp = (4.0 - (x * z)) / y_m;
	} else {
		tmp = (x * (1.0 - z)) / y_m;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-7400.0d0)) then
        tmp = (x / y_m) * ((-1.0d0) + z)
    else if (x <= 4.0d0) then
        tmp = (4.0d0 - (x * z)) / y_m
    else
        tmp = (x * (1.0d0 - z)) / y_m
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -7400.0) {
		tmp = (x / y_m) * (-1.0 + z);
	} else if (x <= 4.0) {
		tmp = (4.0 - (x * z)) / y_m;
	} else {
		tmp = (x * (1.0 - z)) / y_m;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= -7400.0:
		tmp = (x / y_m) * (-1.0 + z)
	elif x <= 4.0:
		tmp = (4.0 - (x * z)) / y_m
	else:
		tmp = (x * (1.0 - z)) / y_m
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= -7400.0)
		tmp = Float64(Float64(x / y_m) * Float64(-1.0 + z));
	elseif (x <= 4.0)
		tmp = Float64(Float64(4.0 - Float64(x * z)) / y_m);
	else
		tmp = Float64(Float64(x * Float64(1.0 - z)) / y_m);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= -7400.0)
		tmp = (x / y_m) * (-1.0 + z);
	elseif (x <= 4.0)
		tmp = (4.0 - (x * z)) / y_m;
	else
		tmp = (x * (1.0 - z)) / y_m;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, -7400.0], N[(N[(x / y$95$m), $MachinePrecision] * N[(-1.0 + z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.0], N[(N[(4.0 - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -7400:\\
\;\;\;\;\frac{x}{y\_m} \cdot \left(-1 + z\right)\\

\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\frac{4 - x \cdot z}{y\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(1 - z\right)}{y\_m}\\


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

    1. Initial program 86.2%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub86.2%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified96.5%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt52.3%

        \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
      2. fabs-sqr52.3%

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
      3. add-sqr-sqrt52.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      4. fma-undefine46.0%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      5. associate-*r/42.8%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      6. associate-*l/44.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      7. div-inv44.3%

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

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

        \[\leadsto \frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y} \]
      10. distribute-neg-in44.3%

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

        \[\leadsto \frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y} \]
      12. cancel-sign-sub-inv44.3%

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

        \[\leadsto \frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}} \]
      14. associate-*l/42.8%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
      15. sub-div51.3%

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(z - 1\right)}{y}} \]
    8. Step-by-step derivation
      1. sub-neg51.3%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot z + x \cdot -1}}{y} \]
      4. *-commutative51.3%

        \[\leadsto \frac{x \cdot z + \color{blue}{-1 \cdot x}}{y} \]
      5. neg-mul-151.3%

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

        \[\leadsto \frac{\color{blue}{x \cdot z - x}}{y} \]
      7. div-sub42.8%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y} - \frac{x}{y}} \]
      8. associate-*l/44.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} - \frac{x}{y} \]
      9. fmm-def44.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, z, -\frac{x}{y}\right)} \]
      10. neg-mul-144.4%

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, z, \color{blue}{-1 \cdot \frac{x}{y}}\right) \]
      11. fma-define44.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z + -1 \cdot \frac{x}{y}} \]
      12. *-commutative44.3%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\frac{x}{y} \cdot -1} \]
      13. distribute-lft-out54.5%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(z + -1\right)} \]
    9. Simplified54.5%

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

    if -7400 < x < 4

    1. Initial program 93.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub93.7%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac96.0%

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in96.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg96.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval96.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified96.0%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine96.0%

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv93.7%

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

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub93.7%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt44.5%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      13. fabs-sqr44.5%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt45.9%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/48.1%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div48.2%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr48.2%

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

      \[\leadsto \frac{\color{blue}{4} - x \cdot z}{y} \]

    if 4 < x

    1. Initial program 85.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub85.9%

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

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

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def94.7%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac94.7%

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in94.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg94.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval94.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified94.7%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine89.4%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt33.2%

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

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt33.8%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/32.0%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div35.5%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr35.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7400:\\ \;\;\;\;\frac{x}{y} \cdot \left(-1 + z\right)\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\frac{4 - x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(1 - z\right)}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 74.9% accurate, 6.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -1.45 \cdot 10^{-17}:\\ \;\;\;\;x \cdot \frac{-1 + z}{y\_m}\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{+23}:\\ \;\;\;\;\frac{x + 4}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{1 - z}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x -1.45e-17)
   (* x (/ (+ -1.0 z) y_m))
   (if (<= x 2.9e+23) (/ (+ x 4.0) y_m) (* x (/ (- 1.0 z) y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -1.45e-17) {
		tmp = x * ((-1.0 + z) / y_m);
	} else if (x <= 2.9e+23) {
		tmp = (x + 4.0) / y_m;
	} else {
		tmp = x * ((1.0 - z) / y_m);
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-1.45d-17)) then
        tmp = x * (((-1.0d0) + z) / y_m)
    else if (x <= 2.9d+23) then
        tmp = (x + 4.0d0) / y_m
    else
        tmp = x * ((1.0d0 - z) / y_m)
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -1.45e-17) {
		tmp = x * ((-1.0 + z) / y_m);
	} else if (x <= 2.9e+23) {
		tmp = (x + 4.0) / y_m;
	} else {
		tmp = x * ((1.0 - z) / y_m);
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= -1.45e-17:
		tmp = x * ((-1.0 + z) / y_m)
	elif x <= 2.9e+23:
		tmp = (x + 4.0) / y_m
	else:
		tmp = x * ((1.0 - z) / y_m)
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= -1.45e-17)
		tmp = Float64(x * Float64(Float64(-1.0 + z) / y_m));
	elseif (x <= 2.9e+23)
		tmp = Float64(Float64(x + 4.0) / y_m);
	else
		tmp = Float64(x * Float64(Float64(1.0 - z) / y_m));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= -1.45e-17)
		tmp = x * ((-1.0 + z) / y_m);
	elseif (x <= 2.9e+23)
		tmp = (x + 4.0) / y_m;
	else
		tmp = x * ((1.0 - z) / y_m);
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, -1.45e-17], N[(x * N[(N[(-1.0 + z), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.9e+23], N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision], N[(x * N[(N[(1.0 - z), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{-17}:\\
\;\;\;\;x \cdot \frac{-1 + z}{y\_m}\\

\mathbf{elif}\;x \leq 2.9 \cdot 10^{+23}:\\
\;\;\;\;\frac{x + 4}{y\_m}\\

\mathbf{else}:\\
\;\;\;\;x \cdot \frac{1 - z}{y\_m}\\


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

    1. Initial program 86.8%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub86.8%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac96.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative96.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in96.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg96.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval96.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified96.6%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt54.5%

        \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
      2. fabs-sqr54.5%

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
      3. add-sqr-sqrt55.1%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      4. fma-undefine48.6%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      5. associate-*r/45.6%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      6. associate-*l/47.0%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      7. div-inv46.9%

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

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y} \]
      9. metadata-eval46.9%

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

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y} \]
      11. +-commutative46.9%

        \[\leadsto \frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y} \]
      12. cancel-sign-sub-inv46.9%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}} \]
      13. div-inv47.0%

        \[\leadsto \frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}} \]
      14. associate-*l/45.6%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
      15. sub-div53.6%

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(z - 1\right)}{y}} \]
    8. Step-by-step derivation
      1. sub-neg52.0%

        \[\leadsto \frac{x \cdot \color{blue}{\left(z + \left(-1\right)\right)}}{y} \]
      2. metadata-eval52.0%

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

        \[\leadsto \frac{\color{blue}{x \cdot z + x \cdot -1}}{y} \]
      4. *-commutative52.1%

        \[\leadsto \frac{x \cdot z + \color{blue}{-1 \cdot x}}{y} \]
      5. neg-mul-152.1%

        \[\leadsto \frac{x \cdot z + \color{blue}{\left(-x\right)}}{y} \]
      6. sub-neg52.1%

        \[\leadsto \frac{\color{blue}{x \cdot z - x}}{y} \]
      7. div-sub44.0%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y} - \frac{x}{y}} \]
      8. associate-*l/45.4%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} - \frac{x}{y} \]
      9. fmm-def45.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, z, -\frac{x}{y}\right)} \]
      10. neg-mul-145.4%

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, z, \color{blue}{-1 \cdot \frac{x}{y}}\right) \]
      11. fma-define45.4%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z + -1 \cdot \frac{x}{y}} \]
      12. *-commutative45.4%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\frac{x}{y} \cdot -1} \]
      13. distribute-lft-out55.1%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(z + -1\right)} \]
    9. Simplified55.1%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(z + -1\right)} \]
    10. Taylor expanded in x around 0 52.0%

      \[\leadsto \color{blue}{\frac{x \cdot \left(z - 1\right)}{y}} \]
    11. Step-by-step derivation
      1. sub-neg52.0%

        \[\leadsto \frac{x \cdot \color{blue}{\left(z + \left(-1\right)\right)}}{y} \]
      2. metadata-eval52.0%

        \[\leadsto \frac{x \cdot \left(z + \color{blue}{-1}\right)}{y} \]
      3. associate-*r/55.1%

        \[\leadsto \color{blue}{x \cdot \frac{z + -1}{y}} \]
    12. Simplified55.1%

      \[\leadsto \color{blue}{x \cdot \frac{z + -1}{y}} \]

    if -1.4500000000000001e-17 < x < 2.90000000000000013e23

    1. Initial program 93.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub93.0%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac95.3%

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in95.3%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg95.3%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval95.3%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified95.3%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine95.3%

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv93.0%

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

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

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

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      13. fabs-sqr45.3%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt46.6%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/48.9%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div48.9%

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

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

      \[\leadsto \color{blue}{\frac{4 + x}{y}} \]

    if 2.90000000000000013e23 < x

    1. Initial program 87.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub87.0%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac96.2%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative96.2%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in96.2%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg96.2%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval96.2%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified96.2%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine90.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt33.2%

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

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt33.8%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/31.9%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div35.6%

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{1 - z}{y}} \]
    9. Simplified37.5%

      \[\leadsto \color{blue}{x \cdot \frac{1 - z}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification43.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.45 \cdot 10^{-17}:\\ \;\;\;\;x \cdot \frac{-1 + z}{y}\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{+23}:\\ \;\;\;\;\frac{x + 4}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{1 - z}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 80.2% accurate, 7.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -20000:\\ \;\;\;\;\frac{x}{y\_m} \cdot \left(-1 + z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x + 4\right) - x \cdot z}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x -20000.0) (* (/ x y_m) (+ -1.0 z)) (/ (- (+ x 4.0) (* x z)) y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -20000.0) {
		tmp = (x / y_m) * (-1.0 + z);
	} else {
		tmp = ((x + 4.0) - (x * z)) / y_m;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-20000.0d0)) then
        tmp = (x / y_m) * ((-1.0d0) + z)
    else
        tmp = ((x + 4.0d0) - (x * z)) / y_m
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -20000.0) {
		tmp = (x / y_m) * (-1.0 + z);
	} else {
		tmp = ((x + 4.0) - (x * z)) / y_m;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= -20000.0:
		tmp = (x / y_m) * (-1.0 + z)
	else:
		tmp = ((x + 4.0) - (x * z)) / y_m
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= -20000.0)
		tmp = Float64(Float64(x / y_m) * Float64(-1.0 + z));
	else
		tmp = Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y_m);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= -20000.0)
		tmp = (x / y_m) * (-1.0 + z);
	else
		tmp = ((x + 4.0) - (x * z)) / y_m;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, -20000.0], N[(N[(x / y$95$m), $MachinePrecision] * N[(-1.0 + z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -20000:\\
\;\;\;\;\frac{x}{y\_m} \cdot \left(-1 + z\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\left(x + 4\right) - x \cdot z}{y\_m}\\


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

    1. Initial program 86.2%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub86.2%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified96.5%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt52.3%

        \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
      2. fabs-sqr52.3%

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
      3. add-sqr-sqrt52.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      4. fma-undefine46.0%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      5. associate-*r/42.8%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      6. associate-*l/44.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      7. div-inv44.3%

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

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

        \[\leadsto \frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y} \]
      10. distribute-neg-in44.3%

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

        \[\leadsto \frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y} \]
      12. cancel-sign-sub-inv44.3%

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

        \[\leadsto \frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}} \]
      14. associate-*l/42.8%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
      15. sub-div51.3%

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(z - 1\right)}{y}} \]
    8. Step-by-step derivation
      1. sub-neg51.3%

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

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

        \[\leadsto \frac{\color{blue}{x \cdot z + x \cdot -1}}{y} \]
      4. *-commutative51.3%

        \[\leadsto \frac{x \cdot z + \color{blue}{-1 \cdot x}}{y} \]
      5. neg-mul-151.3%

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

        \[\leadsto \frac{\color{blue}{x \cdot z - x}}{y} \]
      7. div-sub42.8%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y} - \frac{x}{y}} \]
      8. associate-*l/44.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} - \frac{x}{y} \]
      9. fmm-def44.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, z, -\frac{x}{y}\right)} \]
      10. neg-mul-144.4%

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, z, \color{blue}{-1 \cdot \frac{x}{y}}\right) \]
      11. fma-define44.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z + -1 \cdot \frac{x}{y}} \]
      12. *-commutative44.3%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\frac{x}{y} \cdot -1} \]
      13. distribute-lft-out54.5%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(z + -1\right)} \]
    9. Simplified54.5%

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

    if -2e4 < x

    1. Initial program 91.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub91.5%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac95.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative95.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in95.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg95.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval95.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified95.6%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine94.1%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      13. fabs-sqr41.3%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt42.4%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/43.5%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div44.5%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr44.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -20000:\\ \;\;\;\;\frac{x}{y} \cdot \left(-1 + z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x + 4\right) - x \cdot z}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 68.6% accurate, 8.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -10.5:\\ \;\;\;\;\frac{x}{-y\_m}\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\frac{4}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x -10.5) (/ x (- y_m)) (if (<= x 4.0) (/ 4.0 y_m) (/ x y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -10.5) {
		tmp = x / -y_m;
	} else if (x <= 4.0) {
		tmp = 4.0 / y_m;
	} else {
		tmp = x / y_m;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-10.5d0)) then
        tmp = x / -y_m
    else if (x <= 4.0d0) then
        tmp = 4.0d0 / y_m
    else
        tmp = x / y_m
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -10.5) {
		tmp = x / -y_m;
	} else if (x <= 4.0) {
		tmp = 4.0 / y_m;
	} else {
		tmp = x / y_m;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= -10.5:
		tmp = x / -y_m
	elif x <= 4.0:
		tmp = 4.0 / y_m
	else:
		tmp = x / y_m
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= -10.5)
		tmp = Float64(x / Float64(-y_m));
	elseif (x <= 4.0)
		tmp = Float64(4.0 / y_m);
	else
		tmp = Float64(x / y_m);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= -10.5)
		tmp = x / -y_m;
	elseif (x <= 4.0)
		tmp = 4.0 / y_m;
	else
		tmp = x / y_m;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, -10.5], N[(x / (-y$95$m)), $MachinePrecision], If[LessEqual[x, 4.0], N[(4.0 / y$95$m), $MachinePrecision], N[(x / y$95$m), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -10.5:\\
\;\;\;\;\frac{x}{-y\_m}\\

\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\frac{4}{y\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{y\_m}\\


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

    1. Initial program 86.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub86.5%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified96.5%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt53.1%

        \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
      2. fabs-sqr53.1%

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
      3. add-sqr-sqrt53.6%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      4. fma-undefine46.9%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      5. associate-*r/43.8%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      6. associate-*l/45.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      7. div-inv45.2%

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

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

        \[\leadsto \frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y} \]
      10. distribute-neg-in45.2%

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

        \[\leadsto \frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y} \]
      12. cancel-sign-sub-inv45.2%

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

        \[\leadsto \frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}} \]
      14. associate-*l/43.8%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
      15. sub-div52.1%

        \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
    6. Applied egg-rr52.1%

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

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

        \[\leadsto \frac{x \cdot \color{blue}{\left(z + \left(-1\right)\right)}}{y} \]
      2. metadata-eval52.1%

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

        \[\leadsto \frac{\color{blue}{x \cdot z + x \cdot -1}}{y} \]
      4. *-commutative52.1%

        \[\leadsto \frac{x \cdot z + \color{blue}{-1 \cdot x}}{y} \]
      5. neg-mul-152.1%

        \[\leadsto \frac{x \cdot z + \color{blue}{\left(-x\right)}}{y} \]
      6. sub-neg52.1%

        \[\leadsto \frac{\color{blue}{x \cdot z - x}}{y} \]
      7. div-sub43.8%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y} - \frac{x}{y}} \]
      8. associate-*l/45.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} - \frac{x}{y} \]
      9. fmm-def45.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, z, -\frac{x}{y}\right)} \]
      10. neg-mul-145.3%

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, z, \color{blue}{-1 \cdot \frac{x}{y}}\right) \]
      11. fma-define45.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z + -1 \cdot \frac{x}{y}} \]
      12. *-commutative45.3%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\frac{x}{y} \cdot -1} \]
      13. distribute-lft-out55.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(z + -1\right)} \]
    9. Simplified55.3%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(z + -1\right)} \]
    10. Taylor expanded in z around 0 30.5%

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{y}} \]
    11. Step-by-step derivation
      1. mul-1-neg30.5%

        \[\leadsto \color{blue}{-\frac{x}{y}} \]
      2. distribute-frac-neg30.5%

        \[\leadsto \color{blue}{\frac{-x}{y}} \]
    12. Simplified30.5%

      \[\leadsto \color{blue}{\frac{-x}{y}} \]

    if -10.5 < x < 4

    1. Initial program 93.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub93.7%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac95.9%

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in95.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg95.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval95.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified95.9%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine95.9%

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv93.7%

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

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub93.7%

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt46.2%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/48.5%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div48.5%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr48.5%

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

      \[\leadsto \color{blue}{\frac{4}{y}} \]

    if 4 < x

    1. Initial program 85.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub85.9%

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

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

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def94.7%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac94.7%

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in94.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg94.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval94.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified94.7%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine89.4%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt33.2%

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

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt33.8%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. sub-neg33.8%

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

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

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

      \[\leadsto \color{blue}{\frac{x}{y}} + \frac{x}{y} \cdot \left(-z\right) \]
    8. Taylor expanded in z around 0 28.2%

      \[\leadsto \color{blue}{\frac{x}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification35.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -10.5:\\ \;\;\;\;\frac{x}{-y}\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\frac{4}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 71.8% accurate, 9.2× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -7.2 \cdot 10^{-17}:\\ \;\;\;\;x \cdot \frac{-1 + z}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x -7.2e-17) (* x (/ (+ -1.0 z) y_m)) (/ (+ x 4.0) y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -7.2e-17) {
		tmp = x * ((-1.0 + z) / y_m);
	} else {
		tmp = (x + 4.0) / y_m;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-7.2d-17)) then
        tmp = x * (((-1.0d0) + z) / y_m)
    else
        tmp = (x + 4.0d0) / y_m
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -7.2e-17) {
		tmp = x * ((-1.0 + z) / y_m);
	} else {
		tmp = (x + 4.0) / y_m;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= -7.2e-17:
		tmp = x * ((-1.0 + z) / y_m)
	else:
		tmp = (x + 4.0) / y_m
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= -7.2e-17)
		tmp = Float64(x * Float64(Float64(-1.0 + z) / y_m));
	else
		tmp = Float64(Float64(x + 4.0) / y_m);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= -7.2e-17)
		tmp = x * ((-1.0 + z) / y_m);
	else
		tmp = (x + 4.0) / y_m;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, -7.2e-17], N[(x * N[(N[(-1.0 + z), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.2 \cdot 10^{-17}:\\
\;\;\;\;x \cdot \frac{-1 + z}{y\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + 4}{y\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -7.1999999999999999e-17

    1. Initial program 86.8%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub86.8%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac96.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative96.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in96.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg96.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval96.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified96.6%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt54.5%

        \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
      2. fabs-sqr54.5%

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
      3. add-sqr-sqrt55.1%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      4. fma-undefine48.6%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      5. associate-*r/45.6%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      6. associate-*l/47.0%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      7. div-inv46.9%

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

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y} \]
      9. metadata-eval46.9%

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

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y} \]
      11. +-commutative46.9%

        \[\leadsto \frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y} \]
      12. cancel-sign-sub-inv46.9%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}} \]
      13. div-inv47.0%

        \[\leadsto \frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}} \]
      14. associate-*l/45.6%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
      15. sub-div53.6%

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(z - 1\right)}{y}} \]
    8. Step-by-step derivation
      1. sub-neg52.0%

        \[\leadsto \frac{x \cdot \color{blue}{\left(z + \left(-1\right)\right)}}{y} \]
      2. metadata-eval52.0%

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

        \[\leadsto \frac{\color{blue}{x \cdot z + x \cdot -1}}{y} \]
      4. *-commutative52.1%

        \[\leadsto \frac{x \cdot z + \color{blue}{-1 \cdot x}}{y} \]
      5. neg-mul-152.1%

        \[\leadsto \frac{x \cdot z + \color{blue}{\left(-x\right)}}{y} \]
      6. sub-neg52.1%

        \[\leadsto \frac{\color{blue}{x \cdot z - x}}{y} \]
      7. div-sub44.0%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y} - \frac{x}{y}} \]
      8. associate-*l/45.4%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} - \frac{x}{y} \]
      9. fmm-def45.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, z, -\frac{x}{y}\right)} \]
      10. neg-mul-145.4%

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, z, \color{blue}{-1 \cdot \frac{x}{y}}\right) \]
      11. fma-define45.4%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z + -1 \cdot \frac{x}{y}} \]
      12. *-commutative45.4%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\frac{x}{y} \cdot -1} \]
      13. distribute-lft-out55.1%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(z + -1\right)} \]
    9. Simplified55.1%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(z + -1\right)} \]
    10. Taylor expanded in x around 0 52.0%

      \[\leadsto \color{blue}{\frac{x \cdot \left(z - 1\right)}{y}} \]
    11. Step-by-step derivation
      1. sub-neg52.0%

        \[\leadsto \frac{x \cdot \color{blue}{\left(z + \left(-1\right)\right)}}{y} \]
      2. metadata-eval52.0%

        \[\leadsto \frac{x \cdot \left(z + \color{blue}{-1}\right)}{y} \]
      3. associate-*r/55.1%

        \[\leadsto \color{blue}{x \cdot \frac{z + -1}{y}} \]
    12. Simplified55.1%

      \[\leadsto \color{blue}{x \cdot \frac{z + -1}{y}} \]

    if -7.1999999999999999e-17 < x

    1. Initial program 91.3%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub91.3%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac95.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative95.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in95.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg95.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval95.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified95.5%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine94.0%

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv91.3%

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt43.1%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/44.1%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div45.2%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr45.2%

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

      \[\leadsto \color{blue}{\frac{4 + x}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification41.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7.2 \cdot 10^{-17}:\\ \;\;\;\;x \cdot \frac{-1 + z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 69.6% accurate, 11.1× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{-4 - x}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x -4.0) (/ (- -4.0 x) y_m) (/ (+ x 4.0) y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = (-4.0 - x) / y_m;
	} else {
		tmp = (x + 4.0) / y_m;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-4.0d0)) then
        tmp = ((-4.0d0) - x) / y_m
    else
        tmp = (x + 4.0d0) / y_m
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = (-4.0 - x) / y_m;
	} else {
		tmp = (x + 4.0) / y_m;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= -4.0:
		tmp = (-4.0 - x) / y_m
	else:
		tmp = (x + 4.0) / y_m
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= -4.0)
		tmp = Float64(Float64(-4.0 - x) / y_m);
	else
		tmp = Float64(Float64(x + 4.0) / y_m);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= -4.0)
		tmp = (-4.0 - x) / y_m;
	else
		tmp = (x + 4.0) / y_m;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, -4.0], N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;\frac{-4 - x}{y\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + 4}{y\_m}\\


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

    1. Initial program 86.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub86.5%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified96.5%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt53.1%

        \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
      2. fabs-sqr53.1%

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
      3. add-sqr-sqrt53.6%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      4. fma-undefine46.9%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      5. associate-*r/43.8%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      6. associate-*l/45.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      7. div-inv45.2%

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

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

        \[\leadsto \frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y} \]
      10. distribute-neg-in45.2%

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

        \[\leadsto \frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y} \]
      12. cancel-sign-sub-inv45.2%

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

        \[\leadsto \frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}} \]
      14. associate-*l/43.8%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
      15. sub-div52.1%

        \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
    6. Applied egg-rr52.1%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{4 + x}{y}} \]
    8. Step-by-step derivation
      1. associate-*r/30.5%

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

        \[\leadsto \frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y} \]
      3. metadata-eval30.5%

        \[\leadsto \frac{\color{blue}{-4} + -1 \cdot x}{y} \]
      4. neg-mul-130.5%

        \[\leadsto \frac{-4 + \color{blue}{\left(-x\right)}}{y} \]
      5. sub-neg30.5%

        \[\leadsto \frac{\color{blue}{-4 - x}}{y} \]
    9. Simplified30.5%

      \[\leadsto \color{blue}{\frac{-4 - x}{y}} \]

    if -4 < x

    1. Initial program 91.4%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub91.4%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac95.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative95.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in95.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg95.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval95.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified95.6%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine94.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub91.4%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt41.5%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      13. fabs-sqr41.5%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt42.6%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/43.7%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div44.7%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr44.7%

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

      \[\leadsto \color{blue}{\frac{4 + x}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification35.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{-4 - x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 69.4% accurate, 11.1× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{x}{-y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x -4.0) (/ x (- y_m)) (/ (+ x 4.0) y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = x / -y_m;
	} else {
		tmp = (x + 4.0) / y_m;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-4.0d0)) then
        tmp = x / -y_m
    else
        tmp = (x + 4.0d0) / y_m
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = x / -y_m;
	} else {
		tmp = (x + 4.0) / y_m;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= -4.0:
		tmp = x / -y_m
	else:
		tmp = (x + 4.0) / y_m
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= -4.0)
		tmp = Float64(x / Float64(-y_m));
	else
		tmp = Float64(Float64(x + 4.0) / y_m);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= -4.0)
		tmp = x / -y_m;
	else
		tmp = (x + 4.0) / y_m;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, -4.0], N[(x / (-y$95$m)), $MachinePrecision], N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;\frac{x}{-y\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + 4}{y\_m}\\


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

    1. Initial program 86.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub86.5%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval96.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified96.5%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt53.1%

        \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
      2. fabs-sqr53.1%

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
      3. add-sqr-sqrt53.6%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      4. fma-undefine46.9%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      5. associate-*r/43.8%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      6. associate-*l/45.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      7. div-inv45.2%

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

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

        \[\leadsto \frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y} \]
      10. distribute-neg-in45.2%

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

        \[\leadsto \frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y} \]
      12. cancel-sign-sub-inv45.2%

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

        \[\leadsto \frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}} \]
      14. associate-*l/43.8%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
      15. sub-div52.1%

        \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
    6. Applied egg-rr52.1%

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

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

        \[\leadsto \frac{x \cdot \color{blue}{\left(z + \left(-1\right)\right)}}{y} \]
      2. metadata-eval52.1%

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

        \[\leadsto \frac{\color{blue}{x \cdot z + x \cdot -1}}{y} \]
      4. *-commutative52.1%

        \[\leadsto \frac{x \cdot z + \color{blue}{-1 \cdot x}}{y} \]
      5. neg-mul-152.1%

        \[\leadsto \frac{x \cdot z + \color{blue}{\left(-x\right)}}{y} \]
      6. sub-neg52.1%

        \[\leadsto \frac{\color{blue}{x \cdot z - x}}{y} \]
      7. div-sub43.8%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y} - \frac{x}{y}} \]
      8. associate-*l/45.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} - \frac{x}{y} \]
      9. fmm-def45.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, z, -\frac{x}{y}\right)} \]
      10. neg-mul-145.3%

        \[\leadsto \mathsf{fma}\left(\frac{x}{y}, z, \color{blue}{-1 \cdot \frac{x}{y}}\right) \]
      11. fma-define45.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z + -1 \cdot \frac{x}{y}} \]
      12. *-commutative45.3%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\frac{x}{y} \cdot -1} \]
      13. distribute-lft-out55.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(z + -1\right)} \]
    9. Simplified55.3%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(z + -1\right)} \]
    10. Taylor expanded in z around 0 30.5%

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{y}} \]
    11. Step-by-step derivation
      1. mul-1-neg30.5%

        \[\leadsto \color{blue}{-\frac{x}{y}} \]
      2. distribute-frac-neg30.5%

        \[\leadsto \color{blue}{\frac{-x}{y}} \]
    12. Simplified30.5%

      \[\leadsto \color{blue}{\frac{-x}{y}} \]

    if -4 < x

    1. Initial program 91.4%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub91.4%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac95.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative95.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in95.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg95.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval95.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified95.6%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine94.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub91.4%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt41.5%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      13. fabs-sqr41.5%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt42.6%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/43.7%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div44.7%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr44.7%

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

      \[\leadsto \color{blue}{\frac{4 + x}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification35.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{x}{-y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 54.2% accurate, 13.8× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq 4:\\ \;\;\;\;\frac{4}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z) :precision binary64 (if (<= x 4.0) (/ 4.0 y_m) (/ x y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= 4.0) {
		tmp = 4.0 / y_m;
	} else {
		tmp = x / y_m;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 4.0d0) then
        tmp = 4.0d0 / y_m
    else
        tmp = x / y_m
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if (x <= 4.0) {
		tmp = 4.0 / y_m;
	} else {
		tmp = x / y_m;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= 4.0:
		tmp = 4.0 / y_m
	else:
		tmp = x / y_m
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= 4.0)
		tmp = Float64(4.0 / y_m);
	else
		tmp = Float64(x / y_m);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= 4.0)
		tmp = 4.0 / y_m;
	else
		tmp = x / y_m;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, 4.0], N[(4.0 / y$95$m), $MachinePrecision], N[(x / y$95$m), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq 4:\\
\;\;\;\;\frac{4}{y\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{y\_m}\\


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

    1. Initial program 91.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub91.5%

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

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

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def96.1%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac96.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative96.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in96.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg96.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval96.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified96.1%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine93.6%

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv91.5%

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt43.8%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      13. fabs-sqr43.8%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt44.9%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/45.6%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div46.6%

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

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

      \[\leadsto \color{blue}{\frac{4}{y}} \]

    if 4 < x

    1. Initial program 85.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub85.9%

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

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

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def94.7%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac94.7%

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in94.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg94.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval94.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified94.7%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine89.4%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt33.2%

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

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt33.8%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. sub-neg33.8%

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

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

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

      \[\leadsto \color{blue}{\frac{x}{y}} + \frac{x}{y} \cdot \left(-z\right) \]
    8. Taylor expanded in z around 0 28.2%

      \[\leadsto \color{blue}{\frac{x}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 14: 39.6% accurate, 37.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \frac{4}{y\_m} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z) :precision binary64 (/ 4.0 y_m))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	return 4.0 / y_m;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    code = 4.0d0 / y_m
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	return 4.0 / y_m;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	return 4.0 / y_m
y_m = abs(y)
function code(x, y_m, z)
	return Float64(4.0 / y_m)
end
y_m = abs(y);
function tmp = code(x, y_m, z)
	tmp = 4.0 / y_m;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := N[(4.0 / y$95$m), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|

\\
\frac{4}{y\_m}
\end{array}
Derivation
  1. Initial program 90.3%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Step-by-step derivation
    1. fabs-sub90.3%

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

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

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

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
    5. distribute-neg-frac95.8%

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

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
    7. distribute-neg-in95.8%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
    8. unsub-neg95.8%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
    9. metadata-eval95.8%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
  3. Simplified95.8%

    \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. fma-undefine92.7%

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

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

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

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

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

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

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

      \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
    9. cancel-sign-sub-inv90.2%

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

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

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
    12. add-sqr-sqrt41.4%

      \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
    13. fabs-sqr41.4%

      \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
    14. add-sqr-sqrt42.5%

      \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
    15. associate-*l/42.5%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
    16. sub-div44.1%

      \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
  6. Applied egg-rr44.1%

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

    \[\leadsto \color{blue}{\frac{4}{y}} \]
  8. Add Preprocessing

Alternative 15: 1.6% accurate, 37.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \frac{-4}{y\_m} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z) :precision binary64 (/ -4.0 y_m))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	return -4.0 / y_m;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    code = (-4.0d0) / y_m
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	return -4.0 / y_m;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	return -4.0 / y_m
y_m = abs(y)
function code(x, y_m, z)
	return Float64(-4.0 / y_m)
end
y_m = abs(y);
function tmp = code(x, y_m, z)
	tmp = -4.0 / y_m;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := N[(-4.0 / y$95$m), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|

\\
\frac{-4}{y\_m}
\end{array}
Derivation
  1. Initial program 90.3%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Step-by-step derivation
    1. fabs-sub90.3%

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

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

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

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
    5. distribute-neg-frac95.8%

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

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
    7. distribute-neg-in95.8%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
    8. unsub-neg95.8%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
    9. metadata-eval95.8%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
  3. Simplified95.8%

    \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. add-sqr-sqrt52.4%

      \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
    2. fabs-sqr52.4%

      \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
    3. add-sqr-sqrt53.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
    4. fma-undefine51.5%

      \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
    5. associate-*r/51.9%

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
    6. associate-*l/49.3%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
    7. div-inv49.3%

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

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

      \[\leadsto \frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y} \]
    10. distribute-neg-in49.3%

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

      \[\leadsto \frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y} \]
    12. cancel-sign-sub-inv49.3%

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

      \[\leadsto \frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}} \]
    14. associate-*l/51.9%

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
    15. sub-div55.4%

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

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

    \[\leadsto \color{blue}{\frac{-4}{y}} \]
  8. Add Preprocessing

Reproduce

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