fabs fraction 1

Percentage Accurate: 91.9% → 99.1%
Time: 11.3s
Alternatives: 17
Speedup: 0.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 17 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.1% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x + 4}{y}\\ t_1 := \left|t\_0 - z \cdot \frac{x}{y}\right|\\ \mathbf{if}\;t\_1 \leq 10^{-210} \lor \neg \left(t\_1 \leq 2 \cdot 10^{+301}\right):\\ \;\;\;\;\left|\frac{-1}{y} \cdot \mathsf{fma}\left(x, z, -4 - x\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|t\_0 - \frac{z}{\frac{y}{x}}\right|\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (+ x 4.0) y)) (t_1 (fabs (- t_0 (* z (/ x y))))))
   (if (or (<= t_1 1e-210) (not (<= t_1 2e+301)))
     (fabs (* (/ -1.0 y) (fma x z (- -4.0 x))))
     (fabs (- t_0 (/ z (/ y x)))))))
double code(double x, double y, double z) {
	double t_0 = (x + 4.0) / y;
	double t_1 = fabs((t_0 - (z * (x / y))));
	double tmp;
	if ((t_1 <= 1e-210) || !(t_1 <= 2e+301)) {
		tmp = fabs(((-1.0 / y) * fma(x, z, (-4.0 - x))));
	} else {
		tmp = fabs((t_0 - (z / (y / x))));
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(Float64(x + 4.0) / y)
	t_1 = abs(Float64(t_0 - Float64(z * Float64(x / y))))
	tmp = 0.0
	if ((t_1 <= 1e-210) || !(t_1 <= 2e+301))
		tmp = abs(Float64(Float64(-1.0 / y) * fma(x, z, Float64(-4.0 - x))));
	else
		tmp = abs(Float64(t_0 - Float64(z / Float64(y / x))));
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(t$95$0 - N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[t$95$1, 1e-210], N[Not[LessEqual[t$95$1, 2e+301]], $MachinePrecision]], N[Abs[N[(N[(-1.0 / y), $MachinePrecision] * N[(x * z + N[(-4.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(t$95$0 - N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x + 4}{y}\\
t_1 := \left|t\_0 - z \cdot \frac{x}{y}\right|\\
\mathbf{if}\;t\_1 \leq 10^{-210} \lor \neg \left(t\_1 \leq 2 \cdot 10^{+301}\right):\\
\;\;\;\;\left|\frac{-1}{y} \cdot \mathsf{fma}\left(x, z, -4 - x\right)\right|\\

\mathbf{else}:\\
\;\;\;\;\left|t\_0 - \frac{z}{\frac{y}{x}}\right|\\


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

    1. Initial program 64.8%

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

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

    if 1e-210 < (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))) < 2.00000000000000011e301

    1. Initial program 99.8%

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

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

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

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

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

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

Alternative 2: 96.1% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 97.5%

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

Alternative 3: 97.6% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 4.9999999999999998e86

    1. Initial program 90.1%

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

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

    if 4.9999999999999998e86 < y

    1. Initial program 90.7%

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 96.2% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 97.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. Simplified100.0%

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

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

    \[\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{-1}{y} \cdot \left(x \cdot z\right)\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 43.3% accurate, 5.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -17000000:\\ \;\;\;\;\frac{x}{\frac{y}{-1 + z}}\\ \mathbf{elif}\;x \leq -9.8 \cdot 10^{-48}:\\ \;\;\;\;x \cdot \frac{z}{-y}\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{+21}:\\ \;\;\;\;\frac{x + 4}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{1 - z}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -17000000.0)
   (/ x (/ y (+ -1.0 z)))
   (if (<= x -9.8e-48)
     (* x (/ z (- y)))
     (if (<= x 3.4e+21) (/ (+ x 4.0) y) (* x (/ (- 1.0 z) y))))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -17000000.0) {
		tmp = x / (y / (-1.0 + z));
	} else if (x <= -9.8e-48) {
		tmp = x * (z / -y);
	} else if (x <= 3.4e+21) {
		tmp = (x + 4.0) / y;
	} else {
		tmp = x * ((1.0 - z) / y);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-17000000.0d0)) then
        tmp = x / (y / ((-1.0d0) + z))
    else if (x <= (-9.8d-48)) then
        tmp = x * (z / -y)
    else if (x <= 3.4d+21) then
        tmp = (x + 4.0d0) / y
    else
        tmp = x * ((1.0d0 - z) / y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -17000000.0) {
		tmp = x / (y / (-1.0 + z));
	} else if (x <= -9.8e-48) {
		tmp = x * (z / -y);
	} else if (x <= 3.4e+21) {
		tmp = (x + 4.0) / y;
	} else {
		tmp = x * ((1.0 - z) / y);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -17000000.0:
		tmp = x / (y / (-1.0 + z))
	elif x <= -9.8e-48:
		tmp = x * (z / -y)
	elif x <= 3.4e+21:
		tmp = (x + 4.0) / y
	else:
		tmp = x * ((1.0 - z) / y)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -17000000.0)
		tmp = Float64(x / Float64(y / Float64(-1.0 + z)));
	elseif (x <= -9.8e-48)
		tmp = Float64(x * Float64(z / Float64(-y)));
	elseif (x <= 3.4e+21)
		tmp = Float64(Float64(x + 4.0) / y);
	else
		tmp = Float64(x * Float64(Float64(1.0 - z) / y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -17000000.0)
		tmp = x / (y / (-1.0 + z));
	elseif (x <= -9.8e-48)
		tmp = x * (z / -y);
	elseif (x <= 3.4e+21)
		tmp = (x + 4.0) / y;
	else
		tmp = x * ((1.0 - z) / y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -17000000.0], N[(x / N[(y / N[(-1.0 + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -9.8e-48], N[(x * N[(z / (-y)), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.4e+21], N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision], N[(x * N[(N[(1.0 - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -17000000:\\
\;\;\;\;\frac{x}{\frac{y}{-1 + z}}\\

\mathbf{elif}\;x \leq -9.8 \cdot 10^{-48}:\\
\;\;\;\;x \cdot \frac{z}{-y}\\

\mathbf{elif}\;x \leq 3.4 \cdot 10^{+21}:\\
\;\;\;\;\frac{x + 4}{y}\\

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


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

    1. Initial program 80.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.7e7 < x < -9.8000000000000005e-48

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot z}{y}} \]
    8. Step-by-step derivation
      1. mul-1-neg47.9%

        \[\leadsto \color{blue}{-\frac{x \cdot z}{y}} \]
      2. associate-*r/48.0%

        \[\leadsto -\color{blue}{x \cdot \frac{z}{y}} \]
      3. distribute-rgt-neg-in48.0%

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

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

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

    if -9.8000000000000005e-48 < x < 3.4e21

    1. Initial program 95.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.4e21 < x

    1. Initial program 87.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\color{blue}{z \cdot x - x}}{y} \]
      9. *-lft-identity60.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 43.3% accurate, 5.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -19000000:\\ \;\;\;\;x \cdot \frac{-1 + z}{y}\\ \mathbf{elif}\;x \leq -1 \cdot 10^{-47}:\\ \;\;\;\;x \cdot \frac{z}{-y}\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{+23}:\\ \;\;\;\;\frac{x + 4}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{1 - z}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -19000000.0)
   (* x (/ (+ -1.0 z) y))
   (if (<= x -1e-47)
     (* x (/ z (- y)))
     (if (<= x 4.8e+23) (/ (+ x 4.0) y) (* x (/ (- 1.0 z) y))))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -19000000.0) {
		tmp = x * ((-1.0 + z) / y);
	} else if (x <= -1e-47) {
		tmp = x * (z / -y);
	} else if (x <= 4.8e+23) {
		tmp = (x + 4.0) / y;
	} else {
		tmp = x * ((1.0 - z) / y);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-19000000.0d0)) then
        tmp = x * (((-1.0d0) + z) / y)
    else if (x <= (-1d-47)) then
        tmp = x * (z / -y)
    else if (x <= 4.8d+23) then
        tmp = (x + 4.0d0) / y
    else
        tmp = x * ((1.0d0 - z) / y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -19000000.0) {
		tmp = x * ((-1.0 + z) / y);
	} else if (x <= -1e-47) {
		tmp = x * (z / -y);
	} else if (x <= 4.8e+23) {
		tmp = (x + 4.0) / y;
	} else {
		tmp = x * ((1.0 - z) / y);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -19000000.0:
		tmp = x * ((-1.0 + z) / y)
	elif x <= -1e-47:
		tmp = x * (z / -y)
	elif x <= 4.8e+23:
		tmp = (x + 4.0) / y
	else:
		tmp = x * ((1.0 - z) / y)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -19000000.0)
		tmp = Float64(x * Float64(Float64(-1.0 + z) / y));
	elseif (x <= -1e-47)
		tmp = Float64(x * Float64(z / Float64(-y)));
	elseif (x <= 4.8e+23)
		tmp = Float64(Float64(x + 4.0) / y);
	else
		tmp = Float64(x * Float64(Float64(1.0 - z) / y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -19000000.0)
		tmp = x * ((-1.0 + z) / y);
	elseif (x <= -1e-47)
		tmp = x * (z / -y);
	elseif (x <= 4.8e+23)
		tmp = (x + 4.0) / y;
	else
		tmp = x * ((1.0 - z) / y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -19000000.0], N[(x * N[(N[(-1.0 + z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1e-47], N[(x * N[(z / (-y)), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.8e+23], N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision], N[(x * N[(N[(1.0 - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -19000000:\\
\;\;\;\;x \cdot \frac{-1 + z}{y}\\

\mathbf{elif}\;x \leq -1 \cdot 10^{-47}:\\
\;\;\;\;x \cdot \frac{z}{-y}\\

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

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


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

    1. Initial program 80.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.9e7 < x < -9.9999999999999997e-48

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot z}{y}} \]
    8. Step-by-step derivation
      1. mul-1-neg47.9%

        \[\leadsto \color{blue}{-\frac{x \cdot z}{y}} \]
      2. associate-*r/48.0%

        \[\leadsto -\color{blue}{x \cdot \frac{z}{y}} \]
      3. distribute-rgt-neg-in48.0%

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

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

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

    if -9.9999999999999997e-48 < x < 4.8e23

    1. Initial program 95.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.8e23 < x

    1. Initial program 87.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\color{blue}{z \cdot x - x}}{y} \]
      9. *-lft-identity60.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 49.4% accurate, 6.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -420000000:\\ \;\;\;\;\frac{x}{\frac{y}{-1 + z}}\\ \mathbf{elif}\;x \leq 4.2:\\ \;\;\;\;\frac{4 - x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{1 - z}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -420000000.0)
   (/ x (/ y (+ -1.0 z)))
   (if (<= x 4.2) (/ (- 4.0 (* x z)) y) (* x (/ (- 1.0 z) y)))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -420000000.0) {
		tmp = x / (y / (-1.0 + z));
	} else if (x <= 4.2) {
		tmp = (4.0 - (x * z)) / y;
	} else {
		tmp = x * ((1.0 - z) / y);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-420000000.0d0)) then
        tmp = x / (y / ((-1.0d0) + z))
    else if (x <= 4.2d0) then
        tmp = (4.0d0 - (x * z)) / y
    else
        tmp = x * ((1.0d0 - z) / y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -420000000.0) {
		tmp = x / (y / (-1.0 + z));
	} else if (x <= 4.2) {
		tmp = (4.0 - (x * z)) / y;
	} else {
		tmp = x * ((1.0 - z) / y);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -420000000.0:
		tmp = x / (y / (-1.0 + z))
	elif x <= 4.2:
		tmp = (4.0 - (x * z)) / y
	else:
		tmp = x * ((1.0 - z) / y)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -420000000.0)
		tmp = Float64(x / Float64(y / Float64(-1.0 + z)));
	elseif (x <= 4.2)
		tmp = Float64(Float64(4.0 - Float64(x * z)) / y);
	else
		tmp = Float64(x * Float64(Float64(1.0 - z) / y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -420000000.0)
		tmp = x / (y / (-1.0 + z));
	elseif (x <= 4.2)
		tmp = (4.0 - (x * z)) / y;
	else
		tmp = x * ((1.0 - z) / y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -420000000.0], N[(x / N[(y / N[(-1.0 + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.2], N[(N[(4.0 - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(x * N[(N[(1.0 - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -420000000:\\
\;\;\;\;\frac{x}{\frac{y}{-1 + z}}\\

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

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


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

    1. Initial program 80.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.2e8 < x < 4.20000000000000018

    1. Initial program 95.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.20000000000000018 < x

    1. Initial program 88.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\color{blue}{z \cdot x - x}}{y} \]
      9. *-lft-identity61.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 47.4% accurate, 6.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{-z}{\frac{y}{x}} - \frac{x + 4}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x + 4\right) - x \cdot z}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -4.0)
   (- (/ (- z) (/ y x)) (/ (+ x 4.0) y))
   (/ (- (+ x 4.0) (* x z)) y)))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = (-z / (y / x)) - ((x + 4.0) / y);
	} else {
		tmp = ((x + 4.0) - (x * z)) / y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-4.0d0)) then
        tmp = (-z / (y / x)) - ((x + 4.0d0) / y)
    else
        tmp = ((x + 4.0d0) - (x * z)) / y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = (-z / (y / x)) - ((x + 4.0) / y);
	} else {
		tmp = ((x + 4.0) - (x * z)) / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -4.0:
		tmp = (-z / (y / x)) - ((x + 4.0) / y)
	else:
		tmp = ((x + 4.0) - (x * z)) / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -4.0)
		tmp = Float64(Float64(Float64(-z) / Float64(y / x)) - Float64(Float64(x + 4.0) / y));
	else
		tmp = Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -4.0)
		tmp = (-z / (y / x)) - ((x + 4.0) / y);
	else
		tmp = ((x + 4.0) - (x * z)) / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -4.0], N[(N[((-z) / N[(y / x), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 81.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4 < x

    1. Initial program 93.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 39.8% accurate, 6.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -380000000:\\ \;\;\;\;x \cdot \frac{-1 + z}{y}\\ \mathbf{elif}\;x \leq -1 \cdot 10^{-47}:\\ \;\;\;\;x \cdot \frac{z}{-y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -380000000.0)
   (* x (/ (+ -1.0 z) y))
   (if (<= x -1e-47) (* x (/ z (- y))) (/ (+ x 4.0) y))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -380000000.0) {
		tmp = x * ((-1.0 + z) / y);
	} else if (x <= -1e-47) {
		tmp = x * (z / -y);
	} else {
		tmp = (x + 4.0) / y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-380000000.0d0)) then
        tmp = x * (((-1.0d0) + z) / y)
    else if (x <= (-1d-47)) then
        tmp = x * (z / -y)
    else
        tmp = (x + 4.0d0) / y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -380000000.0) {
		tmp = x * ((-1.0 + z) / y);
	} else if (x <= -1e-47) {
		tmp = x * (z / -y);
	} else {
		tmp = (x + 4.0) / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -380000000.0:
		tmp = x * ((-1.0 + z) / y)
	elif x <= -1e-47:
		tmp = x * (z / -y)
	else:
		tmp = (x + 4.0) / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -380000000.0)
		tmp = Float64(x * Float64(Float64(-1.0 + z) / y));
	elseif (x <= -1e-47)
		tmp = Float64(x * Float64(z / Float64(-y)));
	else
		tmp = Float64(Float64(x + 4.0) / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -380000000.0)
		tmp = x * ((-1.0 + z) / y);
	elseif (x <= -1e-47)
		tmp = x * (z / -y);
	else
		tmp = (x + 4.0) / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -380000000.0], N[(x * N[(N[(-1.0 + z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1e-47], N[(x * N[(z / (-y)), $MachinePrecision]), $MachinePrecision], N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -380000000:\\
\;\;\;\;x \cdot \frac{-1 + z}{y}\\

\mathbf{elif}\;x \leq -1 \cdot 10^{-47}:\\
\;\;\;\;x \cdot \frac{z}{-y}\\

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


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

    1. Initial program 80.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.8e8 < x < -9.9999999999999997e-48

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x \cdot z}{y}} \]
    8. Step-by-step derivation
      1. mul-1-neg47.9%

        \[\leadsto \color{blue}{-\frac{x \cdot z}{y}} \]
      2. associate-*r/48.0%

        \[\leadsto -\color{blue}{x \cdot \frac{z}{y}} \]
      3. distribute-rgt-neg-in48.0%

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

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

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

    if -9.9999999999999997e-48 < x

    1. Initial program 93.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 47.3% accurate, 7.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{-z}{\frac{y}{x}} - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x + 4\right) - x \cdot z}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -4.0) (- (/ (- z) (/ y x)) (/ x y)) (/ (- (+ x 4.0) (* x z)) y)))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = (-z / (y / x)) - (x / y);
	} else {
		tmp = ((x + 4.0) - (x * z)) / y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-4.0d0)) then
        tmp = (-z / (y / x)) - (x / y)
    else
        tmp = ((x + 4.0d0) - (x * z)) / y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = (-z / (y / x)) - (x / y);
	} else {
		tmp = ((x + 4.0) - (x * z)) / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -4.0:
		tmp = (-z / (y / x)) - (x / y)
	else:
		tmp = ((x + 4.0) - (x * z)) / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -4.0)
		tmp = Float64(Float64(Float64(-z) / Float64(y / x)) - Float64(x / y));
	else
		tmp = Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -4.0)
		tmp = (-z / (y / x)) - (x / y);
	else
		tmp = ((x + 4.0) - (x * z)) / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -4.0], N[(N[((-z) / N[(y / x), $MachinePrecision]), $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 81.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4 < x

    1. Initial program 93.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 49.1% accurate, 7.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -31500000:\\ \;\;\;\;\frac{x}{\frac{y}{-1 + z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x + 4\right) - x \cdot z}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -31500000.0) (/ x (/ y (+ -1.0 z))) (/ (- (+ x 4.0) (* x z)) y)))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -31500000.0) {
		tmp = x / (y / (-1.0 + z));
	} else {
		tmp = ((x + 4.0) - (x * z)) / y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-31500000.0d0)) then
        tmp = x / (y / ((-1.0d0) + z))
    else
        tmp = ((x + 4.0d0) - (x * z)) / y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -31500000.0) {
		tmp = x / (y / (-1.0 + z));
	} else {
		tmp = ((x + 4.0) - (x * z)) / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -31500000.0:
		tmp = x / (y / (-1.0 + z))
	else:
		tmp = ((x + 4.0) - (x * z)) / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -31500000.0)
		tmp = Float64(x / Float64(y / Float64(-1.0 + z)));
	else
		tmp = Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -31500000.0)
		tmp = x / (y / (-1.0 + z));
	else
		tmp = ((x + 4.0) - (x * z)) / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -31500000.0], N[(x / N[(y / N[(-1.0 + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -31500000:\\
\;\;\;\;\frac{x}{\frac{y}{-1 + z}}\\

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


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

    1. Initial program 80.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.15e7 < x

    1. Initial program 93.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 35.1% accurate, 8.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.55:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\frac{4}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -1.55) (/ (- x) y) (if (<= x 4.0) (/ 4.0 y) (/ x y))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -1.55) {
		tmp = -x / y;
	} else if (x <= 4.0) {
		tmp = 4.0 / y;
	} else {
		tmp = x / y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-1.55d0)) then
        tmp = -x / y
    else if (x <= 4.0d0) then
        tmp = 4.0d0 / y
    else
        tmp = x / y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -1.55) {
		tmp = -x / y;
	} else if (x <= 4.0) {
		tmp = 4.0 / y;
	} else {
		tmp = x / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -1.55:
		tmp = -x / y
	elif x <= 4.0:
		tmp = 4.0 / y
	else:
		tmp = x / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -1.55)
		tmp = Float64(Float64(-x) / y);
	elseif (x <= 4.0)
		tmp = Float64(4.0 / y);
	else
		tmp = Float64(x / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -1.55)
		tmp = -x / y;
	elseif (x <= 4.0)
		tmp = 4.0 / y;
	else
		tmp = x / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -1.55], N[((-x) / y), $MachinePrecision], If[LessEqual[x, 4.0], N[(4.0 / y), $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 81.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{y}} \]
    11. Step-by-step derivation
      1. mul-1-neg35.1%

        \[\leadsto \color{blue}{-\frac{x}{y}} \]
      2. distribute-frac-neg35.1%

        \[\leadsto \color{blue}{\frac{-x}{y}} \]
    12. Simplified35.1%

      \[\leadsto \color{blue}{\frac{-x}{y}} \]

    if -1.55000000000000004 < x < 4

    1. Initial program 95.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub95.7%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/99.8%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/86.9%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def86.9%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac86.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative86.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in86.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg86.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval86.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified86.9%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine86.9%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
      2. associate-*r/99.8%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
      3. associate-*l/95.7%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
      4. div-inv95.7%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
      5. sub-neg95.7%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval95.7%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y}\right| \]
      7. distribute-neg-in95.7%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative95.7%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv95.7%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      10. div-inv95.7%

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub95.7%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt50.2%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      13. fabs-sqr50.2%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt51.3%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/53.3%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div53.3%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr53.3%

      \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    7. Taylor expanded in x around 0 36.0%

      \[\leadsto \color{blue}{\frac{4}{y}} \]

    if 4 < x

    1. Initial program 88.3%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub88.3%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/81.2%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/88.3%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def94.1%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified94.1%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine88.3%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
      2. associate-*r/81.2%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
      3. associate-*l/88.3%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
      4. div-inv88.1%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
      5. sub-neg88.1%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval88.1%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y}\right| \]
      7. distribute-neg-in88.1%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative88.1%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv88.1%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      10. div-inv88.3%

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub88.3%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt57.2%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      13. fabs-sqr57.2%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt57.9%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/54.3%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div62.0%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr62.0%

      \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    7. Taylor expanded in x around inf 61.3%

      \[\leadsto \frac{\color{blue}{x} - x \cdot z}{y} \]
    8. Taylor expanded in z around 0 34.5%

      \[\leadsto \frac{\color{blue}{x}}{y} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 13: 35.6% accurate, 11.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{-4 - x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -4.0) (/ (- -4.0 x) y) (/ (+ x 4.0) y)))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = (-4.0 - x) / y;
	} else {
		tmp = (x + 4.0) / y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-4.0d0)) then
        tmp = ((-4.0d0) - x) / y
    else
        tmp = (x + 4.0d0) / y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = (-4.0 - x) / y;
	} else {
		tmp = (x + 4.0) / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -4.0:
		tmp = (-4.0 - x) / y
	else:
		tmp = (x + 4.0) / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -4.0)
		tmp = Float64(Float64(-4.0 - x) / y);
	else
		tmp = Float64(Float64(x + 4.0) / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -4.0)
		tmp = (-4.0 - x) / y;
	else
		tmp = (x + 4.0) / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -4.0], N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision], N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;\frac{-4 - x}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + 4}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4

    1. Initial program 81.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub81.0%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/71.9%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/86.9%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def94.1%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified94.1%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt53.4%

        \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
      2. fabs-sqr53.4%

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
      3. add-sqr-sqrt53.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      4. fma-undefine48.0%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      5. associate-*r/39.7%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      6. associate-*l/45.1%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      7. div-inv45.1%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}} \]
      8. sub-neg45.1%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y} \]
      9. metadata-eval45.1%

        \[\leadsto \frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y} \]
      10. distribute-neg-in45.1%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y} \]
      11. +-commutative45.1%

        \[\leadsto \frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y} \]
      12. cancel-sign-sub-inv45.1%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}} \]
      13. div-inv45.1%

        \[\leadsto \frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}} \]
      14. associate-*l/39.7%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
      15. sub-div47.0%

        \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
    6. Applied egg-rr47.0%

      \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
    7. Taylor expanded in z around 0 35.1%

      \[\leadsto \color{blue}{-1 \cdot \frac{4 + x}{y}} \]
    8. Step-by-step derivation
      1. associate-*r/35.1%

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(4 + x\right)}{y}} \]
      2. distribute-lft-in35.1%

        \[\leadsto \frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y} \]
      3. metadata-eval35.1%

        \[\leadsto \frac{\color{blue}{-4} + -1 \cdot x}{y} \]
      4. neg-mul-135.1%

        \[\leadsto \frac{-4 + \color{blue}{\left(-x\right)}}{y} \]
      5. sub-neg35.1%

        \[\leadsto \frac{\color{blue}{-4 - x}}{y} \]
    9. Simplified35.1%

      \[\leadsto \color{blue}{\frac{-4 - x}{y}} \]

    if -4 < x

    1. Initial program 93.6%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub93.6%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/94.7%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/87.3%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def88.9%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac88.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative88.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in88.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg88.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval88.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified88.9%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine87.3%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
      2. associate-*r/94.7%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
      3. associate-*l/93.6%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
      4. div-inv93.6%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
      5. sub-neg93.6%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval93.6%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y}\right| \]
      7. distribute-neg-in93.6%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative93.6%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv93.6%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      10. div-inv93.6%

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub93.6%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt52.2%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      13. fabs-sqr52.2%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt53.1%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/53.6%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div55.7%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr55.7%

      \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    7. Taylor expanded in z around 0 36.0%

      \[\leadsto \color{blue}{\frac{4 + x}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification35.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{-4 - x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 35.4% accurate, 11.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -4.0) (/ (- x) y) (/ (+ x 4.0) y)))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = -x / y;
	} else {
		tmp = (x + 4.0) / y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-4.0d0)) then
        tmp = -x / y
    else
        tmp = (x + 4.0d0) / y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = -x / y;
	} else {
		tmp = (x + 4.0) / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -4.0:
		tmp = -x / y
	else:
		tmp = (x + 4.0) / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -4.0)
		tmp = Float64(Float64(-x) / y);
	else
		tmp = Float64(Float64(x + 4.0) / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -4.0)
		tmp = -x / y;
	else
		tmp = (x + 4.0) / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -4.0], N[((-x) / y), $MachinePrecision], N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;\frac{-x}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + 4}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4

    1. Initial program 81.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub81.0%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/71.9%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/86.9%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def94.1%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified94.1%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt53.4%

        \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
      2. fabs-sqr53.4%

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
      3. add-sqr-sqrt53.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      4. fma-undefine48.0%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      5. associate-*r/39.7%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      6. associate-*l/45.1%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      7. div-inv45.1%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}} \]
      8. sub-neg45.1%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y} \]
      9. metadata-eval45.1%

        \[\leadsto \frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y} \]
      10. distribute-neg-in45.1%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y} \]
      11. +-commutative45.1%

        \[\leadsto \frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y} \]
      12. cancel-sign-sub-inv45.1%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}} \]
      13. div-inv45.1%

        \[\leadsto \frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}} \]
      14. associate-*l/39.7%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
      15. sub-div47.0%

        \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
    6. Applied egg-rr47.0%

      \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
    7. Taylor expanded in x around inf 47.0%

      \[\leadsto \color{blue}{\frac{x \cdot \left(z - 1\right)}{y}} \]
    8. Step-by-step derivation
      1. associate-/l*55.2%

        \[\leadsto \color{blue}{x \cdot \frac{z - 1}{y}} \]
      2. sub-neg55.2%

        \[\leadsto x \cdot \frac{\color{blue}{z + \left(-1\right)}}{y} \]
      3. metadata-eval55.2%

        \[\leadsto x \cdot \frac{z + \color{blue}{-1}}{y} \]
    9. Simplified55.2%

      \[\leadsto \color{blue}{x \cdot \frac{z + -1}{y}} \]
    10. Taylor expanded in z around 0 35.1%

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{y}} \]
    11. Step-by-step derivation
      1. mul-1-neg35.1%

        \[\leadsto \color{blue}{-\frac{x}{y}} \]
      2. distribute-frac-neg35.1%

        \[\leadsto \color{blue}{\frac{-x}{y}} \]
    12. Simplified35.1%

      \[\leadsto \color{blue}{\frac{-x}{y}} \]

    if -4 < x

    1. Initial program 93.6%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub93.6%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/94.7%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/87.3%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def88.9%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac88.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative88.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in88.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg88.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval88.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified88.9%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine87.3%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
      2. associate-*r/94.7%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
      3. associate-*l/93.6%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
      4. div-inv93.6%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
      5. sub-neg93.6%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval93.6%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y}\right| \]
      7. distribute-neg-in93.6%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative93.6%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv93.6%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      10. div-inv93.6%

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub93.6%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt52.2%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      13. fabs-sqr52.2%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt53.1%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/53.6%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div55.7%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr55.7%

      \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    7. Taylor expanded in z around 0 36.0%

      \[\leadsto \color{blue}{\frac{4 + x}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification35.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 27.8% accurate, 13.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 4:\\ \;\;\;\;\frac{4}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
(FPCore (x y z) :precision binary64 (if (<= x 4.0) (/ 4.0 y) (/ x y)))
double code(double x, double y, double z) {
	double tmp;
	if (x <= 4.0) {
		tmp = 4.0 / y;
	} else {
		tmp = x / y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 4.0d0) then
        tmp = 4.0d0 / y
    else
        tmp = x / y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= 4.0) {
		tmp = 4.0 / y;
	} else {
		tmp = x / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= 4.0:
		tmp = 4.0 / y
	else:
		tmp = x / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= 4.0)
		tmp = Float64(4.0 / y);
	else
		tmp = Float64(x / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= 4.0)
		tmp = 4.0 / y;
	else
		tmp = x / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, 4.0], N[(4.0 / y), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 4:\\
\;\;\;\;\frac{4}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 4

    1. Initial program 90.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub90.7%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/90.4%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/86.9%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def89.3%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac89.3%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative89.3%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in89.3%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg89.3%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval89.3%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified89.3%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine86.9%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
      2. associate-*r/90.4%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
      3. associate-*l/90.7%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
      4. div-inv90.7%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
      5. sub-neg90.7%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval90.7%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y}\right| \]
      7. distribute-neg-in90.7%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative90.7%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv90.7%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      10. div-inv90.7%

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub90.7%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt45.4%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      13. fabs-sqr45.4%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt46.3%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/46.3%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div48.3%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr48.3%

      \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    7. Taylor expanded in x around 0 25.0%

      \[\leadsto \color{blue}{\frac{4}{y}} \]

    if 4 < x

    1. Initial program 88.3%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub88.3%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/81.2%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/88.3%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def94.1%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval94.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified94.1%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine88.3%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
      2. associate-*r/81.2%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
      3. associate-*l/88.3%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
      4. div-inv88.1%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
      5. sub-neg88.1%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval88.1%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y}\right| \]
      7. distribute-neg-in88.1%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative88.1%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv88.1%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      10. div-inv88.3%

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub88.3%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt57.2%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      13. fabs-sqr57.2%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt57.9%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/54.3%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div62.0%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr62.0%

      \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    7. Taylor expanded in x around inf 61.3%

      \[\leadsto \frac{\color{blue}{x} - x \cdot z}{y} \]
    8. Taylor expanded in z around 0 34.5%

      \[\leadsto \frac{\color{blue}{x}}{y} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 16: 20.9% accurate, 37.0× speedup?

\[\begin{array}{l} \\ \frac{4}{y} \end{array} \]
(FPCore (x y z) :precision binary64 (/ 4.0 y))
double code(double x, double y, double z) {
	return 4.0 / y;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = 4.0d0 / y
end function
public static double code(double x, double y, double z) {
	return 4.0 / y;
}
def code(x, y, z):
	return 4.0 / y
function code(x, y, z)
	return Float64(4.0 / y)
end
function tmp = code(x, y, z)
	tmp = 4.0 / y;
end
code[x_, y_, z_] := N[(4.0 / y), $MachinePrecision]
\begin{array}{l}

\\
\frac{4}{y}
\end{array}
Derivation
  1. Initial program 90.2%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Step-by-step derivation
    1. fabs-sub90.2%

      \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
    2. associate-*l/88.5%

      \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
    3. associate-*r/87.2%

      \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
    4. fmm-def90.3%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
    5. distribute-neg-frac90.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
    6. +-commutative90.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
    7. distribute-neg-in90.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
    8. unsub-neg90.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
    9. metadata-eval90.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
  3. Simplified90.3%

    \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. fma-undefine87.2%

      \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
    2. associate-*r/88.5%

      \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
    3. associate-*l/90.2%

      \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
    4. div-inv90.2%

      \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
    5. sub-neg90.2%

      \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
    6. metadata-eval90.2%

      \[\leadsto \left|\frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y}\right| \]
    7. distribute-neg-in90.2%

      \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
    8. +-commutative90.2%

      \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
    9. cancel-sign-sub-inv90.2%

      \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
    10. div-inv90.2%

      \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
    11. fabs-sub90.2%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
    12. add-sqr-sqrt47.8%

      \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
    13. fabs-sqr47.8%

      \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
    14. add-sqr-sqrt48.6%

      \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
    15. associate-*l/48.0%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
    16. sub-div51.1%

      \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
  6. Applied egg-rr51.1%

    \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
  7. Taylor expanded in x around 0 20.6%

    \[\leadsto \color{blue}{\frac{4}{y}} \]
  8. Add Preprocessing

Alternative 17: 21.1% accurate, 37.0× speedup?

\[\begin{array}{l} \\ \frac{-4}{y} \end{array} \]
(FPCore (x y z) :precision binary64 (/ -4.0 y))
double code(double x, double y, double z) {
	return -4.0 / y;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (-4.0d0) / y
end function
public static double code(double x, double y, double z) {
	return -4.0 / y;
}
def code(x, y, z):
	return -4.0 / y
function code(x, y, z)
	return Float64(-4.0 / y)
end
function tmp = code(x, y, z)
	tmp = -4.0 / y;
end
code[x_, y_, z_] := N[(-4.0 / y), $MachinePrecision]
\begin{array}{l}

\\
\frac{-4}{y}
\end{array}
Derivation
  1. Initial program 90.2%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Step-by-step derivation
    1. fabs-sub90.2%

      \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
    2. associate-*l/88.5%

      \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
    3. associate-*r/87.2%

      \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
    4. fmm-def90.3%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
    5. distribute-neg-frac90.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
    6. +-commutative90.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
    7. distribute-neg-in90.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
    8. unsub-neg90.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
    9. metadata-eval90.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
  3. Simplified90.3%

    \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. add-sqr-sqrt43.8%

      \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
    2. fabs-sqr43.8%

      \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
    3. add-sqr-sqrt44.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
    4. fma-undefine41.9%

      \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
    5. associate-*r/41.8%

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
    6. associate-*l/42.9%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
    7. div-inv42.8%

      \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}} \]
    8. sub-neg42.8%

      \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y} \]
    9. metadata-eval42.8%

      \[\leadsto \frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y} \]
    10. distribute-neg-in42.8%

      \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y} \]
    11. +-commutative42.8%

      \[\leadsto \frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y} \]
    12. cancel-sign-sub-inv42.8%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}} \]
    13. div-inv42.9%

      \[\leadsto \frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}} \]
    14. associate-*l/41.8%

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
    15. sub-div44.5%

      \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
  6. Applied egg-rr44.5%

    \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
  7. Taylor expanded in x around 0 19.8%

    \[\leadsto \color{blue}{\frac{-4}{y}} \]
  8. Add Preprocessing

Reproduce

?
herbie shell --seed 2024157 
(FPCore (x y z)
  :name "fabs fraction 1"
  :precision binary64
  (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))