fabs fraction 1

Percentage Accurate: 91.4% → 99.8%
Time: 11.4s
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.4% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 88.5%

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

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

    if 4.9999999999999998e-8 < y

    1. Initial program 94.3%

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

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

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

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

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

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

Alternative 2: 95.5% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 95.8%

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

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

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

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

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

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

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

    1. Initial program 72.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left|\frac{-1}{y} \cdot \color{blue}{\left(x \cdot \left(\left(-1 + z\right) - \frac{4}{x}\right)\right)}\right| \]
    7. Step-by-step derivation
      1. add-sqr-sqrt77.4%

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

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

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

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

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

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

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

Alternative 3: 94.5% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 96.3%

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

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

    1. Initial program 51.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.8% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 88.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.2999999999999999e-25 < y

    1. Initial program 94.5%

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

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

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

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

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

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

Alternative 5: 78.7% accurate, 6.5× speedup?

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

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

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

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


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

    1. Initial program 88.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt50.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-sqr50.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-sqrt51.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.6000000000000001 < x < 5.3000000000000001e-5

    1. Initial program 93.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.3000000000000001e-5 < x

    1. Initial program 87.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 78.4% accurate, 6.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -110:\\
\;\;\;\;\frac{x \cdot \left(-1 + z\right)}{y\_m}\\

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

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


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

    1. Initial program 88.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt50.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-sqr50.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-sqrt51.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -110 < x < 5.3000000000000001e-5

    1. Initial program 93.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.3000000000000001e-5 < x

    1. Initial program 87.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 73.5% accurate, 6.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.85:\\
\;\;\;\;\frac{x \cdot \left(-1 + z\right)}{y\_m}\\

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

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


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

    1. Initial program 88.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt50.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-sqr50.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-sqrt51.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.85000000000000009 < x < 6.2e6

    1. Initial program 93.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}} \]
    8. Step-by-step derivation
      1. remove-double-neg41.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{4 + x}}} \]
      2. inv-pow41.8%

        \[\leadsto \color{blue}{{\left(\frac{y}{4 + x}\right)}^{-1}} \]
      3. +-commutative41.8%

        \[\leadsto {\left(\frac{y}{\color{blue}{x + 4}}\right)}^{-1} \]
    11. Applied egg-rr41.8%

      \[\leadsto \color{blue}{{\left(\frac{y}{x + 4}\right)}^{-1}} \]
    12. Step-by-step derivation
      1. unpow-141.8%

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

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

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

    if 6.2e6 < x

    1. Initial program 87.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 74.6% accurate, 6.5× speedup?

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

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

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

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


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

    1. Initial program 88.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt50.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-sqr50.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-sqrt51.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4 < x < 8.1e6

    1. Initial program 93.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}} \]
    8. Step-by-step derivation
      1. remove-double-neg41.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{4 + x}}} \]
      2. inv-pow41.8%

        \[\leadsto \color{blue}{{\left(\frac{y}{4 + x}\right)}^{-1}} \]
      3. +-commutative41.8%

        \[\leadsto {\left(\frac{y}{\color{blue}{x + 4}}\right)}^{-1} \]
    11. Applied egg-rr41.8%

      \[\leadsto \color{blue}{{\left(\frac{y}{x + 4}\right)}^{-1}} \]
    12. Step-by-step derivation
      1. unpow-141.8%

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

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

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

    if 8.1e6 < x

    1. Initial program 87.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 77.1% accurate, 6.9× speedup?

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

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

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


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

    1. Initial program 88.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt50.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-sqr50.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-sqrt51.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.5 < x

    1. Initial program 90.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 79.4% accurate, 7.9× speedup?

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

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

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


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

    1. Initial program 88.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt50.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-sqr50.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-sqrt51.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4 < x

    1. Initial program 90.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 69.5% accurate, 8.5× speedup?

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

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

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

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


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

    1. Initial program 88.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt50.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-sqr50.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-sqrt51.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-x}}{y} \]
    10. Simplified35.3%

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

    if -10.5 < x < 4

    1. Initial program 93.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4 < x

    1. Initial program 87.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}} \]
    8. Step-by-step derivation
      1. remove-double-neg26.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 73.1% accurate, 9.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.4:\\
\;\;\;\;\left(-1 + z\right) \cdot \frac{x}{y\_m}\\

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


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

    1. Initial program 88.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt50.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-sqr50.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-sqrt51.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.39999999999999991 < x

    1. Initial program 90.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}} \]
    8. Step-by-step derivation
      1. remove-double-neg36.1%

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

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

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

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

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

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

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

        \[\leadsto 4 \cdot \frac{1}{y} + x \cdot \frac{\color{blue}{1}}{y} \]
      9. distribute-rgt-in36.0%

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

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

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

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

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

