fabs fraction 1

Percentage Accurate: 91.4% → 98.1%
Time: 12.1s
Alternatives: 16
Speedup: 0.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 16 alternatives:

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

Initial Program: 91.4% 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: 98.1% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 92.3%

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

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

    if 8.20000000000000036e-167 < y

    1. Initial program 95.2%

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.7% accurate, 0.5× speedup?

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

    1. Initial program 92.7%

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

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

    if 9.7999999999999997e-50 < y

    1. Initial program 95.1%

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

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

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

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

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

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

Alternative 3: 98.0% accurate, 0.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left|\frac{-4 - x}{y\_m}\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)) < +inf.0

    1. Initial program 98.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{\color{blue}{-4 - x}}{y}\right| \]
    7. Simplified100.0%

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

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

Alternative 4: 83.9% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;z \leq 2.7 \cdot 10^{-7}:\\
\;\;\;\;\left|\frac{-4 - x}{y\_m}\right|\\

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.7499999999999999e66 or 1.66e263 < z

    1. Initial program 95.3%

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

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

      \[\leadsto \left|\color{blue}{-1 \cdot \frac{x \cdot z}{y}}\right| \]
    5. Step-by-step derivation
      1. mul-1-neg72.9%

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

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

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

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

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

    if -1.7499999999999999e66 < z < 2.70000000000000009e-7

    1. Initial program 93.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{\color{blue}{-4 - x}}{y}\right| \]
    7. Simplified96.4%

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

    if 2.70000000000000009e-7 < z < 1.66e263

    1. Initial program 90.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt47.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| \]
      2. fabs-sqr47.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}} \]
      3. add-sqr-sqrt48.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine41.7%

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

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

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

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

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

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

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

Alternative 5: 97.1% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -80000000 \lor \neg \left(z \leq 5.2 \cdot 10^{-5}\right):\\
\;\;\;\;\left|\frac{4}{y\_m} - z \cdot \frac{x}{y\_m}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8e7 or 5.19999999999999968e-5 < z

    1. Initial program 94.2%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 96.0%

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

    if -8e7 < z < 5.19999999999999968e-5

    1. Initial program 92.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y}\right| \]
      3. metadata-eval99.7%

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

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

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

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

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

Alternative 6: 92.3% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.8 \cdot 10^{-46} \lor \neg \left(x \leq 660000000\right):\\
\;\;\;\;\left|\frac{x}{y\_m} \cdot \left(1 - z\right)\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.80000000000000009e-46 or 6.6e8 < x

    1. Initial program 90.2%

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

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

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

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

        \[\leadsto \left|-\color{blue}{x \cdot \frac{z - 1}{y}}\right| \]
      3. distribute-rgt-neg-in96.3%

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

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

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

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

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

        \[\leadsto \left|x \cdot \frac{\color{blue}{-1 \cdot z + -1 \cdot -1}}{y}\right| \]
      9. neg-mul-196.3%

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

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

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

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

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

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

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

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

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

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

    if -5.80000000000000009e-46 < x < 6.6e8

    1. Initial program 97.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt47.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| \]
      2. fabs-sqr47.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}} \]
      3. add-sqr-sqrt48.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine47.5%

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

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

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

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

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

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

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

