fabs fraction 1

Percentage Accurate: 91.9% → 99.7%
Time: 10.8s
Alternatives: 15
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 15 alternatives:

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

Initial Program: 91.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 87.6%

      \[\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

    if 3.5999999999999999e-43 < y

    1. Initial program 98.6%

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

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

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

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

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

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

Alternative 2: 98.0% accurate, 0.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left|x \cdot \left(\frac{-1 + z}{y\_m} - \frac{4}{y\_m \cdot x}\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)) < 1e308

    1. Initial program 98.4%

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

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

    1. Initial program 39.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 95.0% accurate, 0.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      5. associate-*r/30.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/30.0%

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

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

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

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

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

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

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

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

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

Alternative 4: 92.6% accurate, 1.0× speedup?

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

\\
\left|\frac{x + 4}{y\_m} - \frac{x}{\frac{y\_m}{z}}\right|
\end{array}
Derivation
  1. Initial program 90.8%

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

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

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

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

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

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

Alternative 5: 79.5% accurate, 4.8× speedup?

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

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

\mathbf{elif}\;x \leq 1.75 \cdot 10^{+116}:\\
\;\;\;\;\frac{x + 4}{y\_m} + \frac{-1}{y\_m} \cdot \left(x \cdot z\right)\\

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


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

    1. Initial program 84.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.59999999999999983e-12 < x < 1.74999999999999998e116

    1. Initial program 96.8%

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

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

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

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

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

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

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

        \[\leadsto \left(x \cdot z\right) \cdot \frac{-1}{y} + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{-1}{y} \]
      9. +-commutative57.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-2neg57.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-eval57.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-inv57.8%

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

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

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

    if 1.74999999999999998e116 < x

    1. Initial program 82.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{y}} + \frac{x}{y} \cdot \left(-z\right) \]
    8. Step-by-step derivation
      1. *-un-lft-identity33.0%

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

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

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

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

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

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

        \[\leadsto \frac{x}{y} \cdot \left(1 + \color{blue}{\sqrt{z} \cdot \sqrt{z}}\right) \]
      8. add-sqr-sqrt37.0%

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

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

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

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

Alternative 6: 79.5% accurate, 5.8× speedup?

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

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

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

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


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

    1. Initial program 84.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.59999999999999983e-12 < x < 1.0500000000000001e116

    1. Initial program 96.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.0500000000000001e116 < x

    1. Initial program 82.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{y}} + \frac{x}{y} \cdot \left(-z\right) \]
    8. Step-by-step derivation
      1. *-un-lft-identity33.0%

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

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

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

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

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

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

        \[\leadsto \frac{x}{y} \cdot \left(1 + \color{blue}{\sqrt{z} \cdot \sqrt{z}}\right) \]
      8. add-sqr-sqrt37.0%

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

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

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

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

Alternative 7: 78.6% accurate, 6.5× speedup?

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

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

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

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


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

    1. Initial program 84.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.59999999999999983e-12 < x < 5.2000000000000002e-9

    1. Initial program 96.9%

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

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

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/95.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. fma-undefine95.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/96.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\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 57.1%

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

    if 5.2000000000000002e-9 < x

    1. Initial program 86.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{y}} + \frac{x}{y} \cdot \left(-z\right) \]
    8. Step-by-step derivation
      1. *-un-lft-identity37.9%

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

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

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

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

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

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

        \[\leadsto \frac{x}{y} \cdot \left(1 + \color{blue}{\sqrt{z} \cdot \sqrt{z}}\right) \]
      8. add-sqr-sqrt32.1%

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

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

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

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

Alternative 8: 72.9% accurate, 6.5× speedup?

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

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

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

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


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

    1. Initial program 84.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.32e-14 < x < 2.95e16

    1. Initial program 97.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.95e16 < x

    1. Initial program 85.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt37.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-sqr37.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-sqrt38.0%

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{y}} + \frac{x}{y} \cdot \left(-z\right) \]
    8. Step-by-step derivation
      1. *-un-lft-identity38.0%

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

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

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

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

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

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

        \[\leadsto \frac{x}{y} \cdot \left(1 + \color{blue}{\sqrt{z} \cdot \sqrt{z}}\right) \]
      8. add-sqr-sqrt32.5%

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

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

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

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

Alternative 9: 74.3% accurate, 6.5× speedup?

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

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

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

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


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

    1. Initial program 84.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.49999999999999985e-12 < x < 1.02e6

    1. Initial program 97.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.02e6 < x

    1. Initial program 85.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\color{blue}{\left(-x\right) \cdot \left(-1 \cdot z\right)} + \left(-x\right)}{y} \]
      13. *-rgt-identity40.1%

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

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

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

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

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

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

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

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

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

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