Alternative 13: 70.5% accurate, 11.1× speedup?

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

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

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


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

    1. Initial program 88.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt50.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-sqr50.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-sqrt51.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{4 + x}{y}} \]
    8. Step-by-step derivation
      1. neg-mul-135.4%

        \[\leadsto \color{blue}{-\frac{4 + x}{y}} \]
      2. distribute-neg-frac35.4%

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

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

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

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

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

    if -4 < x

    1. Initial program 90.9%

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

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg96.3%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval96.3%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified96.3%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine95.3%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
      2. associate-*r/92.8%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
      3. associate-*l/90.9%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
      4. div-inv90.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
      5. sub-neg90.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval90.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y}\right| \]
      7. distribute-neg-in90.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative90.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv90.8%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      10. div-inv90.9%

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub90.9%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt44.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-sqr44.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-sqrt45.9%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. sub-neg45.9%

        \[\leadsto \color{blue}{\frac{x + 4}{y} + \left(-\frac{x}{y} \cdot z\right)} \]
      16. distribute-rgt-neg-in45.9%

        \[\leadsto \frac{x + 4}{y} + \color{blue}{\frac{x}{y} \cdot \left(-z\right)} \]
    6. Applied egg-rr45.9%

      \[\leadsto \color{blue}{\frac{x + 4}{y} + \frac{x}{y} \cdot \left(-z\right)} \]
    7. Taylor expanded in z around 0 36.1%

      \[\leadsto \color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}} \]
    8. Step-by-step derivation
      1. remove-double-neg36.1%

        \[\leadsto 4 \cdot \frac{1}{y} + \color{blue}{\left(-\left(-\frac{x}{y}\right)\right)} \]
      2. distribute-neg-frac36.1%

        \[\leadsto 4 \cdot \frac{1}{y} + \left(-\color{blue}{\frac{-x}{y}}\right) \]
      3. neg-mul-136.1%

        \[\leadsto 4 \cdot \frac{1}{y} + \left(-\frac{\color{blue}{-1 \cdot x}}{y}\right) \]
      4. associate-*l/36.0%

        \[\leadsto 4 \cdot \frac{1}{y} + \left(-\color{blue}{\frac{-1}{y} \cdot x}\right) \]
      5. *-commutative36.0%

        \[\leadsto 4 \cdot \frac{1}{y} + \left(-\color{blue}{x \cdot \frac{-1}{y}}\right) \]
      6. distribute-rgt-neg-in36.0%

        \[\leadsto 4 \cdot \frac{1}{y} + \color{blue}{x \cdot \left(-\frac{-1}{y}\right)} \]
      7. distribute-neg-frac36.0%

        \[\leadsto 4 \cdot \frac{1}{y} + x \cdot \color{blue}{\frac{--1}{y}} \]
      8. metadata-eval36.0%

        \[\leadsto 4 \cdot \frac{1}{y} + x \cdot \frac{\color{blue}{1}}{y} \]
      9. distribute-rgt-in36.0%

        \[\leadsto \color{blue}{\frac{1}{y} \cdot \left(4 + x\right)} \]
      10. associate-*l/36.1%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(4 + x\right)}{y}} \]
      11. *-lft-identity36.1%

        \[\leadsto \frac{\color{blue}{4 + x}}{y} \]
    9. Simplified36.1%

      \[\leadsto \color{blue}{\frac{4 + x}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification35.9%

    \[\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: 70.2% accurate, 11.1× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{x}{-y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x -4.0) (/ x (- y_m)) (/ (+ x 4.0) y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = x / -y_m;
	} else {
		tmp = (x + 4.0) / y_m;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-4.0d0)) then
        tmp = x / -y_m
    else
        tmp = (x + 4.0d0) / y_m
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = x / -y_m;
	} else {
		tmp = (x + 4.0) / y_m;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= -4.0:
		tmp = x / -y_m
	else:
		tmp = (x + 4.0) / y_m
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= -4.0)
		tmp = Float64(x / Float64(-y_m));
	else
		tmp = Float64(Float64(x + 4.0) / y_m);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= -4.0)
		tmp = x / -y_m;
	else
		tmp = (x + 4.0) / y_m;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, -4.0], N[(x / (-y$95$m)), $MachinePrecision], N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;\frac{x}{-y\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + 4}{y\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4

    1. Initial program 88.2%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub88.2%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/87.0%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/89.7%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def94.0%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac94.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative94.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in94.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg94.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval94.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified94.0%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt50.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-sqr50.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-sqrt51.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      4. fma-undefine51.0%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      5. associate-*r/49.7%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      6. associate-*l/49.5%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      7. div-inv49.4%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}} \]
      8. sub-neg49.4%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y} \]
      9. metadata-eval49.4%

        \[\leadsto \frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y} \]
      10. distribute-neg-in49.4%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y} \]
      11. +-commutative49.4%

        \[\leadsto \frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y} \]
      12. cancel-sign-sub-inv49.4%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}} \]
      13. div-inv49.5%

        \[\leadsto \frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}} \]
      14. associate-*l/49.7%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
      15. sub-div56.9%

        \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
    6. Applied egg-rr56.9%

      \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
    7. Taylor expanded in x around inf 56.7%

      \[\leadsto \frac{x \cdot z - \color{blue}{x}}{y} \]
    8. Taylor expanded in z around 0 35.3%

      \[\leadsto \frac{\color{blue}{-1 \cdot x}}{y} \]
    9. Step-by-step derivation
      1. neg-mul-135.3%

        \[\leadsto \frac{\color{blue}{-x}}{y} \]
    10. Simplified35.3%

      \[\leadsto \frac{\color{blue}{-x}}{y} \]

    if -4 < x

    1. Initial program 90.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub90.9%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/92.8%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/95.3%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def96.3%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac96.3%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative96.3%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in96.3%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg96.3%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval96.3%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified96.3%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine95.3%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
      2. associate-*r/92.8%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
      3. associate-*l/90.9%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
      4. div-inv90.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
      5. sub-neg90.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval90.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y}\right| \]
      7. distribute-neg-in90.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative90.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv90.8%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      10. div-inv90.9%

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub90.9%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt44.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-sqr44.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-sqrt45.9%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. sub-neg45.9%

        \[\leadsto \color{blue}{\frac{x + 4}{y} + \left(-\frac{x}{y} \cdot z\right)} \]
      16. distribute-rgt-neg-in45.9%

        \[\leadsto \frac{x + 4}{y} + \color{blue}{\frac{x}{y} \cdot \left(-z\right)} \]
    6. Applied egg-rr45.9%

      \[\leadsto \color{blue}{\frac{x + 4}{y} + \frac{x}{y} \cdot \left(-z\right)} \]
    7. Taylor expanded in z around 0 36.1%

      \[\leadsto \color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}} \]
    8. Step-by-step derivation
      1. remove-double-neg36.1%

        \[\leadsto 4 \cdot \frac{1}{y} + \color{blue}{\left(-\left(-\frac{x}{y}\right)\right)} \]
      2. distribute-neg-frac36.1%

        \[\leadsto 4 \cdot \frac{1}{y} + \left(-\color{blue}{\frac{-x}{y}}\right) \]
      3. neg-mul-136.1%

        \[\leadsto 4 \cdot \frac{1}{y} + \left(-\frac{\color{blue}{-1 \cdot x}}{y}\right) \]
      4. associate-*l/36.0%

        \[\leadsto 4 \cdot \frac{1}{y} + \left(-\color{blue}{\frac{-1}{y} \cdot x}\right) \]
      5. *-commutative36.0%

        \[\leadsto 4 \cdot \frac{1}{y} + \left(-\color{blue}{x \cdot \frac{-1}{y}}\right) \]
      6. distribute-rgt-neg-in36.0%

        \[\leadsto 4 \cdot \frac{1}{y} + \color{blue}{x \cdot \left(-\frac{-1}{y}\right)} \]
      7. distribute-neg-frac36.0%

        \[\leadsto 4 \cdot \frac{1}{y} + x \cdot \color{blue}{\frac{--1}{y}} \]
      8. metadata-eval36.0%

        \[\leadsto 4 \cdot \frac{1}{y} + x \cdot \frac{\color{blue}{1}}{y} \]
      9. distribute-rgt-in36.0%

        \[\leadsto \color{blue}{\frac{1}{y} \cdot \left(4 + x\right)} \]
      10. associate-*l/36.1%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(4 + x\right)}{y}} \]
      11. *-lft-identity36.1%

        \[\leadsto \frac{\color{blue}{4 + x}}{y} \]
    9. Simplified36.1%

      \[\leadsto \color{blue}{\frac{4 + x}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification35.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{x}{-y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 54.9% accurate, 13.8× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq 4:\\ \;\;\;\;\frac{4}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z) :precision binary64 (if (<= x 4.0) (/ 4.0 y_m) (/ x y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= 4.0) {
		tmp = 4.0 / y_m;
	} else {
		tmp = x / y_m;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 4.0d0) then
        tmp = 4.0d0 / y_m
    else
        tmp = x / y_m
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if (x <= 4.0) {
		tmp = 4.0 / y_m;
	} else {
		tmp = x / y_m;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= 4.0:
		tmp = 4.0 / y_m
	else:
		tmp = x / y_m
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= 4.0)
		tmp = Float64(4.0 / y_m);
	else
		tmp = Float64(x / y_m);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= 4.0)
		tmp = 4.0 / y_m;
	else
		tmp = x / y_m;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, 4.0], N[(4.0 / y$95$m), $MachinePrecision], N[(x / y$95$m), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq 4:\\
\;\;\;\;\frac{4}{y\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{y\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 4

    1. Initial program 91.2%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub91.2%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/95.0%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/93.6%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def95.2%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac95.2%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative95.2%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in95.2%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg95.2%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval95.2%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified95.2%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine93.6%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
      2. associate-*r/95.0%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
      3. associate-*l/91.2%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
      4. div-inv91.2%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
      5. sub-neg91.2%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval91.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-in91.2%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative91.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-inv91.2%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      10. div-inv91.2%

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub91.2%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt45.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-sqr45.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-sqrt46.2%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/48.6%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div49.7%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr49.7%

      \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    7. Taylor expanded in x around 0 27.1%

      \[\leadsto \color{blue}{\frac{4}{y}} \]

    if 4 < x

    1. Initial program 87.3%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub87.3%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/81.4%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/94.3%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def97.0%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac97.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative97.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in97.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg97.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval97.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified97.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-undefine94.3%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
      2. associate-*r/81.4%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
      3. associate-*l/87.3%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
      4. div-inv87.1%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
      5. sub-neg87.1%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval87.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-in87.1%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative87.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-inv87.1%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      10. div-inv87.3%

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub87.3%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt38.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-sqr38.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-sqrt39.1%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. sub-neg39.1%

        \[\leadsto \color{blue}{\frac{x + 4}{y} + \left(-\frac{x}{y} \cdot z\right)} \]
      16. distribute-rgt-neg-in39.1%

        \[\leadsto \frac{x + 4}{y} + \color{blue}{\frac{x}{y} \cdot \left(-z\right)} \]
    6. Applied egg-rr39.1%

      \[\leadsto \color{blue}{\frac{x + 4}{y} + \frac{x}{y} \cdot \left(-z\right)} \]
    7. Taylor expanded in z around 0 26.8%

      \[\leadsto \color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}} \]
    8. Step-by-step derivation
      1. remove-double-neg26.8%

        \[\leadsto 4 \cdot \frac{1}{y} + \color{blue}{\left(-\left(-\frac{x}{y}\right)\right)} \]
      2. distribute-neg-frac26.8%

        \[\leadsto 4 \cdot \frac{1}{y} + \left(-\color{blue}{\frac{-x}{y}}\right) \]
      3. neg-mul-126.8%

        \[\leadsto 4 \cdot \frac{1}{y} + \left(-\frac{\color{blue}{-1 \cdot x}}{y}\right) \]
      4. associate-*l/26.8%

        \[\leadsto 4 \cdot \frac{1}{y} + \left(-\color{blue}{\frac{-1}{y} \cdot x}\right) \]
      5. *-commutative26.8%

        \[\leadsto 4 \cdot \frac{1}{y} + \left(-\color{blue}{x \cdot \frac{-1}{y}}\right) \]
      6. distribute-rgt-neg-in26.8%

        \[\leadsto 4 \cdot \frac{1}{y} + \color{blue}{x \cdot \left(-\frac{-1}{y}\right)} \]
      7. distribute-neg-frac26.8%

        \[\leadsto 4 \cdot \frac{1}{y} + x \cdot \color{blue}{\frac{--1}{y}} \]
      8. metadata-eval26.8%

        \[\leadsto 4 \cdot \frac{1}{y} + x \cdot \frac{\color{blue}{1}}{y} \]
      9. distribute-rgt-in26.8%

        \[\leadsto \color{blue}{\frac{1}{y} \cdot \left(4 + x\right)} \]
      10. associate-*l/26.8%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(4 + x\right)}{y}} \]
      11. *-lft-identity26.8%

        \[\leadsto \frac{\color{blue}{4 + x}}{y} \]
    9. Simplified26.8%

      \[\leadsto \color{blue}{\frac{4 + x}{y}} \]
    10. Taylor expanded in x around inf 26.8%

      \[\leadsto \color{blue}{\frac{x}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 16: 40.6% accurate, 37.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \frac{4}{y\_m} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z) :precision binary64 (/ 4.0 y_m))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	return 4.0 / y_m;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    code = 4.0d0 / y_m
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	return 4.0 / y_m;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	return 4.0 / y_m
y_m = abs(y)
function code(x, y_m, z)
	return Float64(4.0 / y_m)