Alternative 7: 77.2% accurate, 6.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15 \cdot 10^{-45}:\\
\;\;\;\;\frac{x \cdot z - \left(x + 4\right)}{y\_m}\\

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

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


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

    1. Initial program 90.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y} \]
      11. clear-num53.7%

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

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{z}}} - \frac{x + 4}{y} \]
      13. associate-/r/51.0%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} - \frac{x + 4}{y} \]
    6. Applied egg-rr51.0%

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

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

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

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

    if -1.14999999999999996e-45 < x < 4.20000000000000018

    1. Initial program 97.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt47.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| \]
      2. fabs-sqr47.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}} \]
      3. add-sqr-sqrt48.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine47.5%

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

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

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

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

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

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

      \[\leadsto 0 - \frac{x \cdot z - \color{blue}{4}}{y} \]
    6. Taylor expanded in y around 0 50.5%

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

    if 4.20000000000000018 < x

    1. Initial program 90.1%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt38.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| \]
      2. fabs-sqr38.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}} \]
      3. add-sqr-sqrt39.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 76.3% accurate, 6.5× speedup?

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

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

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

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


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

    1. Initial program 90.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y} \]
      11. clear-num53.7%

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

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{z}}} - \frac{x + 4}{y} \]
      13. associate-/r/51.0%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} - \frac{x + 4}{y} \]
    6. Applied egg-rr51.0%

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

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

    if -1.14999999999999996e-45 < x < 4

    1. Initial program 97.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt47.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| \]
      2. fabs-sqr47.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}} \]
      3. add-sqr-sqrt48.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine47.5%

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

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

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

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

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

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

      \[\leadsto 0 - \frac{x \cdot z - \color{blue}{4}}{y} \]
    6. Taylor expanded in y around 0 50.5%

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

    if 4 < x

    1. Initial program 90.1%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt38.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| \]
      2. fabs-sqr38.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}} \]
      3. add-sqr-sqrt39.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 77.5% accurate, 6.5× speedup?

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

\mathbf{elif}\;x \leq 4.4:\\
\;\;\;\;\frac{4 - x \cdot z}{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 < -4

    1. Initial program 89.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{\color{blue}{-4 - x}}{y}\right| \]
    7. Simplified72.6%

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    8. Step-by-step derivation
      1. add-sqr-sqrt43.3%

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

        \[\leadsto \color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}} \]
      3. add-sqr-sqrt43.8%

        \[\leadsto \color{blue}{\frac{-4 - x}{y}} \]
      4. div-inv43.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-4 - x}}{y} \]
    12. Simplified43.8%

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

    if -4 < x < 4.4000000000000004

    1. Initial program 97.1%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt48.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| \]
      2. fabs-sqr48.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}} \]
      3. add-sqr-sqrt50.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0 - \frac{x \cdot z - \color{blue}{4}}{y} \]
    6. Taylor expanded in y around 0 51.6%

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

    if 4.4000000000000004 < x

    1. Initial program 90.1%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt38.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| \]
      2. fabs-sqr38.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}} \]
      3. add-sqr-sqrt39.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 75.3% accurate, 6.5× speedup?

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

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

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

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


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

    1. Initial program 89.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{\color{blue}{-4 - x}}{y}\right| \]
    7. Simplified72.6%

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    8. Step-by-step derivation
      1. add-sqr-sqrt43.3%

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

        \[\leadsto \color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}} \]
      3. add-sqr-sqrt43.8%

        \[\leadsto \color{blue}{\frac{-4 - x}{y}} \]
      4. div-inv43.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-4 - x}}{y} \]
    12. Simplified43.8%

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

    if -4 < x < 3.8500000000000001e-25

    1. Initial program 97.1%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt49.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| \]
      2. fabs-sqr49.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}} \]
      3. add-sqr-sqrt50.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine50.0%

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

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

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

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

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

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

      \[\leadsto 0 - \frac{x \cdot z - \color{blue}{4}}{y} \]
    6. Taylor expanded in y around 0 52.4%

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

    if 3.8500000000000001e-25 < x

    1. Initial program 90.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt37.6%

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

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

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

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

        \[\leadsto \frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}} \]
    4. Applied egg-rr39.9%

      \[\leadsto \color{blue}{\frac{x + 4}{y} - x \cdot \frac{z}{y}} \]
    5. Step-by-step derivation
      1. clear-num39.8%

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

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x}{\frac{y}{z}}} \]
      3. frac-2neg39.8%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{-\frac{y}{z}}} \]
      4. frac-2neg39.8%

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

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

        \[\leadsto \frac{x + 4}{y} - \frac{-\left(-x\right)}{\color{blue}{\frac{-y}{-z}}} \]
      7. frac-2neg39.8%

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

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

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

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

        \[\leadsto \frac{\color{blue}{4}}{y} + \frac{x}{y} \]
    9. Simplified25.7%

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

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

