fabs fraction 1

Percentage Accurate: 91.9% → 99.7%
Time: 12.2s
Alternatives: 16
Speedup: 2.7×

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

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

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

Alternative 1: 99.7% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 87.6%

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

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

    if 3.5999999999999999e-43 < y

    1. Initial program 98.6%

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

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

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

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

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

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

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

Alternative 2: 97.7% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 98.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 98.6%

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

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

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

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

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

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x}{\frac{y}{z}}}\right| \]
    5. Step-by-step derivation
      1. add-sqr-sqrt93.0%

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. 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 3 regimes into one program.
  4. Final simplification97.7%

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

Alternative 3: 97.8% accurate, 0.9× speedup?

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 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.5%

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\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 5: 94.7% accurate, 2.7× speedup?

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

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

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

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


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

    1. Initial program 98.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 98.6%

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

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

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

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

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

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x}{\frac{y}{z}}}\right| \]
    5. Step-by-step derivation
      1. add-sqr-sqrt93.0%

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

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

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

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

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

    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. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt0.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-sqr0.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-sqrt0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0 - \color{blue}{x \cdot \frac{z + -1}{y}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt45.0%

        \[\leadsto \color{blue}{\sqrt{0 - x \cdot \frac{z + -1}{y}} \cdot \sqrt{0 - x \cdot \frac{z + -1}{y}}} \]
      2. sqrt-unprod100.0%

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{z + -1}{y}} \]
      8. *-commutative55.0%

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

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

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

Alternative 6: 77.3% accurate, 5.8× speedup?

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

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

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

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


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

    1. Initial program 84.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0 - \color{blue}{x \cdot \frac{z + -1}{y}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt42.1%

        \[\leadsto \color{blue}{\sqrt{0 - x \cdot \frac{z + -1}{y}} \cdot \sqrt{0 - x \cdot \frac{z + -1}{y}}} \]
      2. sqrt-unprod72.1%

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{x \cdot \frac{z + -1}{y}} \cdot \sqrt{x \cdot \frac{z + -1}{y}}} \]
      7. add-sqr-sqrt57.9%

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

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

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

    if -2.59999999999999983e-12 < 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-sqrt53.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-sqr53.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-sqrt55.0%

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

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

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

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

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

    if 4 < x

    1. Initial program 86.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - \color{blue}{\frac{x}{\frac{y}{z + -1}}} \]
    9. Applied egg-rr45.9%

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

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

Alternative 7: 74.4% accurate, 6.2× speedup?

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

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

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

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


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

    1. Initial program 84.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0 - \color{blue}{x \cdot \frac{z + -1}{y}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt42.1%

        \[\leadsto \color{blue}{\sqrt{0 - x \cdot \frac{z + -1}{y}} \cdot \sqrt{0 - x \cdot \frac{z + -1}{y}}} \]
      2. sqrt-unprod72.1%

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{x \cdot \frac{z + -1}{y}} \cdot \sqrt{x \cdot \frac{z + -1}{y}}} \]
      7. add-sqr-sqrt57.9%

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

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

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

    if -2.59999999999999983e-12 < x < 1e6

    1. Initial program 97.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{x + 4}{y}}} \]
      18. sqrt-unprod41.6%

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

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

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

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

    if 1e6 < x

    1. Initial program 85.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - x \cdot \frac{z + \color{blue}{-1}}{y} \]
    7. Simplified46.8%

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

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

        \[\leadsto 0 - \color{blue}{\frac{x}{\frac{y}{z + -1}}} \]
    9. Applied egg-rr46.8%

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

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

Alternative 8: 74.3% accurate, 6.2× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(-x\right)\\


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

    1. Initial program 84.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0 - \color{blue}{x \cdot \frac{z + -1}{y}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt42.1%

        \[\leadsto \color{blue}{\sqrt{0 - x \cdot \frac{z + -1}{y}} \cdot \sqrt{0 - x \cdot \frac{z + -1}{y}}} \]
      2. sqrt-unprod72.1%

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{x \cdot \frac{z + -1}{y}} \cdot \sqrt{x \cdot \frac{z + -1}{y}}} \]
      7. add-sqr-sqrt57.9%

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

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

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

    if -4.0000000000000003e-15 < x < 4.9e5

    1. Initial program 97.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{x + 4}{y}}} \]
      18. sqrt-unprod41.6%

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

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

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

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

    if 4.9e5 < x

    1. Initial program 85.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - x \cdot \frac{z + \color{blue}{-1}}{y} \]
    7. Simplified46.8%

      \[\leadsto 0 - \color{blue}{x \cdot \frac{z + -1}{y}} \]
    8. Step-by-step derivation
      1. sub0-neg46.8%

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

        \[\leadsto -\color{blue}{\frac{z + -1}{y} \cdot x} \]
      3. distribute-rgt-neg-in46.8%

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

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

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