end
y_m = abs(y);
function tmp = code(x, y_m, z)
	tmp = 4.0 / y_m;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := N[(4.0 / y$95$m), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|

\\
\frac{4}{y\_m}
\end{array}
Derivation
  1. Initial program 90.1%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Step-by-step derivation
    1. fabs-sub90.1%

      \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
    2. associate-*l/91.2%

      \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
    3. associate-*r/93.8%

      \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
    4. fmm-def95.7%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
    5. distribute-neg-frac95.7%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
    6. +-commutative95.7%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
    7. distribute-neg-in95.7%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
    8. unsub-neg95.7%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
    9. metadata-eval95.7%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
  3. Simplified95.7%

    \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. fma-undefine93.8%

      \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
    2. associate-*r/91.2%

      \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
    3. associate-*l/90.1%

      \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
    4. div-inv90.0%

      \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
    5. sub-neg90.0%

      \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
    6. metadata-eval90.0%

      \[\leadsto \left|\frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y}\right| \]
    7. distribute-neg-in90.0%

      \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
    8. +-commutative90.0%

      \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
    9. cancel-sign-sub-inv90.0%

      \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
    10. div-inv90.1%

      \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
    11. fabs-sub90.1%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
    12. add-sqr-sqrt43.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-sqr43.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-sqrt44.2%

      \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
    15. associate-*l/46.4%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
    16. sub-div47.6%

      \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
  6. Applied egg-rr47.6%

    \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
  7. Taylor expanded in x around 0 20.3%

    \[\leadsto \color{blue}{\frac{4}{y}} \]
  8. Add Preprocessing