Alternative 11: 77.0% accurate, 6.9× speedup?

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

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

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


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

    1. Initial program 90.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.14999999999999996e-45 < x

    1. Initial program 94.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt44.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| \]
      2. fabs-sqr44.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}} \]
      3. add-sqr-sqrt45.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine45.8%

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

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

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

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

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

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

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

Alternative 12: 76.8% accurate, 7.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.15 \cdot 10^{-45}:\\
\;\;\;\;\frac{x \cdot z - \left(x + 4\right)}{y\_m}\\

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


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

    1. Initial program 90.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y} \]
      11. clear-num53.7%

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

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{z}}} - \frac{x + 4}{y} \]
      13. associate-/r/51.0%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} - \frac{x + 4}{y} \]
    6. Applied egg-rr51.0%

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

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

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

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

    if -1.14999999999999996e-45 < x

    1. Initial program 94.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt44.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| \]
      2. fabs-sqr44.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}} \]
      3. add-sqr-sqrt45.2%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine45.8%

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

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

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

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

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

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

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

Alternative 13: 70.2% accurate, 11.1× speedup?

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

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

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


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

    1. Initial program 89.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{\color{blue}{-4 - x}}{y}\right| \]
    7. Simplified72.6%

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    8. Step-by-step derivation
      1. add-sqr-sqrt43.3%

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

        \[\leadsto \color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}} \]
      3. add-sqr-sqrt43.8%

        \[\leadsto \color{blue}{\frac{-4 - x}{y}} \]
      4. div-inv43.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-4 - x}}{y} \]
    12. Simplified43.8%

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

    if -4 < x

    1. Initial program 94.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine47.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot \frac{1}{y} - -1 \cdot \frac{x}{y}} \]
    9. Step-by-step derivation
      1. sub-neg34.2%

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

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

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

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

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

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

        \[\leadsto 4 \cdot \frac{1}{y} + x \cdot \frac{\color{blue}{1}}{y} \]
      8. distribute-rgt-in34.2%

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

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

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

        \[\leadsto \frac{\color{blue}{x + 4}}{y} \]
    10. Simplified34.2%

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

Alternative 14: 70.0% 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 89.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{\color{blue}{-4 - x}}{y}\right| \]
    7. Simplified72.6%

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    8. Step-by-step derivation
      1. add-sqr-sqrt43.3%

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

        \[\leadsto \color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}} \]
      3. add-sqr-sqrt43.8%

        \[\leadsto \color{blue}{\frac{-4 - x}{y}} \]
      4. div-inv43.6%

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot x}{y}} \]
      2. mul-1-neg42.4%

        \[\leadsto \frac{\color{blue}{-x}}{y} \]
    12. Simplified42.4%

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

    if -4 < x

    1. Initial program 94.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine47.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot \frac{1}{y} - -1 \cdot \frac{x}{y}} \]
    9. Step-by-step derivation
      1. sub-neg34.2%

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

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

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

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

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

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

        \[\leadsto 4 \cdot \frac{1}{y} + x \cdot \frac{\color{blue}{1}}{y} \]
      8. distribute-rgt-in34.2%

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

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

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

        \[\leadsto \frac{\color{blue}{x + 4}}{y} \]
    10. Simplified34.2%

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

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

Alternative 15: 54.8% accurate, 12.3× speedup?

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

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

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


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

    1. Initial program 89.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{\color{blue}{-4 - x}}{y}\right| \]
    7. Simplified72.6%

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    8. Step-by-step derivation
      1. add-sqr-sqrt43.3%

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

        \[\leadsto \color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}} \]
      3. add-sqr-sqrt43.8%

        \[\leadsto \color{blue}{\frac{-4 - x}{y}} \]
      4. div-inv43.6%

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot x}{y}} \]
      2. mul-1-neg42.4%

        \[\leadsto \frac{\color{blue}{-x}}{y} \]
    12. Simplified42.4%

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

    if -10.5 < x

    1. Initial program 94.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine47.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 40.4% 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 93.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
    15. fma-undefine45.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{4}{y}} \]
  9. Add Preprocessing

Reproduce

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