Alternative 9: 67.8% accurate, 7.9× speedup?

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

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

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

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


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

    1. Initial program 84.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.52 < 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-sqrt54.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0 - \color{blue}{\frac{-4}{y}} \]
    6. Step-by-step derivation
      1. sub0-neg41.1%

        \[\leadsto \color{blue}{-\frac{-4}{y}} \]
      2. distribute-neg-frac241.1%

        \[\leadsto \color{blue}{\frac{-4}{-y}} \]
    7. Applied egg-rr41.1%

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

    if 4 < x

    1. Initial program 86.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 79.7% accurate, 7.9× speedup?

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

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


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

    1. Initial program 84.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0 - \color{blue}{x \cdot \frac{z + -1}{y}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt0.5%

        \[\leadsto 0 - \color{blue}{\sqrt{x \cdot \frac{z + -1}{y}} \cdot \sqrt{x \cdot \frac{z + -1}{y}}} \]
      2. sqrt-unprod0.8%

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

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

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

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

        \[\leadsto 0 - \color{blue}{\sqrt{0 - x \cdot \frac{z + -1}{y}} \cdot \sqrt{0 - x \cdot \frac{z + -1}{y}}} \]
      7. add-sqr-sqrt57.9%

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

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

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

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

        \[\leadsto 0 - \color{blue}{\frac{-x}{\frac{y}{z + -1}}} \]
    9. Applied egg-rr58.0%

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

    if -2.59999999999999983e-12 < x

    1. Initial program 92.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 79.7% accurate, 7.9× speedup?

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

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

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


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

    1. Initial program 84.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0 - \color{blue}{x \cdot \frac{z + -1}{y}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt42.1%

        \[\leadsto \color{blue}{\sqrt{0 - x \cdot \frac{z + -1}{y}} \cdot \sqrt{0 - x \cdot \frac{z + -1}{y}}} \]
      2. sqrt-unprod72.1%

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{x \cdot \frac{z + -1}{y}} \cdot \sqrt{x \cdot \frac{z + -1}{y}}} \]
      7. add-sqr-sqrt57.9%

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

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

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

    if -2.59999999999999983e-12 < x

    1. Initial program 92.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 71.0% accurate, 9.2× speedup?

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

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

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


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

    1. Initial program 84.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0 - \color{blue}{x \cdot \frac{z + -1}{y}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt42.1%

        \[\leadsto \color{blue}{\sqrt{0 - x \cdot \frac{z + -1}{y}} \cdot \sqrt{0 - x \cdot \frac{z + -1}{y}}} \]
      2. sqrt-unprod72.1%

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{x \cdot \frac{z + -1}{y}} \cdot \sqrt{x \cdot \frac{z + -1}{y}}} \]
      7. add-sqr-sqrt57.9%

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

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

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

    if -2.6999999999999999e-14 < x

    1. Initial program 92.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\left|\frac{-4 - x}{y}\right| \cdot \left|\frac{-4 - x}{y}\right|}} \]
      3. neg-fabs48.5%

        \[\leadsto \sqrt{\color{blue}{\left|-\frac{-4 - x}{y}\right|} \cdot \left|\frac{-4 - x}{y}\right|} \]
      4. neg-fabs48.5%

        \[\leadsto \sqrt{\left|-\frac{-4 - x}{y}\right| \cdot \color{blue}{\left|-\frac{-4 - x}{y}\right|}} \]
      5. sqr-abs48.5%

        \[\leadsto \sqrt{\color{blue}{\left(-\frac{-4 - x}{y}\right) \cdot \left(-\frac{-4 - x}{y}\right)}} \]
      6. distribute-frac-neg248.5%

        \[\leadsto \sqrt{\color{blue}{\frac{-4 - x}{-y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      7. sub-neg48.5%

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\frac{x + 4}{y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      12. distribute-frac-neg248.5%

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

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

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

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

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

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{x + 4}{y}}} \]
      18. sqrt-unprod34.4%

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

        \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
      20. frac-2neg35.4%

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

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

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

Alternative 13: 68.7% accurate, 11.1× speedup?

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

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

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


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

    1. Initial program 84.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4 < x

    1. Initial program 93.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(-\frac{-4 - x}{y}\right) \cdot \left(-\frac{-4 - x}{y}\right)}} \]
      6. distribute-frac-neg248.2%

        \[\leadsto \sqrt{\color{blue}{\frac{-4 - x}{-y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      7. sub-neg48.2%

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\frac{x + 4}{y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      12. distribute-frac-neg248.2%

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

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-4 + \left(-x\right)}}{-y}} \]
      14. metadata-eval48.2%

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

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

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{-\color{blue}{\left(x + 4\right)}}{-y}} \]
      17. frac-2neg48.2%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{x + 4}{y}}} \]
      18. sqrt-unprod34.2%

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

        \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
      20. frac-2neg35.2%

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

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

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