Alternative 17: 1.7% accurate, 37.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \frac{-4}{y\_m} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z) :precision binary64 (/ -4.0 y_m))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	return -4.0 / y_m;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    code = (-4.0d0) / y_m
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	return -4.0 / y_m;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	return -4.0 / y_m
y_m = abs(y)
function code(x, y_m, z)
	return Float64(-4.0 / y_m)
end
y_m = abs(y);
function tmp = code(x, y_m, z)
	tmp = -4.0 / y_m;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := N[(-4.0 / y$95$m), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|

\\
\frac{-4}{y\_m}
\end{array}
Derivation
  1. Initial program 90.1%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Step-by-step derivation
    1. fabs-sub90.1%

      \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
    2. associate-*l/91.2%

      \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
    3. associate-*r/93.8%

      \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
    4. fmm-def95.7%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
    5. distribute-neg-frac95.7%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
    6. +-commutative95.7%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
    7. distribute-neg-in95.7%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
    8. unsub-neg95.7%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
    9. metadata-eval95.7%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
  3. Simplified95.7%

    \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. add-sqr-sqrt47.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-sqr47.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-sqrt48.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
    4. fma-undefine48.4%

      \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
    5. associate-*r/46.2%

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
    6. associate-*l/47.4%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
    7. div-inv47.3%

      \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}} \]
    8. sub-neg47.3%

      \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y} \]
    9. metadata-eval47.3%

      \[\leadsto \frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y} \]
    10. distribute-neg-in47.3%

      \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y} \]
    11. +-commutative47.3%

      \[\leadsto \frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y} \]
    12. cancel-sign-sub-inv47.3%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}} \]
    13. div-inv47.4%

      \[\leadsto \frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}} \]
    14. associate-*l/46.2%

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
    15. sub-div49.3%

      \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
  6. Applied egg-rr49.3%

    \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
  7. Taylor expanded in x around 0 18.1%

    \[\leadsto \color{blue}{\frac{-4}{y}} \]
  8. Add Preprocessing

Reproduce

?
herbie shell --seed 2024186 
(FPCore (x y z)
  :name "fabs fraction 1"
  :precision binary64
  (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))