Alternative 10: 67.8% accurate, 8.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -1.52:\\ \;\;\;\;\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 -1.52) (/ 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 <= -1.52) {
		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 <= (-1.52d0)) 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 <= -1.52) {
		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 <= -1.52:
		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 <= -1.52)
		tmp = Float64(x / Float64(-y_m));
	elseif (x <= 4.0)
		tmp = Float64(4.0 / y_m);
	else
		tmp = Float64(x / y_m);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= -1.52)
		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, -1.52], 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 -1.52:\\
\;\;\;\;\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 < -1.52

    1. Initial program 84.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.52 < x < 4

    1. Initial program 97.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4 < x

    1. Initial program 86.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\color{blue}{x \cdot z + x \cdot -1}}{y} \]
      7. *-commutative39.6%

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

        \[\leadsto -\frac{x \cdot z + \color{blue}{\left(-x\right)}}{y} \]
      9. remove-double-neg39.6%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{1 - z}{y}} \]
    10. Taylor expanded in z around 0 22.8%

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

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

Alternative 11: 71.0% accurate, 9.2× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -5.2 \cdot 10^{-14}:\\ \;\;\;\;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 -5.2e-14) (* 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 <= -5.2e-14) {
		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 <= (-5.2d-14)) 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 <= -5.2e-14) {
		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 <= -5.2e-14:
		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 <= -5.2e-14)
		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 <= -5.2e-14)
		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, -5.2e-14], 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 -5.2 \cdot 10^{-14}:\\
\;\;\;\;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 < -5.19999999999999993e-14

    1. Initial program 84.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.19999999999999993e-14 < x

    1. Initial program 92.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt48.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-sqr48.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-sqrt49.1%

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

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

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

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

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

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

Alternative 12: 68.7% accurate, 11.1× speedup?

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

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

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


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

    1. Initial program 84.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4 < x

    1. Initial program 93.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 53.7% 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 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/95.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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-sqrt48.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-sqr48.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-sqrt49.0%

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

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

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

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

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

    if 4 < x

    1. Initial program 86.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\color{blue}{x \cdot z + x \cdot -1}}{y} \]
      7. *-commutative39.6%

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

        \[\leadsto -\frac{x \cdot z + \color{blue}{\left(-x\right)}}{y} \]
      9. remove-double-neg39.6%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \frac{1 - z}{y}} \]
    10. Taylor expanded in z around 0 22.8%

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

Alternative 14: 39.3% accurate, 37.0× speedup?

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

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

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

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

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

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

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

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

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
    8. unsub-neg95.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
    9. metadata-eval95.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
  3. Simplified95.3%

    \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. fma-undefine93.8%

      \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
    2. associate-*r/92.3%

      \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
    3. associate-*l/90.8%

      \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
    4. div-inv90.7%

      \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
    5. sub-neg90.7%

      \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
    6. metadata-eval90.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-in90.7%

      \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
    8. +-commutative90.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-inv90.7%

      \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
    10. div-inv90.8%

      \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
    11. fabs-sub90.8%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
    12. add-sqr-sqrt45.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-sqr45.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-sqrt46.3%

      \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
    15. associate-*l/47.1%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
    16. sub-div49.1%

      \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
  6. Applied egg-rr49.1%

    \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
  7. Taylor expanded in x around 0 20.8%

    \[\leadsto \color{blue}{\frac{4}{y}} \]
  8. Add Preprocessing

Alternative 15: 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 90.8%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Step-by-step derivation
    1. fabs-sub90.8%

      \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
    2. associate-*l/92.3%

      \[\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-neg95.3%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
    5. distribute-neg-frac95.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
    6. +-commutative95.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
    7. distribute-neg-in95.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
    8. unsub-neg95.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
    9. metadata-eval95.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
  3. Simplified95.3%

    \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. add-sqr-sqrt48.1%

      \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
    2. fabs-sqr48.1%

      \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
    3. add-sqr-sqrt49.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
    4. fma-undefine47.9%

      \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
    5. associate-*r/46.5%

      \[\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/46.5%

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
    15. sub-div48.4%

      \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
  6. Applied egg-rr48.4%

    \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
  7. Taylor expanded in x around 0 17.6%

    \[\leadsto \color{blue}{\frac{-4}{y}} \]
  8. Add Preprocessing

Reproduce

?
herbie shell --seed 2024137 
(FPCore (x y z)
  :name "fabs fraction 1"
  :precision binary64
  (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))