Alternative 14: 53.7% accurate, 12.3× speedup?

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

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

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


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

    1. Initial program 92.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0 - \color{blue}{\frac{-4}{y}} \]
    6. Step-by-step derivation
      1. sub0-neg28.1%

        \[\leadsto \color{blue}{-\frac{-4}{y}} \]
      2. distribute-neg-frac228.1%

        \[\leadsto \color{blue}{\frac{-4}{-y}} \]
    7. Applied egg-rr28.1%

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

    if 4 < x

    1. Initial program 86.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \color{blue}{\left(-\frac{-4 - x}{y}\right)} \]
      14. distribute-neg-in43.6%

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine44.9%

        \[\leadsto -\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      16. neg-sub044.9%

        \[\leadsto \color{blue}{0 - \mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      17. fma-undefine43.6%

        \[\leadsto 0 - \color{blue}{\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      18. associate-*r/37.2%

        \[\leadsto 0 - \left(\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right) \]
      19. associate-*l/39.5%

        \[\leadsto 0 - \left(\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right) \]
    4. Applied egg-rr41.3%

      \[\leadsto \color{blue}{0 - \frac{x \cdot z - \left(x + 4\right)}{y}} \]
    5. Taylor expanded in x around inf 39.6%

      \[\leadsto 0 - \color{blue}{\frac{x \cdot \left(z - 1\right)}{y}} \]
    6. Step-by-step derivation
      1. associate-/l*46.0%

        \[\leadsto 0 - \color{blue}{x \cdot \frac{z - 1}{y}} \]
      2. sub-neg46.0%

        \[\leadsto 0 - x \cdot \frac{\color{blue}{z + \left(-1\right)}}{y} \]
      3. metadata-eval46.0%

        \[\leadsto 0 - x \cdot \frac{z + \color{blue}{-1}}{y} \]
    7. Simplified46.0%

      \[\leadsto 0 - \color{blue}{x \cdot \frac{z + -1}{y}} \]
    8. Taylor expanded in z around 0 22.8%

      \[\leadsto \color{blue}{\frac{x}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 15: 18.0% accurate, 37.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \frac{x}{y\_m} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z) :precision binary64 (/ x y_m))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	return x / 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 = x / y_m
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	return x / y_m;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	return x / y_m
y_m = abs(y)
function code(x, y_m, z)
	return Float64(x / y_m)
end
y_m = abs(y);
function tmp = code(x, y_m, z)
	tmp = x / y_m;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := N[(x / y$95$m), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|

\\
\frac{x}{y\_m}
\end{array}
Derivation
  1. Initial program 90.8%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-sqr-sqrt45.4%

      \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
    2. fabs-sqr45.4%

      \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
    3. add-sqr-sqrt46.3%

      \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
    4. sub-neg46.3%

      \[\leadsto \color{blue}{\frac{x + 4}{y} + \left(-\frac{x}{y} \cdot z\right)} \]
    5. +-commutative46.3%

      \[\leadsto \color{blue}{\left(-\frac{x}{y} \cdot z\right) + \frac{x + 4}{y}} \]
    6. associate-*l/47.1%

      \[\leadsto \left(-\color{blue}{\frac{x \cdot z}{y}}\right) + \frac{x + 4}{y} \]
    7. associate-*r/47.2%

      \[\leadsto \left(-\color{blue}{x \cdot \frac{z}{y}}\right) + \frac{x + 4}{y} \]
    8. frac-2neg47.2%

      \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \color{blue}{\frac{-\left(x + 4\right)}{-y}} \]
    9. +-commutative47.2%

      \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{-\color{blue}{\left(4 + x\right)}}{-y} \]
    10. distribute-neg-in47.2%

      \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{-y} \]
    11. metadata-eval47.2%

      \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{-4} + \left(-x\right)}{-y} \]
    12. sub-neg47.2%

      \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{-4 - x}}{-y} \]
    13. distribute-frac-neg247.2%

      \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \color{blue}{\left(-\frac{-4 - x}{y}\right)} \]
    14. distribute-neg-in47.2%

      \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
    15. fma-undefine47.6%

      \[\leadsto -\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
    16. neg-sub047.6%

      \[\leadsto \color{blue}{0 - \mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
    17. fma-undefine47.2%

      \[\leadsto 0 - \color{blue}{\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
    18. associate-*r/47.1%

      \[\leadsto 0 - \left(\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right) \]
    19. associate-*l/46.3%

      \[\leadsto 0 - \left(\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right) \]
  4. Applied egg-rr49.1%

    \[\leadsto \color{blue}{0 - \frac{x \cdot z - \left(x + 4\right)}{y}} \]
  5. Taylor expanded in x around inf 30.3%

    \[\leadsto 0 - \color{blue}{\frac{x \cdot \left(z - 1\right)}{y}} \]
  6. Step-by-step derivation
    1. associate-/l*31.1%

      \[\leadsto 0 - \color{blue}{x \cdot \frac{z - 1}{y}} \]
    2. sub-neg31.1%

      \[\leadsto 0 - x \cdot \frac{\color{blue}{z + \left(-1\right)}}{y} \]
    3. metadata-eval31.1%

      \[\leadsto 0 - x \cdot \frac{z + \color{blue}{-1}}{y} \]
  7. Simplified31.1%

    \[\leadsto 0 - \color{blue}{x \cdot \frac{z + -1}{y}} \]
  8. Taylor expanded in z around 0 16.0%

    \[\leadsto \color{blue}{\frac{x}{y}} \]
  9. Add Preprocessing

Alternative 16: 1.7% accurate, 37.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \frac{-4}{y\_m} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z) :precision binary64 (/ -4.0 y_m))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	return -4.0 / y_m;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    code = (-4.0d0) / y_m
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	return -4.0 / y_m;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	return -4.0 / y_m
y_m = abs(y)
function code(x, y_m, z)
	return Float64(-4.0 / y_m)
end
y_m = abs(y);
function tmp = code(x, y_m, z)
	tmp = -4.0 / y_m;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := N[(-4.0 / y$95$m), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|

\\
\frac{-4}{y\_m}
\end{array}
Derivation
  1. Initial program 90.8%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Step-by-step derivation
    1. fabs-sub90.8%

      \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
    2. associate-*l/92.3%

      \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
    3. associate-*r/93.8%

      \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
    4. fma-neg95.3%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
    5. distribute-neg-frac95.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
    6. +-commutative95.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
    7. distribute-neg-in95.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
    8. unsub-neg95.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
    9. metadata-eval95.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
  3. Simplified95.3%

    \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
  4. Add Preprocessing
  5. Taylor expanded in z around 0 69.7%

    \[\leadsto \left|\color{blue}{-1 \cdot \frac{4 + x}{y}}\right| \]
  6. Step-by-step derivation
    1. associate-*r/69.7%

      \[\leadsto \left|\color{blue}{\frac{-1 \cdot \left(4 + x\right)}{y}}\right| \]
    2. distribute-lft-in69.7%

      \[\leadsto \left|\frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y}\right| \]
    3. metadata-eval69.7%

      \[\leadsto \left|\frac{\color{blue}{-4} + -1 \cdot x}{y}\right| \]
    4. neg-mul-169.7%

      \[\leadsto \left|\frac{-4 + \color{blue}{\left(-x\right)}}{y}\right| \]
    5. sub-neg69.7%

      \[\leadsto \left|\frac{\color{blue}{-4 - x}}{y}\right| \]
  7. Simplified69.7%

    \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
  8. Step-by-step derivation
    1. add-sqr-sqrt36.2%

      \[\leadsto \left|\color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}}\right| \]
    2. fabs-sqr36.2%

      \[\leadsto \color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}} \]
    3. add-sqr-sqrt37.1%

      \[\leadsto \color{blue}{\frac{-4 - x}{y}} \]
    4. div-inv37.1%

      \[\leadsto \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}} \]
  9. Applied egg-rr37.1%

    \[\leadsto \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}} \]
  10. Taylor expanded in x around 0 17.6%

    \[\leadsto \color{blue}{\frac{-4}{y}} \]
  11. Add Preprocessing

Reproduce

?
herbie shell --seed 2024137 
(FPCore (x y z)
  :name "fabs fraction 1"
  :precision binary64
  (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))