fabs fraction 1

Percentage Accurate: 91.3% → 99.6%
Time: 11.1s
Alternatives: 16
Speedup: 0.9×

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 16 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.3% accurate, 1.0× speedup?

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

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

Alternative 1: 99.6% accurate, 0.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;y\_m \leq 5 \cdot 10^{-56}:\\ \;\;\;\;\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 5e-56)
   (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 <= 5e-56) {
		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 <= 5e-56)
		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, 5e-56], 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 5 \cdot 10^{-56}:\\
\;\;\;\;\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 < 4.99999999999999997e-56

    1. Initial program 93.0%

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

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

    if 4.99999999999999997e-56 < y

    1. Initial program 98.8%

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

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

        \[\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. fma-neg99.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.7% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 98.6%

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

    if 9.9999999999999994e303 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))

    1. Initial program 74.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 94.5% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \frac{x + 4}{y\_m} - z \cdot \frac{x}{y\_m}\\ \mathbf{if}\;t\_0 \leq \infty:\\ \;\;\;\;\left|t\_0\right|\\ \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
 (let* ((t_0 (- (/ (+ x 4.0) y_m) (* z (/ x y_m)))))
   (if (<= t_0 INFINITY) (fabs t_0) (* x (/ (+ -1.0 z) y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = ((x + 4.0) / y_m) - (z * (x / y_m));
	double tmp;
	if (t_0 <= ((double) INFINITY)) {
		tmp = fabs(t_0);
	} else {
		tmp = x * ((-1.0 + z) / y_m);
	}
	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) - (z * (x / y_m));
	double tmp;
	if (t_0 <= Double.POSITIVE_INFINITY) {
		tmp = Math.abs(t_0);
	} else {
		tmp = x * ((-1.0 + z) / y_m);
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	t_0 = ((x + 4.0) / y_m) - (z * (x / y_m))
	tmp = 0
	if t_0 <= math.inf:
		tmp = math.fabs(t_0)
	else:
		tmp = x * ((-1.0 + z) / y_m)
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	t_0 = Float64(Float64(Float64(x + 4.0) / y_m) - Float64(z * Float64(x / y_m)))
	tmp = 0.0
	if (t_0 <= Inf)
		tmp = abs(t_0);
	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)
	t_0 = ((x + 4.0) / y_m) - (z * (x / y_m));
	tmp = 0.0;
	if (t_0 <= Inf)
		tmp = abs(t_0);
	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_] := Block[{t$95$0 = N[(N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision] - N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[Abs[t$95$0], $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}
t_0 := \frac{x + 4}{y\_m} - z \cdot \frac{x}{y\_m}\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;\left|t\_0\right|\\

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


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

    1. Initial program 98.8%

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

    if +inf.0 < (-.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. Step-by-step derivation
      1. fabs-sub0.0%

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

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

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified80.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. add-sqr-sqrt40.0%

        \[\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-sqr40.0%

        \[\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-sqrt40.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{z - 1}{y}} \]
      2. sub-neg50.0%

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

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

        \[\leadsto x \cdot \frac{\color{blue}{-1 + z}}{y} \]
    9. Simplified50.0%

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

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

Alternative 4: 85.1% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -9.2 \cdot 10^{-47} \lor \neg \left(x \leq 2.35 \cdot 10^{-36}\right):\\ \;\;\;\;\left|\frac{x}{y\_m} - \frac{z}{\frac{y\_m}{x}}\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{y\_m} \cdot \left(x \cdot z\right) + \frac{4}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (or (<= x -9.2e-47) (not (<= x 2.35e-36)))
   (fabs (- (/ x y_m) (/ z (/ y_m x))))
   (+ (* (/ -1.0 y_m) (* x z)) (/ 4.0 y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if ((x <= -9.2e-47) || !(x <= 2.35e-36)) {
		tmp = fabs(((x / y_m) - (z / (y_m / x))));
	} else {
		tmp = ((-1.0 / y_m) * (x * z)) + (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 <= (-9.2d-47)) .or. (.not. (x <= 2.35d-36))) then
        tmp = abs(((x / y_m) - (z / (y_m / x))))
    else
        tmp = (((-1.0d0) / y_m) * (x * z)) + (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 <= -9.2e-47) || !(x <= 2.35e-36)) {
		tmp = Math.abs(((x / y_m) - (z / (y_m / x))));
	} else {
		tmp = ((-1.0 / y_m) * (x * z)) + (4.0 / y_m);
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if (x <= -9.2e-47) or not (x <= 2.35e-36):
		tmp = math.fabs(((x / y_m) - (z / (y_m / x))))
	else:
		tmp = ((-1.0 / y_m) * (x * z)) + (4.0 / y_m)
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if ((x <= -9.2e-47) || !(x <= 2.35e-36))
		tmp = abs(Float64(Float64(x / y_m) - Float64(z / Float64(y_m / x))));
	else
		tmp = Float64(Float64(Float64(-1.0 / y_m) * Float64(x * z)) + Float64(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 <= -9.2e-47) || ~((x <= 2.35e-36)))
		tmp = abs(((x / y_m) - (z / (y_m / x))));
	else
		tmp = ((-1.0 / y_m) * (x * z)) + (4.0 / y_m);
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[Or[LessEqual[x, -9.2e-47], N[Not[LessEqual[x, 2.35e-36]], $MachinePrecision]], N[Abs[N[(N[(x / y$95$m), $MachinePrecision] - N[(z / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(N[(-1.0 / y$95$m), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(4.0 / y$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.2 \cdot 10^{-47} \lor \neg \left(x \leq 2.35 \cdot 10^{-36}\right):\\
\;\;\;\;\left|\frac{x}{y\_m} - \frac{z}{\frac{y\_m}{x}}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9.19999999999999928e-47 or 2.3500000000000001e-36 < x

    1. Initial program 92.8%

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

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

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

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

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

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

    if -9.19999999999999928e-47 < x < 2.3500000000000001e-36

    1. Initial program 97.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 78.5% accurate, 5.8× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -2.55 \cdot 10^{-45}:\\ \;\;\;\;x \cdot \frac{-1 + z}{y\_m}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-5}:\\ \;\;\;\;\frac{4 - x \cdot z}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\frac{1}{y\_m} - \frac{z}{y\_m}\right)\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x -2.55e-45)
   (* x (/ (+ -1.0 z) y_m))
   (if (<= x 1.4e-5) (/ (- 4.0 (* x z)) y_m) (* x (- (/ 1.0 y_m) (/ z y_m))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -2.55e-45) {
		tmp = x * ((-1.0 + z) / y_m);
	} else if (x <= 1.4e-5) {
		tmp = (4.0 - (x * z)) / y_m;
	} else {
		tmp = x * ((1.0 / y_m) - (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 <= (-2.55d-45)) then
        tmp = x * (((-1.0d0) + z) / y_m)
    else if (x <= 1.4d-5) then
        tmp = (4.0d0 - (x * z)) / y_m
    else
        tmp = x * ((1.0d0 / y_m) - (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 <= -2.55e-45) {
		tmp = x * ((-1.0 + z) / y_m);
	} else if (x <= 1.4e-5) {
		tmp = (4.0 - (x * z)) / y_m;
	} else {
		tmp = x * ((1.0 / y_m) - (z / y_m));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= -2.55e-45:
		tmp = x * ((-1.0 + z) / y_m)
	elif x <= 1.4e-5:
		tmp = (4.0 - (x * z)) / y_m
	else:
		tmp = x * ((1.0 / y_m) - (z / y_m))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= -2.55e-45)
		tmp = Float64(x * Float64(Float64(-1.0 + z) / y_m));
	elseif (x <= 1.4e-5)
		tmp = Float64(Float64(4.0 - Float64(x * z)) / y_m);
	else
		tmp = Float64(x * Float64(Float64(1.0 / y_m) - Float64(z / y_m)));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= -2.55e-45)
		tmp = x * ((-1.0 + z) / y_m);
	elseif (x <= 1.4e-5)
		tmp = (4.0 - (x * z)) / y_m;
	else
		tmp = x * ((1.0 / y_m) - (z / y_m));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, -2.55e-45], N[(x * N[(N[(-1.0 + z), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4e-5], N[(N[(4.0 - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision], N[(x * N[(N[(1.0 / y$95$m), $MachinePrecision] - N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|

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

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

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


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

    1. Initial program 92.6%

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

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

        \[\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. fma-neg97.1%

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified97.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. add-sqr-sqrt48.2%

        \[\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-sqr48.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{z - 1}{y}} \]
      2. sub-neg47.3%

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

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

        \[\leadsto x \cdot \frac{\color{blue}{-1 + z}}{y} \]
    9. Simplified47.3%

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

    if -2.5499999999999999e-45 < x < 1.39999999999999998e-5

    1. Initial program 97.6%

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

        \[\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/92.2%

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified92.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-undefine92.2%

        \[\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/97.6%

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

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

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

        \[\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-in97.6%

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

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

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

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

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

        \[\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-sqr53.0%

        \[\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-sqrt54.1%

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

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

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

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

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

    if 1.39999999999999998e-5 < x

    1. Initial program 92.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(-1 \cdot \frac{z}{y} + \frac{1}{y}\right)} \]
    7. Step-by-step derivation
      1. neg-mul-159.6%

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

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

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

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

Alternative 6: 66.2% accurate, 6.2× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -2.2 \cdot 10^{+68}:\\ \;\;\;\;\frac{-x}{y\_m}\\ \mathbf{elif}\;x \leq -2.55 \cdot 10^{-45}:\\ \;\;\;\;z \cdot \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 -2.2e+68)
   (/ (- x) y_m)
   (if (<= x -2.55e-45)
     (* z (/ 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 <= -2.2e+68) {
		tmp = -x / y_m;
	} else if (x <= -2.55e-45) {
		tmp = z * (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 <= (-2.2d+68)) then
        tmp = -x / y_m
    else if (x <= (-2.55d-45)) then
        tmp = z * (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 <= -2.2e+68) {
		tmp = -x / y_m;
	} else if (x <= -2.55e-45) {
		tmp = z * (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 <= -2.2e+68:
		tmp = -x / y_m
	elif x <= -2.55e-45:
		tmp = z * (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 <= -2.2e+68)
		tmp = Float64(Float64(-x) / y_m);
	elseif (x <= -2.55e-45)
		tmp = Float64(z * Float64(x / 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 <= -2.2e+68)
		tmp = -x / y_m;
	elseif (x <= -2.55e-45)
		tmp = z * (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, -2.2e+68], N[((-x) / y$95$m), $MachinePrecision], If[LessEqual[x, -2.55e-45], N[(z * N[(x / y$95$m), $MachinePrecision]), $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 -2.2 \cdot 10^{+68}:\\
\;\;\;\;\frac{-x}{y\_m}\\

\mathbf{elif}\;x \leq -2.55 \cdot 10^{-45}:\\
\;\;\;\;z \cdot \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 4 regimes
  2. if x < -2.19999999999999987e68

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified97.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. add-sqr-sqrt50.8%

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

        \[\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-sqrt51.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-\left(4 + x\right)}}{y} \]
      3. distribute-neg-in32.5%

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

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

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

      \[\leadsto \color{blue}{\frac{-4 - x}{y}} \]
    10. Taylor expanded in x around inf 32.5%

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

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

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

    if -2.19999999999999987e68 < x < -2.5499999999999999e-45

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified95.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. add-sqr-sqrt41.6%

        \[\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-sqr41.6%

        \[\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-sqrt42.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} \]
    9. Step-by-step derivation
      1. associate-*l/33.2%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} \]
      2. *-commutative33.2%

        \[\leadsto \color{blue}{z \cdot \frac{x}{y}} \]
    10. Simplified33.2%

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

    if -2.5499999999999999e-45 < x < 4

    1. Initial program 97.6%

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

        \[\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/92.3%

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified92.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-undefine92.3%

        \[\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/97.6%

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

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

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

        \[\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-in97.6%

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt53.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-sqr53.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-sqrt54.5%

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

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

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

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

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

    if 4 < x

    1. Initial program 92.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}} \]
    7. Step-by-step derivation
      1. *-lft-identity30.4%

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

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

        \[\leadsto \color{blue}{4 \cdot \frac{1}{y} - -1 \cdot \frac{x}{y}} \]
      4. associate-*r/30.4%

        \[\leadsto 4 \cdot \frac{1}{y} - \color{blue}{\frac{-1 \cdot x}{y}} \]
      5. associate-*l/30.3%

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

        \[\leadsto 4 \cdot \frac{1}{y} - \frac{\color{blue}{-1}}{y} \cdot x \]
      7. distribute-neg-frac30.3%

        \[\leadsto 4 \cdot \frac{1}{y} - \color{blue}{\left(-\frac{1}{y}\right)} \cdot x \]
      8. cancel-sign-sub30.3%

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

        \[\leadsto \color{blue}{\frac{1}{y} \cdot 4} + \frac{1}{y} \cdot x \]
      10. distribute-lft-in30.3%

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

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

        \[\leadsto \frac{\color{blue}{4 + x}}{y} \]
    8. Simplified30.4%

      \[\leadsto \color{blue}{\frac{4 + x}{y}} \]
    9. Taylor expanded in x around inf 29.6%

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

Alternative 7: 66.2% accurate, 6.2× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -3 \cdot 10^{+68}:\\ \;\;\;\;\frac{-x}{y\_m}\\ \mathbf{elif}\;x \leq -2.55 \cdot 10^{-45}:\\ \;\;\;\;x \cdot \frac{z}{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 -3e+68)
   (/ (- x) y_m)
   (if (<= x -2.55e-45)
     (* x (/ z 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 <= -3e+68) {
		tmp = -x / y_m;
	} else if (x <= -2.55e-45) {
		tmp = x * (z / 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 <= (-3d+68)) then
        tmp = -x / y_m
    else if (x <= (-2.55d-45)) then
        tmp = x * (z / 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 <= -3e+68) {
		tmp = -x / y_m;
	} else if (x <= -2.55e-45) {
		tmp = x * (z / 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 <= -3e+68:
		tmp = -x / y_m
	elif x <= -2.55e-45:
		tmp = x * (z / 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 <= -3e+68)
		tmp = Float64(Float64(-x) / y_m);
	elseif (x <= -2.55e-45)
		tmp = Float64(x * Float64(z / 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 <= -3e+68)
		tmp = -x / y_m;
	elseif (x <= -2.55e-45)
		tmp = x * (z / 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, -3e+68], N[((-x) / y$95$m), $MachinePrecision], If[LessEqual[x, -2.55e-45], N[(x * N[(z / y$95$m), $MachinePrecision]), $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 -3 \cdot 10^{+68}:\\
\;\;\;\;\frac{-x}{y\_m}\\

\mathbf{elif}\;x \leq -2.55 \cdot 10^{-45}:\\
\;\;\;\;x \cdot \frac{z}{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 4 regimes
  2. if x < -3.0000000000000002e68

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified97.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. add-sqr-sqrt50.8%

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

        \[\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-sqrt51.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-\left(4 + x\right)}}{y} \]
      3. distribute-neg-in32.5%

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

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

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

      \[\leadsto \color{blue}{\frac{-4 - x}{y}} \]
    10. Taylor expanded in x around inf 32.5%

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

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

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

    if -3.0000000000000002e68 < x < -2.5499999999999999e-45

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified95.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. add-sqr-sqrt41.6%

        \[\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-sqr41.6%

        \[\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-sqrt42.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{z}{y}} \]
    9. Simplified33.2%

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

    if -2.5499999999999999e-45 < x < 4

    1. Initial program 97.6%

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

        \[\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/92.3%

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified92.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-undefine92.3%

        \[\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/97.6%

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

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

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

        \[\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-in97.6%

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt53.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-sqr53.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-sqrt54.5%

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

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

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

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

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

    if 4 < x

    1. Initial program 92.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}} \]
    7. Step-by-step derivation
      1. *-lft-identity30.4%

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

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

        \[\leadsto \color{blue}{4 \cdot \frac{1}{y} - -1 \cdot \frac{x}{y}} \]
      4. associate-*r/30.4%

        \[\leadsto 4 \cdot \frac{1}{y} - \color{blue}{\frac{-1 \cdot x}{y}} \]
      5. associate-*l/30.3%

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

        \[\leadsto 4 \cdot \frac{1}{y} - \frac{\color{blue}{-1}}{y} \cdot x \]
      7. distribute-neg-frac30.3%

        \[\leadsto 4 \cdot \frac{1}{y} - \color{blue}{\left(-\frac{1}{y}\right)} \cdot x \]
      8. cancel-sign-sub30.3%

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

        \[\leadsto \color{blue}{\frac{1}{y} \cdot 4} + \frac{1}{y} \cdot x \]
      10. distribute-lft-in30.3%

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

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

        \[\leadsto \frac{\color{blue}{4 + x}}{y} \]
    8. Simplified30.4%

      \[\leadsto \color{blue}{\frac{4 + x}{y}} \]
    9. Taylor expanded in x around inf 29.6%

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

Alternative 8: 77.4% accurate, 6.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -2.55 \cdot 10^{-45}:\\ \;\;\;\;x \cdot \frac{-1 + z}{y\_m}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-5}:\\ \;\;\;\;\frac{4 - x \cdot z}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - x \cdot z}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x -2.55e-45)
   (* x (/ (+ -1.0 z) y_m))
   (if (<= x 1.4e-5) (/ (- 4.0 (* x z)) y_m) (/ (- x (* x z)) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -2.55e-45) {
		tmp = x * ((-1.0 + z) / y_m);
	} else if (x <= 1.4e-5) {
		tmp = (4.0 - (x * z)) / y_m;
	} else {
		tmp = (x - (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 <= (-2.55d-45)) then
        tmp = x * (((-1.0d0) + z) / y_m)
    else if (x <= 1.4d-5) then
        tmp = (4.0d0 - (x * z)) / y_m
    else
        tmp = (x - (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 <= -2.55e-45) {
		tmp = x * ((-1.0 + z) / y_m);
	} else if (x <= 1.4e-5) {
		tmp = (4.0 - (x * z)) / y_m;
	} else {
		tmp = (x - (x * z)) / y_m;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= -2.55e-45:
		tmp = x * ((-1.0 + z) / y_m)
	elif x <= 1.4e-5:
		tmp = (4.0 - (x * z)) / y_m
	else:
		tmp = (x - (x * z)) / y_m
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= -2.55e-45)
		tmp = Float64(x * Float64(Float64(-1.0 + z) / y_m));
	elseif (x <= 1.4e-5)
		tmp = Float64(Float64(4.0 - Float64(x * z)) / y_m);
	else
		tmp = Float64(Float64(x - 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 <= -2.55e-45)
		tmp = x * ((-1.0 + z) / y_m);
	elseif (x <= 1.4e-5)
		tmp = (4.0 - (x * z)) / y_m;
	else
		tmp = (x - (x * z)) / y_m;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, -2.55e-45], N[(x * N[(N[(-1.0 + z), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4e-5], N[(N[(4.0 - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|

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

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

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


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

    1. Initial program 92.6%

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

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

        \[\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. fma-neg97.1%

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified97.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. add-sqr-sqrt48.2%

        \[\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-sqr48.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{z - 1}{y}} \]
      2. sub-neg47.3%

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

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

        \[\leadsto x \cdot \frac{\color{blue}{-1 + z}}{y} \]
    9. Simplified47.3%

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

    if -2.5499999999999999e-45 < x < 1.39999999999999998e-5

    1. Initial program 97.6%

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

        \[\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/92.2%

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified92.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-undefine92.2%

        \[\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/97.6%

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

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

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

        \[\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-in97.6%

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

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

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

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

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

        \[\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-sqr53.0%

        \[\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-sqrt54.1%

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

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

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

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

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

    if 1.39999999999999998e-5 < x

    1. Initial program 92.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified98.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-undefine95.5%

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

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

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval92.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-in92.3%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative92.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-inv92.3%

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

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

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

        \[\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-sqr55.6%

        \[\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-sqrt56.0%

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

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

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

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

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

Alternative 9: 73.0% accurate, 6.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -2.55 \cdot 10^{-45}:\\ \;\;\;\;x \cdot \frac{-1 + z}{y\_m}\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{+117}:\\ \;\;\;\;\frac{4 - x \cdot 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 -2.55e-45)
   (* x (/ (+ -1.0 z) y_m))
   (if (<= x 1.35e+117) (/ (- 4.0 (* x 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 <= -2.55e-45) {
		tmp = x * ((-1.0 + z) / y_m);
	} else if (x <= 1.35e+117) {
		tmp = (4.0 - (x * 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 <= (-2.55d-45)) then
        tmp = x * (((-1.0d0) + z) / y_m)
    else if (x <= 1.35d+117) then
        tmp = (4.0d0 - (x * 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 <= -2.55e-45) {
		tmp = x * ((-1.0 + z) / y_m);
	} else if (x <= 1.35e+117) {
		tmp = (4.0 - (x * 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 <= -2.55e-45:
		tmp = x * ((-1.0 + z) / y_m)
	elif x <= 1.35e+117:
		tmp = (4.0 - (x * 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 <= -2.55e-45)
		tmp = Float64(x * Float64(Float64(-1.0 + z) / y_m));
	elseif (x <= 1.35e+117)
		tmp = Float64(Float64(4.0 - Float64(x * 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 <= -2.55e-45)
		tmp = x * ((-1.0 + z) / y_m);
	elseif (x <= 1.35e+117)
		tmp = (4.0 - (x * 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, -2.55e-45], N[(x * N[(N[(-1.0 + z), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.35e+117], N[(N[(4.0 - N[(x * z), $MachinePrecision]), $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 -2.55 \cdot 10^{-45}:\\
\;\;\;\;x \cdot \frac{-1 + z}{y\_m}\\

\mathbf{elif}\;x \leq 1.35 \cdot 10^{+117}:\\
\;\;\;\;\frac{4 - x \cdot z}{y\_m}\\

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


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

    1. Initial program 92.6%

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

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

        \[\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. fma-neg97.1%

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified97.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. add-sqr-sqrt48.2%

        \[\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-sqr48.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{z - 1}{y}} \]
      2. sub-neg47.3%

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

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

        \[\leadsto x \cdot \frac{\color{blue}{-1 + z}}{y} \]
    9. Simplified47.3%

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

    if -2.5499999999999999e-45 < x < 1.3500000000000001e117

    1. Initial program 97.3%

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

        \[\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/93.1%

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified93.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.1%

        \[\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/97.3%

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval97.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-in97.3%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative97.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-inv97.3%

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

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

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

        \[\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-sqr55.0%

        \[\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-sqrt56.0%

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

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

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

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

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

    if 1.3500000000000001e117 < x

    1. Initial program 89.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}} \]
    7. Step-by-step derivation
      1. *-lft-identity33.4%

        \[\leadsto 4 \cdot \frac{1}{y} + \color{blue}{1 \cdot \frac{x}{y}} \]
      2. metadata-eval33.4%

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

        \[\leadsto \color{blue}{4 \cdot \frac{1}{y} - -1 \cdot \frac{x}{y}} \]
      4. associate-*r/33.4%

        \[\leadsto 4 \cdot \frac{1}{y} - \color{blue}{\frac{-1 \cdot x}{y}} \]
      5. associate-*l/33.3%

        \[\leadsto 4 \cdot \frac{1}{y} - \color{blue}{\frac{-1}{y} \cdot x} \]
      6. metadata-eval33.3%

        \[\leadsto 4 \cdot \frac{1}{y} - \frac{\color{blue}{-1}}{y} \cdot x \]
      7. distribute-neg-frac33.3%

        \[\leadsto 4 \cdot \frac{1}{y} - \color{blue}{\left(-\frac{1}{y}\right)} \cdot x \]
      8. cancel-sign-sub33.3%

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

        \[\leadsto \color{blue}{\frac{1}{y} \cdot 4} + \frac{1}{y} \cdot x \]
      10. distribute-lft-in33.3%

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

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

        \[\leadsto \frac{\color{blue}{4 + x}}{y} \]
    8. Simplified33.4%

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

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

Alternative 10: 66.8% accurate, 7.4× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -2.4 \cdot 10^{+68}:\\ \;\;\;\;\frac{-x}{y\_m}\\ \mathbf{elif}\;x \leq -4.5 \cdot 10^{-46}:\\ \;\;\;\;z \cdot \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 -2.4e+68)
   (/ (- x) y_m)
   (if (<= x -4.5e-46) (* z (/ 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 <= -2.4e+68) {
		tmp = -x / y_m;
	} else if (x <= -4.5e-46) {
		tmp = z * (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 <= (-2.4d+68)) then
        tmp = -x / y_m
    else if (x <= (-4.5d-46)) then
        tmp = z * (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 <= -2.4e+68) {
		tmp = -x / y_m;
	} else if (x <= -4.5e-46) {
		tmp = z * (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 <= -2.4e+68:
		tmp = -x / y_m
	elif x <= -4.5e-46:
		tmp = z * (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 <= -2.4e+68)
		tmp = Float64(Float64(-x) / y_m);
	elseif (x <= -4.5e-46)
		tmp = Float64(z * Float64(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 <= -2.4e+68)
		tmp = -x / y_m;
	elseif (x <= -4.5e-46)
		tmp = z * (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, -2.4e+68], N[((-x) / y$95$m), $MachinePrecision], If[LessEqual[x, -4.5e-46], N[(z * N[(x / 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 -2.4 \cdot 10^{+68}:\\
\;\;\;\;\frac{-x}{y\_m}\\

\mathbf{elif}\;x \leq -4.5 \cdot 10^{-46}:\\
\;\;\;\;z \cdot \frac{x}{y\_m}\\

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


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

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified97.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. add-sqr-sqrt50.8%

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

        \[\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-sqrt51.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-\left(4 + x\right)}}{y} \]
      3. distribute-neg-in32.5%

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

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

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

      \[\leadsto \color{blue}{\frac{-4 - x}{y}} \]
    10. Taylor expanded in x around inf 32.5%

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

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

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

    if -2.40000000000000008e68 < x < -4.50000000000000001e-46

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified95.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. add-sqr-sqrt41.6%

        \[\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-sqr41.6%

        \[\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-sqrt42.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} \]
    9. Step-by-step derivation
      1. associate-*l/33.2%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} \]
      2. *-commutative33.2%

        \[\leadsto \color{blue}{z \cdot \frac{x}{y}} \]
    10. Simplified33.2%

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

    if -4.50000000000000001e-46 < x

    1. Initial program 95.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}} \]
    7. Step-by-step derivation
      1. *-lft-identity38.4%

        \[\leadsto 4 \cdot \frac{1}{y} + \color{blue}{1 \cdot \frac{x}{y}} \]
      2. metadata-eval38.4%

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

        \[\leadsto \color{blue}{4 \cdot \frac{1}{y} - -1 \cdot \frac{x}{y}} \]
      4. associate-*r/38.4%

        \[\leadsto 4 \cdot \frac{1}{y} - \color{blue}{\frac{-1 \cdot x}{y}} \]
      5. associate-*l/38.4%

        \[\leadsto 4 \cdot \frac{1}{y} - \color{blue}{\frac{-1}{y} \cdot x} \]
      6. metadata-eval38.4%

        \[\leadsto 4 \cdot \frac{1}{y} - \frac{\color{blue}{-1}}{y} \cdot x \]
      7. distribute-neg-frac38.4%

        \[\leadsto 4 \cdot \frac{1}{y} - \color{blue}{\left(-\frac{1}{y}\right)} \cdot x \]
      8. cancel-sign-sub38.4%

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

        \[\leadsto \color{blue}{\frac{1}{y} \cdot 4} + \frac{1}{y} \cdot x \]
      10. distribute-lft-in38.3%

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

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

        \[\leadsto \frac{\color{blue}{4 + x}}{y} \]
    8. Simplified38.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.4 \cdot 10^{+68}:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{elif}\;x \leq -4.5 \cdot 10^{-46}:\\ \;\;\;\;z \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 77.9% accurate, 7.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -2.55 \cdot 10^{-45}:\\ \;\;\;\;x \cdot \frac{-1 + z}{y\_m}\\ \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 -2.55e-45) (* x (/ (+ -1.0 z) y_m)) (/ (- (+ x 4.0) (* x z)) y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -2.55e-45) {
		tmp = x * ((-1.0 + z) / y_m);
	} 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 <= (-2.55d-45)) then
        tmp = x * (((-1.0d0) + z) / y_m)
    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 <= -2.55e-45) {
		tmp = x * ((-1.0 + z) / y_m);
	} 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 <= -2.55e-45:
		tmp = x * ((-1.0 + z) / y_m)
	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 <= -2.55e-45)
		tmp = Float64(x * Float64(Float64(-1.0 + z) / y_m));
	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 <= -2.55e-45)
		tmp = x * ((-1.0 + z) / y_m);
	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, -2.55e-45], N[(x * N[(N[(-1.0 + z), $MachinePrecision] / y$95$m), $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 -2.55 \cdot 10^{-45}:\\
\;\;\;\;x \cdot \frac{-1 + z}{y\_m}\\

\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 < -2.5499999999999999e-45

    1. Initial program 92.6%

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

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

        \[\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. fma-neg97.1%

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified97.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. add-sqr-sqrt48.2%

        \[\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-sqr48.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{z - 1}{y}} \]
      2. sub-neg47.3%

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

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

        \[\leadsto x \cdot \frac{\color{blue}{-1 + z}}{y} \]
    9. Simplified47.3%

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

    if -2.5499999999999999e-45 < x

    1. Initial program 95.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval95.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-in95.7%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative95.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-inv95.7%

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

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

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

        \[\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-sqr54.0%

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

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

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

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

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

Alternative 12: 68.3% 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(Float64(-x) / 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 91.8%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified98.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. add-sqr-sqrt45.7%

        \[\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-sqr45.7%

        \[\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-sqrt46.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-\left(4 + x\right)}}{y} \]
      3. distribute-neg-in26.6%

        \[\leadsto \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y} \]
      4. metadata-eval26.6%

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

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

      \[\leadsto \color{blue}{\frac{-4 - x}{y}} \]
    10. Taylor expanded in x around inf 26.6%

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

        \[\leadsto \frac{\color{blue}{-x}}{y} \]
    12. Simplified26.6%

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

    if -10.5 < x < 4

    1. Initial program 97.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub97.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/92.0%

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified92.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-undefine92.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/97.7%

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval97.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-in97.7%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative97.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-inv97.7%

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

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

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

        \[\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-sqr52.1%

        \[\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-sqrt53.1%

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

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

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

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

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

    if 4 < x

    1. Initial program 92.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}} \]
    7. Step-by-step derivation
      1. *-lft-identity30.4%

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

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

        \[\leadsto \color{blue}{4 \cdot \frac{1}{y} - -1 \cdot \frac{x}{y}} \]
      4. associate-*r/30.4%

        \[\leadsto 4 \cdot \frac{1}{y} - \color{blue}{\frac{-1 \cdot x}{y}} \]
      5. associate-*l/30.3%

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

        \[\leadsto 4 \cdot \frac{1}{y} - \frac{\color{blue}{-1}}{y} \cdot x \]
      7. distribute-neg-frac30.3%

        \[\leadsto 4 \cdot \frac{1}{y} - \color{blue}{\left(-\frac{1}{y}\right)} \cdot x \]
      8. cancel-sign-sub30.3%

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

        \[\leadsto \color{blue}{\frac{1}{y} \cdot 4} + \frac{1}{y} \cdot x \]
      10. distribute-lft-in30.3%

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

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

        \[\leadsto \frac{\color{blue}{4 + x}}{y} \]
    8. Simplified30.4%

      \[\leadsto \color{blue}{\frac{4 + x}{y}} \]
    9. Taylor expanded in x around inf 29.6%

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

Alternative 13: 70.9% accurate, 9.2× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -2.55 \cdot 10^{-45}:\\ \;\;\;\;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 -2.55e-45) (* 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 <= -2.55e-45) {
		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 <= (-2.55d-45)) 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 <= -2.55e-45) {
		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 <= -2.55e-45:
		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 <= -2.55e-45)
		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 <= -2.55e-45)
		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, -2.55e-45], 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 -2.55 \cdot 10^{-45}:\\
\;\;\;\;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 < -2.5499999999999999e-45

    1. Initial program 92.6%

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

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

        \[\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. fma-neg97.1%

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified97.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. add-sqr-sqrt48.2%

        \[\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-sqr48.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{z - 1}{y}} \]
      2. sub-neg47.3%

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

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

        \[\leadsto x \cdot \frac{\color{blue}{-1 + z}}{y} \]
    9. Simplified47.3%

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

    if -2.5499999999999999e-45 < x

    1. Initial program 95.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}} \]
    7. Step-by-step derivation
      1. *-lft-identity38.4%

        \[\leadsto 4 \cdot \frac{1}{y} + \color{blue}{1 \cdot \frac{x}{y}} \]
      2. metadata-eval38.4%

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

        \[\leadsto \color{blue}{4 \cdot \frac{1}{y} - -1 \cdot \frac{x}{y}} \]
      4. associate-*r/38.4%

        \[\leadsto 4 \cdot \frac{1}{y} - \color{blue}{\frac{-1 \cdot x}{y}} \]
      5. associate-*l/38.4%

        \[\leadsto 4 \cdot \frac{1}{y} - \color{blue}{\frac{-1}{y} \cdot x} \]
      6. metadata-eval38.4%

        \[\leadsto 4 \cdot \frac{1}{y} - \frac{\color{blue}{-1}}{y} \cdot x \]
      7. distribute-neg-frac38.4%

        \[\leadsto 4 \cdot \frac{1}{y} - \color{blue}{\left(-\frac{1}{y}\right)} \cdot x \]
      8. cancel-sign-sub38.4%

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

        \[\leadsto \color{blue}{\frac{1}{y} \cdot 4} + \frac{1}{y} \cdot x \]
      10. distribute-lft-in38.3%

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

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

        \[\leadsto \frac{\color{blue}{4 + x}}{y} \]
    8. Simplified38.4%

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

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

Alternative 14: 54.4% 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 95.8%

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

        \[\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/92.9%

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified94.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-undefine92.9%

        \[\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/95.8%

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval95.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-in95.7%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative95.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-inv95.7%

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

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

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

        \[\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-sqr51.0%

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

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

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

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

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

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

    if 4 < x

    1. Initial program 92.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}} \]
    7. Step-by-step derivation
      1. *-lft-identity30.4%

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

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

        \[\leadsto \color{blue}{4 \cdot \frac{1}{y} - -1 \cdot \frac{x}{y}} \]
      4. associate-*r/30.4%

        \[\leadsto 4 \cdot \frac{1}{y} - \color{blue}{\frac{-1 \cdot x}{y}} \]
      5. associate-*l/30.3%

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

        \[\leadsto 4 \cdot \frac{1}{y} - \frac{\color{blue}{-1}}{y} \cdot x \]
      7. distribute-neg-frac30.3%

        \[\leadsto 4 \cdot \frac{1}{y} - \color{blue}{\left(-\frac{1}{y}\right)} \cdot x \]
      8. cancel-sign-sub30.3%

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

        \[\leadsto \color{blue}{\frac{1}{y} \cdot 4} + \frac{1}{y} \cdot x \]
      10. distribute-lft-in30.3%

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

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

        \[\leadsto \frac{\color{blue}{4 + x}}{y} \]
    8. Simplified30.4%

      \[\leadsto \color{blue}{\frac{4 + x}{y}} \]
    9. Taylor expanded in x around inf 29.6%

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

Alternative 15: 39.7% 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 94.9%

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

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

      \[\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. fma-neg95.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-undefine93.6%

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

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

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

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

      \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
    6. metadata-eval94.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-in94.8%

      \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
    8. +-commutative94.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-inv94.8%

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

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

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

      \[\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-sqr52.1%

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{4}{y}} \]
  8. Add Preprocessing

Alternative 16: 1.7% 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 94.9%

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

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

      \[\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. fma-neg95.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. add-sqr-sqrt42.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-sqr42.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-sqrt43.4%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y} \]
    12. cancel-sign-sub-inv43.2%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}} \]
    13. div-inv43.2%

      \[\leadsto \frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}} \]
    14. associate-*l/42.9%

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
    15. sub-div44.1%

      \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
  6. Applied egg-rr44.1%

    \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
  7. Taylor expanded in x around 0 19.3%

    \[\leadsto \color{blue}{\frac{-4}{y}} \]
  8. Add Preprocessing

Reproduce

?
herbie shell --seed 2024133 
(FPCore (x y z)
  :name "fabs fraction 1"
  :precision binary64
  (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))