fabs fraction 1

Percentage Accurate: 91.7% → 99.9%
Time: 16.0s
Alternatives: 19
Speedup: 2.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 19 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.7% 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.9% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 87.9%

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

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

    if 2e-3 < y

    1. Initial program 94.2%

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.6% accurate, 0.3× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \frac{x + 4}{y\_m}\\ t_1 := \left|t\_0 - z \cdot \frac{x}{y\_m}\right|\\ \mathbf{if}\;t\_1 \leq 2 \cdot 10^{+30}:\\ \;\;\;\;\left|t\_0 - \frac{x \cdot z}{y\_m}\right|\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+296}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{-1}{y\_m} \cdot \mathsf{fma}\left(x, z, -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)) (t_1 (fabs (- t_0 (* z (/ x y_m))))))
   (if (<= t_1 2e+30)
     (fabs (- t_0 (/ (* x z) y_m)))
     (if (<= t_1 2e+296) t_1 (fabs (* (/ -1.0 y_m) (fma x 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 t_1 = fabs((t_0 - (z * (x / y_m))));
	double tmp;
	if (t_1 <= 2e+30) {
		tmp = fabs((t_0 - ((x * z) / y_m)));
	} else if (t_1 <= 2e+296) {
		tmp = t_1;
	} else {
		tmp = fabs(((-1.0 / y_m) * fma(x, 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)
	t_1 = abs(Float64(t_0 - Float64(z * Float64(x / y_m))))
	tmp = 0.0
	if (t_1 <= 2e+30)
		tmp = abs(Float64(t_0 - Float64(Float64(x * z) / y_m)));
	elseif (t_1 <= 2e+296)
		tmp = t_1;
	else
		tmp = abs(Float64(Float64(-1.0 / y_m) * fma(x, z, Float64(-4.0 - x))));
	end
	return tmp
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(t$95$0 - N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, 2e+30], N[Abs[N[(t$95$0 - N[(N[(x * z), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, 2e+296], t$95$1, N[Abs[N[(N[(-1.0 / y$95$m), $MachinePrecision] * N[(x * 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}\\
t_1 := \left|t\_0 - z \cdot \frac{x}{y\_m}\right|\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{+30}:\\
\;\;\;\;\left|t\_0 - \frac{x \cdot z}{y\_m}\right|\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+296}:\\
\;\;\;\;t\_1\\

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


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

    1. Initial program 92.3%

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

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

    if 2e30 < (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))) < 1.99999999999999996e296

    1. Initial program 99.9%

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

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

    1. Initial program 66.7%

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

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

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

Alternative 3: 99.7% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+306}:\\
\;\;\;\;t\_2\\

\mathbf{else}:\\
\;\;\;\;\left|t\_1\right|\\


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

    1. Initial program 92.3%

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

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

    if 2e30 < (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))) < 2.00000000000000003e306

    1. Initial program 99.9%

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

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

    1. Initial program 64.8%

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

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

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

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

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

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

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

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

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

Alternative 4: 97.9% accurate, 0.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\left|t\_0\right|\\


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

    1. Initial program 96.4%

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

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

    1. Initial program 64.8%

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

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

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

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

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

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

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

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

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

Alternative 5: 97.6% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;t\_2 \leq 10^{-33}:\\
\;\;\;\;t\_0 - \frac{x}{\frac{y\_m}{z}}\\

\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+306}:\\
\;\;\;\;t\_2\\

\mathbf{else}:\\
\;\;\;\;\left|t\_1\right|\\


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.9999999999999999e-223 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) < 1.0000000000000001e-33

    1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

    if 1.0000000000000001e-33 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) < 2.00000000000000003e306

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 47.2%

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

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

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

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

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

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

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

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

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

Alternative 6: 97.8% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;t\_1 \leq 10^{-33}:\\
\;\;\;\;t\_0 - \frac{x}{\frac{y\_m}{z}}\\

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.9999999999999999e-223 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) < 1.0000000000000001e-33

    1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 94.5% accurate, 2.0× speedup?

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

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

\mathbf{elif}\;t\_1 \leq 10^{-33}:\\
\;\;\;\;t\_0 - \frac{x}{\frac{y\_m}{z}}\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+306}:\\
\;\;\;\;t\_1\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.9999999999999999e-223 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) < 1.0000000000000001e-33

    1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

    if 1.0000000000000001e-33 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) < 2.00000000000000003e306

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 47.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-x \cdot \frac{z}{y}} \]
      2. *-un-lft-identity59.6%

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

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

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

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

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

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

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

Alternative 8: 94.4% accurate, 2.0× speedup?

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

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

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-89}:\\
\;\;\;\;\frac{\left(x + 4\right) - x \cdot z}{y\_m}\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+306}:\\
\;\;\;\;t\_1\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.9999999999999999e-223 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) < 4.99999999999999967e-89

    1. Initial program 83.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999967e-89 < (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)) < 2.00000000000000003e306

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 47.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-x \cdot \frac{z}{y}} \]
      2. *-un-lft-identity59.6%

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

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

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

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

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

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

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

Alternative 9: 66.8% accurate, 4.4× speedup?

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

\\
\begin{array}{l}
t_0 := x \cdot \frac{z}{y\_m}\\
\mathbf{if}\;x \leq -1.45 \cdot 10^{+64}:\\
\;\;\;\;\frac{-x}{y\_m}\\

\mathbf{elif}\;x \leq -6.4 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;x \leq 1.9 \cdot 10^{+45}:\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 74.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.44999999999999997e64 < x < -6.3999999999999997e-6 or 3.59999999999999983e-16 < x < 1.9000000000000001e45

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{z}{y}} \]
    9. Simplified30.3%

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

    if -6.3999999999999997e-6 < x < 3.59999999999999983e-16

    1. Initial program 94.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.9000000000000001e45 < x

    1. Initial program 88.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
      20. clear-num35.1%

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

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

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

Alternative 10: 77.6% accurate, 4.6× speedup?

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

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

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

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

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


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

    1. Initial program 37.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - \color{blue}{x \cdot \frac{z}{y}} \]
    7. Simplified39.3%

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

        \[\leadsto \color{blue}{-x \cdot \frac{z}{y}} \]
      2. *-un-lft-identity39.3%

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

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

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

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

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

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

    if -4.49999999999999964e255 < x < -2.6999999999999999e-5

    1. Initial program 86.9%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot z - x}{y} - \frac{4}{y}} \]
      8. *-commutative50.6%

        \[\leadsto \frac{\color{blue}{z \cdot x} - x}{y} - \frac{4}{y} \]
      9. *-un-lft-identity50.6%

        \[\leadsto \frac{z \cdot x - \color{blue}{1 \cdot x}}{y} - \frac{4}{y} \]
      10. distribute-rgt-out--50.6%

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

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

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

    if -2.6999999999999999e-5 < x < 8e153

    1. Initial program 93.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8e153 < x

    1. Initial program 87.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 77.2% accurate, 4.6× speedup?

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

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

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

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


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

    1. Initial program 37.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - \color{blue}{x \cdot \frac{z}{y}} \]
    7. Simplified39.3%

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

        \[\leadsto \color{blue}{-x \cdot \frac{z}{y}} \]
      2. *-un-lft-identity39.3%

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

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

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

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

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

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

    if -1.5999999999999999e255 < x < -5.59999999999999975e-6

    1. Initial program 86.9%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot z - x}{y} - \frac{4}{y}} \]
      8. *-commutative50.6%

        \[\leadsto \frac{\color{blue}{z \cdot x} - x}{y} - \frac{4}{y} \]
      9. *-un-lft-identity50.6%

        \[\leadsto \frac{z \cdot x - \color{blue}{1 \cdot x}}{y} - \frac{4}{y} \]
      10. distribute-rgt-out--50.6%

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

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

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

    if -5.59999999999999975e-6 < x < 4

    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. add-sqr-sqrt48.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4 < x

    1. Initial program 89.3%

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

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

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

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

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

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

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

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

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

Alternative 12: 77.0% accurate, 4.6× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -4.2 \cdot 10^{+255}:\\ \;\;\;\;z \cdot \frac{-x}{y\_m}\\ \mathbf{elif}\;x \leq -2.7 \cdot 10^{-5}:\\ \;\;\;\;\frac{x \cdot \left(-1 + z\right)}{y\_m}\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\frac{4 - x \cdot z}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{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 -4.2e+255)
   (* z (/ (- x) y_m))
   (if (<= x -2.7e-5)
     (/ (* x (+ -1.0 z)) y_m)
     (if (<= x 4.0) (/ (- 4.0 (* x z)) y_m) (- (/ x y_m) (* x (/ z y_m)))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -4.2e+255) {
		tmp = z * (-x / y_m);
	} else if (x <= -2.7e-5) {
		tmp = (x * (-1.0 + z)) / y_m;
	} else if (x <= 4.0) {
		tmp = (4.0 - (x * z)) / y_m;
	} else {
		tmp = (x / 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 <= (-4.2d+255)) then
        tmp = z * (-x / y_m)
    else if (x <= (-2.7d-5)) then
        tmp = (x * ((-1.0d0) + z)) / y_m
    else if (x <= 4.0d0) then
        tmp = (4.0d0 - (x * z)) / y_m
    else
        tmp = (x / 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 <= -4.2e+255) {
		tmp = z * (-x / y_m);
	} else if (x <= -2.7e-5) {
		tmp = (x * (-1.0 + z)) / y_m;
	} else if (x <= 4.0) {
		tmp = (4.0 - (x * z)) / y_m;
	} else {
		tmp = (x / y_m) - (x * (z / y_m));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= -4.2e+255:
		tmp = z * (-x / y_m)
	elif x <= -2.7e-5:
		tmp = (x * (-1.0 + z)) / y_m
	elif x <= 4.0:
		tmp = (4.0 - (x * z)) / y_m
	else:
		tmp = (x / y_m) - (x * (z / y_m))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= -4.2e+255)
		tmp = Float64(z * Float64(Float64(-x) / y_m));
	elseif (x <= -2.7e-5)
		tmp = Float64(Float64(x * Float64(-1.0 + z)) / y_m);
	elseif (x <= 4.0)
		tmp = Float64(Float64(4.0 - Float64(x * z)) / y_m);
	else
		tmp = Float64(Float64(x / 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 <= -4.2e+255)
		tmp = z * (-x / y_m);
	elseif (x <= -2.7e-5)
		tmp = (x * (-1.0 + z)) / y_m;
	elseif (x <= 4.0)
		tmp = (4.0 - (x * z)) / y_m;
	else
		tmp = (x / 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, -4.2e+255], N[(z * N[((-x) / y$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.7e-5], N[(N[(x * N[(-1.0 + z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision], If[LessEqual[x, 4.0], N[(N[(4.0 - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(x / 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 -4.2 \cdot 10^{+255}:\\
\;\;\;\;z \cdot \frac{-x}{y\_m}\\

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

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

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


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

    1. Initial program 37.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - \color{blue}{x \cdot \frac{z}{y}} \]
    7. Simplified39.3%

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

        \[\leadsto \color{blue}{-x \cdot \frac{z}{y}} \]
      2. *-un-lft-identity39.3%

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

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

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

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

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

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

    if -4.2e255 < x < -2.6999999999999999e-5

    1. Initial program 86.9%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot z - x}{y} - \frac{4}{y}} \]
      8. *-commutative50.6%

        \[\leadsto \frac{\color{blue}{z \cdot x} - x}{y} - \frac{4}{y} \]
      9. *-un-lft-identity50.6%

        \[\leadsto \frac{z \cdot x - \color{blue}{1 \cdot x}}{y} - \frac{4}{y} \]
      10. distribute-rgt-out--50.6%

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

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

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

    if -2.6999999999999999e-5 < x < 4

    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. add-sqr-sqrt48.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4 < x

    1. Initial program 89.3%

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

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

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

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

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

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

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

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

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

Alternative 13: 74.3% accurate, 5.0× speedup?

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

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

\mathbf{elif}\;x \leq 4.8 \cdot 10^{+49}:\\
\;\;\;\;\frac{4 - x \cdot z}{y\_m}\\

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


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

    1. Initial program 37.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - \color{blue}{x \cdot \frac{z}{y}} \]
    7. Simplified39.3%

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

        \[\leadsto \color{blue}{-x \cdot \frac{z}{y}} \]
      2. *-un-lft-identity39.3%

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

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

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

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

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

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

    if -3.7999999999999999e255 < x < -2.6999999999999999e-5

    1. Initial program 86.9%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot z - x}{y} - \frac{4}{y}} \]
      8. *-commutative50.6%

        \[\leadsto \frac{\color{blue}{z \cdot x} - x}{y} - \frac{4}{y} \]
      9. *-un-lft-identity50.6%

        \[\leadsto \frac{z \cdot x - \color{blue}{1 \cdot x}}{y} - \frac{4}{y} \]
      10. distribute-rgt-out--50.6%

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

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

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

    if -2.6999999999999999e-5 < x < 4.8e49

    1. Initial program 94.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.8e49 < x

    1. Initial program 87.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 77.3% accurate, 5.8× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -4.5 \cdot 10^{+255}:\\ \;\;\;\;z \cdot \frac{-x}{y\_m}\\ \mathbf{elif}\;x \leq -2.7 \cdot 10^{-5}:\\ \;\;\;\;\frac{x \cdot \left(-1 + z\right) - 4}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x + 4\right) - x \cdot z}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x -4.5e+255)
   (* z (/ (- x) y_m))
   (if (<= x -2.7e-5)
     (/ (- (* x (+ -1.0 z)) 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.5e+255) {
		tmp = z * (-x / y_m);
	} else if (x <= -2.7e-5) {
		tmp = ((x * (-1.0 + z)) - 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.5d+255)) then
        tmp = z * (-x / y_m)
    else if (x <= (-2.7d-5)) then
        tmp = ((x * ((-1.0d0) + z)) - 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.5e+255) {
		tmp = z * (-x / y_m);
	} else if (x <= -2.7e-5) {
		tmp = ((x * (-1.0 + z)) - 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.5e+255:
		tmp = z * (-x / y_m)
	elif x <= -2.7e-5:
		tmp = ((x * (-1.0 + z)) - 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.5e+255)
		tmp = Float64(z * Float64(Float64(-x) / y_m));
	elseif (x <= -2.7e-5)
		tmp = Float64(Float64(Float64(x * Float64(-1.0 + z)) - 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.5e+255)
		tmp = z * (-x / y_m);
	elseif (x <= -2.7e-5)
		tmp = ((x * (-1.0 + z)) - 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.5e+255], N[(z * N[((-x) / y$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.7e-5], N[(N[(N[(x * N[(-1.0 + z), $MachinePrecision]), $MachinePrecision] - 4.0), $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.5 \cdot 10^{+255}:\\
\;\;\;\;z \cdot \frac{-x}{y\_m}\\

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

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


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

    1. Initial program 37.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{-y} \]
      11. metadata-eval25.1%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{-4} + \left(-x\right)}{-y} \]
      12. sub-neg25.1%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{-4 - x}}{-y} \]
      13. distribute-frac-neg225.1%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \color{blue}{\left(-\frac{-4 - x}{y}\right)} \]
      14. distribute-neg-in25.1%

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine37.6%

        \[\leadsto -\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      16. neg-sub037.6%

        \[\leadsto \color{blue}{0 - \mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      17. fma-undefine25.1%

        \[\leadsto 0 - \color{blue}{\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      18. associate-*r/25.1%

        \[\leadsto 0 - \left(\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right) \]
      19. associate-*l/25.1%

        \[\leadsto 0 - \left(\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right) \]
    4. Applied egg-rr50.1%

      \[\leadsto \color{blue}{0 - \frac{x \cdot z - \left(x + 4\right)}{y}} \]
    5. Taylor expanded in z around inf 39.5%

      \[\leadsto 0 - \color{blue}{\frac{x \cdot z}{y}} \]
    6. Step-by-step derivation
      1. associate-*r/39.3%

        \[\leadsto 0 - \color{blue}{x \cdot \frac{z}{y}} \]
    7. Simplified39.3%

      \[\leadsto 0 - \color{blue}{x \cdot \frac{z}{y}} \]
    8. Step-by-step derivation
      1. sub0-neg39.3%

        \[\leadsto \color{blue}{-x \cdot \frac{z}{y}} \]
      2. *-un-lft-identity39.3%

        \[\leadsto -x \cdot \frac{\color{blue}{1 \cdot z}}{y} \]
      3. associate-*l/39.3%

        \[\leadsto -x \cdot \color{blue}{\left(\frac{1}{y} \cdot z\right)} \]
      4. associate-*r*63.2%

        \[\leadsto -\color{blue}{\left(x \cdot \frac{1}{y}\right) \cdot z} \]
      5. distribute-rgt-neg-in63.2%

        \[\leadsto \color{blue}{\left(x \cdot \frac{1}{y}\right) \cdot \left(-z\right)} \]
      6. un-div-inv63.2%

        \[\leadsto \color{blue}{\frac{x}{y}} \cdot \left(-z\right) \]
    9. Applied egg-rr63.2%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(-z\right)} \]

    if -4.49999999999999964e255 < x < -2.6999999999999999e-5

    1. Initial program 86.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 90.8%

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
    4. Step-by-step derivation
      1. fabs-sub90.8%

        \[\leadsto \color{blue}{\left|\frac{x \cdot z}{y} - \frac{x + 4}{y}\right|} \]
      2. div-sub98.2%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}}\right| \]
      3. add-sqr-sqrt50.0%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}} \cdot \sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}}}\right| \]
      4. fabs-sqr50.0%

        \[\leadsto \color{blue}{\sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}} \cdot \sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}}} \]
      5. add-sqr-sqrt50.6%

        \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
      6. associate--r+50.6%

        \[\leadsto \frac{\color{blue}{\left(x \cdot z - x\right) - 4}}{y} \]
      7. div-sub50.6%

        \[\leadsto \color{blue}{\frac{x \cdot z - x}{y} - \frac{4}{y}} \]
      8. *-commutative50.6%

        \[\leadsto \frac{\color{blue}{z \cdot x} - x}{y} - \frac{4}{y} \]
      9. *-un-lft-identity50.6%

        \[\leadsto \frac{z \cdot x - \color{blue}{1 \cdot x}}{y} - \frac{4}{y} \]
      10. distribute-rgt-out--50.6%

        \[\leadsto \frac{\color{blue}{x \cdot \left(z - 1\right)}}{y} - \frac{4}{y} \]
    5. Applied egg-rr50.6%

      \[\leadsto \color{blue}{\frac{x \cdot \left(z - 1\right)}{y} - \frac{4}{y}} \]
    6. Taylor expanded in y around 0 50.6%

      \[\leadsto \color{blue}{\frac{x \cdot \left(z - 1\right) - 4}{y}} \]

    if -2.6999999999999999e-5 < x

    1. Initial program 92.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt50.0%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      2. fabs-sqr50.0%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      3. add-sqr-sqrt51.0%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      4. associate-*l/49.8%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      5. associate-*r/51.7%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}} \]
    4. Applied egg-rr51.7%

      \[\leadsto \color{blue}{\frac{x + 4}{y} - x \cdot \frac{z}{y}} \]
    5. Step-by-step derivation
      1. clear-num51.7%

        \[\leadsto \frac{x + 4}{y} - x \cdot \color{blue}{\frac{1}{\frac{y}{z}}} \]
      2. associate-/r/51.7%

        \[\leadsto \frac{x + 4}{y} - x \cdot \color{blue}{\left(\frac{1}{y} \cdot z\right)} \]
    6. Applied egg-rr51.7%

      \[\leadsto \frac{x + 4}{y} - x \cdot \color{blue}{\left(\frac{1}{y} \cdot z\right)} \]
    7. Taylor expanded in y around 0 51.9%

      \[\leadsto \color{blue}{\frac{\left(4 + x\right) - x \cdot z}{y}} \]
    8. Step-by-step derivation
      1. div-sub49.8%

        \[\leadsto \color{blue}{\frac{4 + x}{y} - \frac{x \cdot z}{y}} \]
      2. +-commutative49.8%

        \[\leadsto \frac{\color{blue}{x + 4}}{y} - \frac{x \cdot z}{y} \]
      3. div-sub51.9%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    9. Simplified51.9%

      \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification51.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.5 \cdot 10^{+255}:\\ \;\;\;\;z \cdot \frac{-x}{y}\\ \mathbf{elif}\;x \leq -2.7 \cdot 10^{-5}:\\ \;\;\;\;\frac{x \cdot \left(-1 + z\right) - 4}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x + 4\right) - x \cdot z}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 69.6% accurate, 6.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -7 \cdot 10^{+253}:\\ \;\;\;\;z \cdot \frac{-x}{y\_m}\\ \mathbf{elif}\;x \leq -1.55 \cdot 10^{-5}:\\ \;\;\;\;\frac{x \cdot \left(-1 + z\right)}{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 -7e+253)
   (* z (/ (- x) y_m))
   (if (<= x -1.55e-5) (/ (* x (+ -1.0 z)) y_m) (/ (+ x 4.0) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -7e+253) {
		tmp = z * (-x / y_m);
	} else if (x <= -1.55e-5) {
		tmp = (x * (-1.0 + z)) / y_m;
	} else {
		tmp = (x + 4.0) / y_m;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-7d+253)) then
        tmp = z * (-x / y_m)
    else if (x <= (-1.55d-5)) then
        tmp = (x * ((-1.0d0) + z)) / y_m
    else
        tmp = (x + 4.0d0) / y_m
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -7e+253) {
		tmp = z * (-x / y_m);
	} else if (x <= -1.55e-5) {
		tmp = (x * (-1.0 + z)) / y_m;
	} else {
		tmp = (x + 4.0) / y_m;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= -7e+253:
		tmp = z * (-x / y_m)
	elif x <= -1.55e-5:
		tmp = (x * (-1.0 + z)) / y_m
	else:
		tmp = (x + 4.0) / y_m
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= -7e+253)
		tmp = Float64(z * Float64(Float64(-x) / y_m));
	elseif (x <= -1.55e-5)
		tmp = Float64(Float64(x * Float64(-1.0 + z)) / y_m);
	else
		tmp = Float64(Float64(x + 4.0) / y_m);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= -7e+253)
		tmp = z * (-x / y_m);
	elseif (x <= -1.55e-5)
		tmp = (x * (-1.0 + z)) / y_m;
	else
		tmp = (x + 4.0) / y_m;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, -7e+253], N[(z * N[((-x) / y$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.55e-5], N[(N[(x * N[(-1.0 + z), $MachinePrecision]), $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 -7 \cdot 10^{+253}:\\
\;\;\;\;z \cdot \frac{-x}{y\_m}\\

\mathbf{elif}\;x \leq -1.55 \cdot 10^{-5}:\\
\;\;\;\;\frac{x \cdot \left(-1 + z\right)}{y\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + 4}{y\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -6.99999999999999955e253

    1. Initial program 37.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt25.0%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      2. fabs-sqr25.0%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      3. add-sqr-sqrt25.1%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      4. sub-neg25.1%

        \[\leadsto \color{blue}{\frac{x + 4}{y} + \left(-\frac{x}{y} \cdot z\right)} \]
      5. +-commutative25.1%

        \[\leadsto \color{blue}{\left(-\frac{x}{y} \cdot z\right) + \frac{x + 4}{y}} \]
      6. associate-*l/25.1%

        \[\leadsto \left(-\color{blue}{\frac{x \cdot z}{y}}\right) + \frac{x + 4}{y} \]
      7. associate-*r/25.1%

        \[\leadsto \left(-\color{blue}{x \cdot \frac{z}{y}}\right) + \frac{x + 4}{y} \]
      8. frac-2neg25.1%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \color{blue}{\frac{-\left(x + 4\right)}{-y}} \]
      9. +-commutative25.1%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{-\color{blue}{\left(4 + x\right)}}{-y} \]
      10. distribute-neg-in25.1%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{-y} \]
      11. metadata-eval25.1%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{-4} + \left(-x\right)}{-y} \]
      12. sub-neg25.1%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{-4 - x}}{-y} \]
      13. distribute-frac-neg225.1%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \color{blue}{\left(-\frac{-4 - x}{y}\right)} \]
      14. distribute-neg-in25.1%

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine37.6%

        \[\leadsto -\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      16. neg-sub037.6%

        \[\leadsto \color{blue}{0 - \mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      17. fma-undefine25.1%

        \[\leadsto 0 - \color{blue}{\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      18. associate-*r/25.1%

        \[\leadsto 0 - \left(\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right) \]
      19. associate-*l/25.1%

        \[\leadsto 0 - \left(\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right) \]
    4. Applied egg-rr50.1%

      \[\leadsto \color{blue}{0 - \frac{x \cdot z - \left(x + 4\right)}{y}} \]
    5. Taylor expanded in z around inf 39.5%

      \[\leadsto 0 - \color{blue}{\frac{x \cdot z}{y}} \]
    6. Step-by-step derivation
      1. associate-*r/39.3%

        \[\leadsto 0 - \color{blue}{x \cdot \frac{z}{y}} \]
    7. Simplified39.3%

      \[\leadsto 0 - \color{blue}{x \cdot \frac{z}{y}} \]
    8. Step-by-step derivation
      1. sub0-neg39.3%

        \[\leadsto \color{blue}{-x \cdot \frac{z}{y}} \]
      2. *-un-lft-identity39.3%

        \[\leadsto -x \cdot \frac{\color{blue}{1 \cdot z}}{y} \]
      3. associate-*l/39.3%

        \[\leadsto -x \cdot \color{blue}{\left(\frac{1}{y} \cdot z\right)} \]
      4. associate-*r*63.2%

        \[\leadsto -\color{blue}{\left(x \cdot \frac{1}{y}\right) \cdot z} \]
      5. distribute-rgt-neg-in63.2%

        \[\leadsto \color{blue}{\left(x \cdot \frac{1}{y}\right) \cdot \left(-z\right)} \]
      6. un-div-inv63.2%

        \[\leadsto \color{blue}{\frac{x}{y}} \cdot \left(-z\right) \]
    9. Applied egg-rr63.2%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \left(-z\right)} \]

    if -6.99999999999999955e253 < x < -1.55000000000000007e-5

    1. Initial program 86.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 90.8%

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
    4. Step-by-step derivation
      1. fabs-sub90.8%

        \[\leadsto \color{blue}{\left|\frac{x \cdot z}{y} - \frac{x + 4}{y}\right|} \]
      2. div-sub98.2%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}}\right| \]
      3. add-sqr-sqrt50.0%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}} \cdot \sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}}}\right| \]
      4. fabs-sqr50.0%

        \[\leadsto \color{blue}{\sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}} \cdot \sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}}} \]
      5. add-sqr-sqrt50.6%

        \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
      6. associate--r+50.6%

        \[\leadsto \frac{\color{blue}{\left(x \cdot z - x\right) - 4}}{y} \]
      7. div-sub50.6%

        \[\leadsto \color{blue}{\frac{x \cdot z - x}{y} - \frac{4}{y}} \]
      8. *-commutative50.6%

        \[\leadsto \frac{\color{blue}{z \cdot x} - x}{y} - \frac{4}{y} \]
      9. *-un-lft-identity50.6%

        \[\leadsto \frac{z \cdot x - \color{blue}{1 \cdot x}}{y} - \frac{4}{y} \]
      10. distribute-rgt-out--50.6%

        \[\leadsto \frac{\color{blue}{x \cdot \left(z - 1\right)}}{y} - \frac{4}{y} \]
    5. Applied egg-rr50.6%

      \[\leadsto \color{blue}{\frac{x \cdot \left(z - 1\right)}{y} - \frac{4}{y}} \]
    6. Taylor expanded in x around -inf 50.4%

      \[\leadsto \color{blue}{\frac{x \cdot \left(z - 1\right)}{y}} \]

    if -1.55000000000000007e-5 < x

    1. Initial program 92.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub92.7%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/92.5%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/93.5%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fma-neg94.5%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac94.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative94.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in94.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg94.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval94.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified94.5%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 75.7%

      \[\leadsto \left|\color{blue}{-1 \cdot \frac{4 + x}{y}}\right| \]
    6. Step-by-step derivation
      1. associate-*r/75.7%

        \[\leadsto \left|\color{blue}{\frac{-1 \cdot \left(4 + x\right)}{y}}\right| \]
      2. distribute-lft-in75.7%

        \[\leadsto \left|\frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y}\right| \]
      3. metadata-eval75.7%

        \[\leadsto \left|\frac{\color{blue}{-4} + -1 \cdot x}{y}\right| \]
      4. neg-mul-175.7%

        \[\leadsto \left|\frac{-4 + \color{blue}{\left(-x\right)}}{y}\right| \]
      5. sub-neg75.7%

        \[\leadsto \left|\frac{\color{blue}{-4 - x}}{y}\right| \]
    7. Simplified75.7%

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    8. Step-by-step derivation
      1. add-sqr-sqrt75.3%

        \[\leadsto \color{blue}{\sqrt{\left|\frac{-4 - x}{y}\right|} \cdot \sqrt{\left|\frac{-4 - x}{y}\right|}} \]
      2. sqrt-unprod50.7%

        \[\leadsto \color{blue}{\sqrt{\left|\frac{-4 - x}{y}\right| \cdot \left|\frac{-4 - x}{y}\right|}} \]
      3. neg-fabs50.7%

        \[\leadsto \sqrt{\color{blue}{\left|-\frac{-4 - x}{y}\right|} \cdot \left|\frac{-4 - x}{y}\right|} \]
      4. neg-fabs50.7%

        \[\leadsto \sqrt{\left|-\frac{-4 - x}{y}\right| \cdot \color{blue}{\left|-\frac{-4 - x}{y}\right|}} \]
      5. sqr-abs50.7%

        \[\leadsto \sqrt{\color{blue}{\left(-\frac{-4 - x}{y}\right) \cdot \left(-\frac{-4 - x}{y}\right)}} \]
      6. distribute-frac-neg250.7%

        \[\leadsto \sqrt{\color{blue}{\frac{-4 - x}{-y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      7. sub-neg50.7%

        \[\leadsto \sqrt{\frac{\color{blue}{-4 + \left(-x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      8. metadata-eval50.7%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      9. distribute-neg-in50.7%

        \[\leadsto \sqrt{\frac{\color{blue}{-\left(4 + x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      10. +-commutative50.7%

        \[\leadsto \sqrt{\frac{-\color{blue}{\left(x + 4\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      11. frac-2neg50.7%

        \[\leadsto \sqrt{\color{blue}{\frac{x + 4}{y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      12. distribute-frac-neg250.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{-4 - x}{-y}}} \]
      13. sub-neg50.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-4 + \left(-x\right)}}{-y}} \]
      14. metadata-eval50.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y}} \]
      15. distribute-neg-in50.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-\left(4 + x\right)}}{-y}} \]
      16. +-commutative50.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{-\color{blue}{\left(x + 4\right)}}{-y}} \]
      17. frac-2neg50.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{x + 4}{y}}} \]
      18. sqrt-unprod39.5%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}} \]
      19. add-sqr-sqrt40.4%

        \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
    9. Applied egg-rr40.4%

      \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification43.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7 \cdot 10^{+253}:\\ \;\;\;\;z \cdot \frac{-x}{y}\\ \mathbf{elif}\;x \leq -1.55 \cdot 10^{-5}:\\ \;\;\;\;\frac{x \cdot \left(-1 + z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 68.1% accurate, 7.4× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -8.5 \cdot 10^{+63}:\\ \;\;\;\;\frac{-x}{y\_m}\\ \mathbf{elif}\;x \leq -1.24 \cdot 10^{-5}:\\ \;\;\;\;x \cdot \frac{z}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x -8.5e+63)
   (/ (- x) y_m)
   (if (<= x -1.24e-5) (* x (/ z y_m)) (/ (+ x 4.0) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -8.5e+63) {
		tmp = -x / y_m;
	} else if (x <= -1.24e-5) {
		tmp = x * (z / y_m);
	} else {
		tmp = (x + 4.0) / y_m;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-8.5d+63)) then
        tmp = -x / y_m
    else if (x <= (-1.24d-5)) then
        tmp = x * (z / y_m)
    else
        tmp = (x + 4.0d0) / y_m
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -8.5e+63) {
		tmp = -x / y_m;
	} else if (x <= -1.24e-5) {
		tmp = x * (z / y_m);
	} else {
		tmp = (x + 4.0) / y_m;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= -8.5e+63:
		tmp = -x / y_m
	elif x <= -1.24e-5:
		tmp = x * (z / y_m)
	else:
		tmp = (x + 4.0) / y_m
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= -8.5e+63)
		tmp = Float64(Float64(-x) / y_m);
	elseif (x <= -1.24e-5)
		tmp = Float64(x * Float64(z / y_m));
	else
		tmp = Float64(Float64(x + 4.0) / y_m);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= -8.5e+63)
		tmp = -x / y_m;
	elseif (x <= -1.24e-5)
		tmp = x * (z / y_m);
	else
		tmp = (x + 4.0) / y_m;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, -8.5e+63], N[((-x) / y$95$m), $MachinePrecision], If[LessEqual[x, -1.24e-5], N[(x * N[(z / 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 -8.5 \cdot 10^{+63}:\\
\;\;\;\;\frac{-x}{y\_m}\\

\mathbf{elif}\;x \leq -1.24 \cdot 10^{-5}:\\
\;\;\;\;x \cdot \frac{z}{y\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + 4}{y\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -8.5000000000000004e63

    1. Initial program 74.4%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub74.4%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/81.0%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/85.0%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fma-neg95.7%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac95.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative95.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in95.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg95.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval95.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified95.7%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 71.5%

      \[\leadsto \left|\color{blue}{-1 \cdot \frac{4 + x}{y}}\right| \]
    6. Step-by-step derivation
      1. associate-*r/71.5%

        \[\leadsto \left|\color{blue}{\frac{-1 \cdot \left(4 + x\right)}{y}}\right| \]
      2. distribute-lft-in71.5%

        \[\leadsto \left|\frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y}\right| \]
      3. metadata-eval71.5%

        \[\leadsto \left|\frac{\color{blue}{-4} + -1 \cdot x}{y}\right| \]
      4. neg-mul-171.5%

        \[\leadsto \left|\frac{-4 + \color{blue}{\left(-x\right)}}{y}\right| \]
      5. sub-neg71.5%

        \[\leadsto \left|\frac{\color{blue}{-4 - x}}{y}\right| \]
    7. Simplified71.5%

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    8. Step-by-step derivation
      1. add-sqr-sqrt39.4%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}}\right| \]
      2. fabs-sqr39.4%

        \[\leadsto \color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}} \]
      3. add-sqr-sqrt39.8%

        \[\leadsto \color{blue}{\frac{-4 - x}{y}} \]
      4. div-inv39.7%

        \[\leadsto \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}} \]
    9. Applied egg-rr39.7%

      \[\leadsto \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}} \]
    10. Taylor expanded in x around inf 39.8%

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{y}} \]
    11. Step-by-step derivation
      1. associate-*r/39.8%

        \[\leadsto \color{blue}{\frac{-1 \cdot x}{y}} \]
      2. mul-1-neg39.8%

        \[\leadsto \frac{\color{blue}{-x}}{y} \]
    12. Simplified39.8%

      \[\leadsto \color{blue}{\frac{-x}{y}} \]

    if -8.5000000000000004e63 < x < -1.24e-5

    1. Initial program 99.8%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt59.8%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      2. fabs-sqr59.8%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      3. add-sqr-sqrt60.5%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      4. associate-*l/60.5%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      5. associate-*r/60.5%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}} \]
    4. Applied egg-rr60.5%

      \[\leadsto \color{blue}{\frac{x + 4}{y} - x \cdot \frac{z}{y}} \]
    5. Step-by-step derivation
      1. associate-*r/60.5%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      2. add-sqr-sqrt13.8%

        \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)}}{y} \]
      3. sqrt-unprod15.7%

        \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \color{blue}{\sqrt{z \cdot z}}}{y} \]
      4. sqr-neg15.7%

        \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \sqrt{\color{blue}{\left(-z\right) \cdot \left(-z\right)}}}{y} \]
      5. sqrt-unprod27.1%

        \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \color{blue}{\left(\sqrt{-z} \cdot \sqrt{-z}\right)}}{y} \]
      6. add-sqr-sqrt34.2%

        \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \color{blue}{\left(-z\right)}}{y} \]
      7. associate-/l*34.1%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{x \cdot \frac{-z}{y}} \]
      8. distribute-frac-neg34.1%

        \[\leadsto \frac{x + 4}{y} - x \cdot \color{blue}{\left(-\frac{z}{y}\right)} \]
      9. distribute-rgt-neg-in34.1%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\left(-x \cdot \frac{z}{y}\right)} \]
      10. distribute-lft-neg-in34.1%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\left(-x\right) \cdot \frac{z}{y}} \]
      11. clear-num34.2%

        \[\leadsto \frac{x + 4}{y} - \left(-x\right) \cdot \color{blue}{\frac{1}{\frac{y}{z}}} \]
      12. un-div-inv34.3%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{\frac{y}{z}}} \]
    6. Applied egg-rr34.3%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{\frac{y}{z}}} \]
    7. Taylor expanded in z around inf 28.1%

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} \]
    8. Step-by-step derivation
      1. associate-*r/28.0%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y}} \]
    9. Simplified28.0%

      \[\leadsto \color{blue}{x \cdot \frac{z}{y}} \]

    if -1.24e-5 < x

    1. Initial program 92.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub92.7%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/92.5%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/93.5%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fma-neg94.5%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac94.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative94.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in94.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg94.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval94.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified94.5%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 75.7%

      \[\leadsto \left|\color{blue}{-1 \cdot \frac{4 + x}{y}}\right| \]
    6. Step-by-step derivation
      1. associate-*r/75.7%

        \[\leadsto \left|\color{blue}{\frac{-1 \cdot \left(4 + x\right)}{y}}\right| \]
      2. distribute-lft-in75.7%

        \[\leadsto \left|\frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y}\right| \]
      3. metadata-eval75.7%

        \[\leadsto \left|\frac{\color{blue}{-4} + -1 \cdot x}{y}\right| \]
      4. neg-mul-175.7%

        \[\leadsto \left|\frac{-4 + \color{blue}{\left(-x\right)}}{y}\right| \]
      5. sub-neg75.7%

        \[\leadsto \left|\frac{\color{blue}{-4 - x}}{y}\right| \]
    7. Simplified75.7%

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    8. Step-by-step derivation
      1. add-sqr-sqrt75.3%

        \[\leadsto \color{blue}{\sqrt{\left|\frac{-4 - x}{y}\right|} \cdot \sqrt{\left|\frac{-4 - x}{y}\right|}} \]
      2. sqrt-unprod50.7%

        \[\leadsto \color{blue}{\sqrt{\left|\frac{-4 - x}{y}\right| \cdot \left|\frac{-4 - x}{y}\right|}} \]
      3. neg-fabs50.7%

        \[\leadsto \sqrt{\color{blue}{\left|-\frac{-4 - x}{y}\right|} \cdot \left|\frac{-4 - x}{y}\right|} \]
      4. neg-fabs50.7%

        \[\leadsto \sqrt{\left|-\frac{-4 - x}{y}\right| \cdot \color{blue}{\left|-\frac{-4 - x}{y}\right|}} \]
      5. sqr-abs50.7%

        \[\leadsto \sqrt{\color{blue}{\left(-\frac{-4 - x}{y}\right) \cdot \left(-\frac{-4 - x}{y}\right)}} \]
      6. distribute-frac-neg250.7%

        \[\leadsto \sqrt{\color{blue}{\frac{-4 - x}{-y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      7. sub-neg50.7%

        \[\leadsto \sqrt{\frac{\color{blue}{-4 + \left(-x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      8. metadata-eval50.7%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      9. distribute-neg-in50.7%

        \[\leadsto \sqrt{\frac{\color{blue}{-\left(4 + x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      10. +-commutative50.7%

        \[\leadsto \sqrt{\frac{-\color{blue}{\left(x + 4\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      11. frac-2neg50.7%

        \[\leadsto \sqrt{\color{blue}{\frac{x + 4}{y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      12. distribute-frac-neg250.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{-4 - x}{-y}}} \]
      13. sub-neg50.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-4 + \left(-x\right)}}{-y}} \]
      14. metadata-eval50.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y}} \]
      15. distribute-neg-in50.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-\left(4 + x\right)}}{-y}} \]
      16. +-commutative50.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{-\color{blue}{\left(x + 4\right)}}{-y}} \]
      17. frac-2neg50.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{x + 4}{y}}} \]
      18. sqrt-unprod39.5%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}} \]
      19. add-sqr-sqrt40.4%

        \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
    9. Applied egg-rr40.4%

      \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 17: 68.5% accurate, 8.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -10.2:\\ \;\;\;\;\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.2) (/ (- 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.2) {
		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.2d0)) 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.2) {
		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.2:
		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.2)
		tmp = Float64(Float64(-x) / 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.2)
		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.2], 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.2:\\
\;\;\;\;\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.199999999999999

    1. Initial program 80.2%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub80.2%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/85.3%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/88.4%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fma-neg96.6%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac96.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative96.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in96.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg96.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval96.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified96.6%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 64.0%

      \[\leadsto \left|\color{blue}{-1 \cdot \frac{4 + x}{y}}\right| \]
    6. Step-by-step derivation
      1. associate-*r/64.0%

        \[\leadsto \left|\color{blue}{\frac{-1 \cdot \left(4 + x\right)}{y}}\right| \]
      2. distribute-lft-in64.0%

        \[\leadsto \left|\frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y}\right| \]
      3. metadata-eval64.0%

        \[\leadsto \left|\frac{\color{blue}{-4} + -1 \cdot x}{y}\right| \]
      4. neg-mul-164.0%

        \[\leadsto \left|\frac{-4 + \color{blue}{\left(-x\right)}}{y}\right| \]
      5. sub-neg64.0%

        \[\leadsto \left|\frac{\color{blue}{-4 - x}}{y}\right| \]
    7. Simplified64.0%

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    8. Step-by-step derivation
      1. add-sqr-sqrt35.4%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}}\right| \]
      2. fabs-sqr35.4%

        \[\leadsto \color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}} \]
      3. add-sqr-sqrt36.0%

        \[\leadsto \color{blue}{\frac{-4 - x}{y}} \]
      4. div-inv35.9%

        \[\leadsto \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}} \]
    9. Applied egg-rr35.9%

      \[\leadsto \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}} \]
    10. Taylor expanded in x around inf 35.8%

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{y}} \]
    11. Step-by-step derivation
      1. associate-*r/35.8%

        \[\leadsto \color{blue}{\frac{-1 \cdot x}{y}} \]
      2. mul-1-neg35.8%

        \[\leadsto \frac{\color{blue}{-x}}{y} \]
    12. Simplified35.8%

      \[\leadsto \color{blue}{\frac{-x}{y}} \]

    if -10.199999999999999 < x < 4

    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. 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| \]
      2. 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}} \]
      3. add-sqr-sqrt49.5%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      4. associate-*l/52.0%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      5. associate-*r/50.6%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}} \]
    4. Applied egg-rr50.6%

      \[\leadsto \color{blue}{\frac{x + 4}{y} - x \cdot \frac{z}{y}} \]
    5. Step-by-step derivation
      1. associate-*r/52.0%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      2. add-sqr-sqrt24.4%

        \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)}}{y} \]
      3. sqrt-unprod44.6%

        \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \color{blue}{\sqrt{z \cdot z}}}{y} \]
      4. sqr-neg44.6%

        \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \sqrt{\color{blue}{\left(-z\right) \cdot \left(-z\right)}}}{y} \]
      5. sqrt-unprod27.1%

        \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \color{blue}{\left(\sqrt{-z} \cdot \sqrt{-z}\right)}}{y} \]
      6. add-sqr-sqrt52.3%

        \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \color{blue}{\left(-z\right)}}{y} \]
      7. associate-/l*50.3%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{x \cdot \frac{-z}{y}} \]
      8. distribute-frac-neg50.3%

        \[\leadsto \frac{x + 4}{y} - x \cdot \color{blue}{\left(-\frac{z}{y}\right)} \]
      9. distribute-rgt-neg-in50.3%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\left(-x \cdot \frac{z}{y}\right)} \]
      10. distribute-lft-neg-in50.3%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\left(-x\right) \cdot \frac{z}{y}} \]
      11. clear-num50.3%

        \[\leadsto \frac{x + 4}{y} - \left(-x\right) \cdot \color{blue}{\frac{1}{\frac{y}{z}}} \]
      12. un-div-inv50.3%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{\frac{y}{z}}} \]
    6. Applied egg-rr50.3%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{\frac{y}{z}}} \]
    7. Taylor expanded in x around 0 43.6%

      \[\leadsto \color{blue}{\frac{4}{y}} \]

    if 4 < x

    1. Initial program 89.3%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub89.3%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/78.1%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/90.8%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fma-neg93.8%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac93.8%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative93.8%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in93.8%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg93.8%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval93.8%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified93.8%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 58.6%

      \[\leadsto \left|\color{blue}{-1 \cdot \frac{4 + x}{y}}\right| \]
    6. Step-by-step derivation
      1. associate-*r/58.6%

        \[\leadsto \left|\color{blue}{\frac{-1 \cdot \left(4 + x\right)}{y}}\right| \]
      2. distribute-lft-in58.6%

        \[\leadsto \left|\frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y}\right| \]
      3. metadata-eval58.6%

        \[\leadsto \left|\frac{\color{blue}{-4} + -1 \cdot x}{y}\right| \]
      4. neg-mul-158.6%

        \[\leadsto \left|\frac{-4 + \color{blue}{\left(-x\right)}}{y}\right| \]
      5. sub-neg58.6%

        \[\leadsto \left|\frac{\color{blue}{-4 - x}}{y}\right| \]
    7. Simplified58.6%

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    8. Step-by-step derivation
      1. add-sqr-sqrt58.4%

        \[\leadsto \color{blue}{\sqrt{\left|\frac{-4 - x}{y}\right|} \cdot \sqrt{\left|\frac{-4 - x}{y}\right|}} \]
      2. sqrt-unprod52.8%

        \[\leadsto \color{blue}{\sqrt{\left|\frac{-4 - x}{y}\right| \cdot \left|\frac{-4 - x}{y}\right|}} \]
      3. neg-fabs52.8%

        \[\leadsto \sqrt{\color{blue}{\left|-\frac{-4 - x}{y}\right|} \cdot \left|\frac{-4 - x}{y}\right|} \]
      4. neg-fabs52.8%

        \[\leadsto \sqrt{\left|-\frac{-4 - x}{y}\right| \cdot \color{blue}{\left|-\frac{-4 - x}{y}\right|}} \]
      5. sqr-abs52.8%

        \[\leadsto \sqrt{\color{blue}{\left(-\frac{-4 - x}{y}\right) \cdot \left(-\frac{-4 - x}{y}\right)}} \]
      6. distribute-frac-neg252.8%

        \[\leadsto \sqrt{\color{blue}{\frac{-4 - x}{-y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      7. sub-neg52.8%

        \[\leadsto \sqrt{\frac{\color{blue}{-4 + \left(-x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      8. metadata-eval52.8%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      9. distribute-neg-in52.8%

        \[\leadsto \sqrt{\frac{\color{blue}{-\left(4 + x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      10. +-commutative52.8%

        \[\leadsto \sqrt{\frac{-\color{blue}{\left(x + 4\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      11. frac-2neg52.8%

        \[\leadsto \sqrt{\color{blue}{\frac{x + 4}{y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      12. distribute-frac-neg252.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{-4 - x}{-y}}} \]
      13. sub-neg52.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-4 + \left(-x\right)}}{-y}} \]
      14. metadata-eval52.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y}} \]
      15. distribute-neg-in52.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-\left(4 + x\right)}}{-y}} \]
      16. +-commutative52.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{-\color{blue}{\left(x + 4\right)}}{-y}} \]
      17. frac-2neg52.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{x + 4}{y}}} \]
      18. sqrt-unprod31.7%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}} \]
      19. add-sqr-sqrt32.0%

        \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
      20. clear-num32.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{x + 4}}} \]
    9. Applied egg-rr32.0%

      \[\leadsto \color{blue}{\frac{1}{\frac{y}{x + 4}}} \]
    10. Taylor expanded in x around inf 32.0%

      \[\leadsto \color{blue}{\frac{x}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 18: 54.5% 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 89.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt45.9%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      2. fabs-sqr45.9%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      3. add-sqr-sqrt46.8%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      4. associate-*l/49.1%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      5. associate-*r/48.1%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}} \]
    4. Applied egg-rr48.1%

      \[\leadsto \color{blue}{\frac{x + 4}{y} - x \cdot \frac{z}{y}} \]
    5. Step-by-step derivation
      1. associate-*r/49.1%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      2. add-sqr-sqrt22.4%

        \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)}}{y} \]
      3. sqrt-unprod41.5%

        \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \color{blue}{\sqrt{z \cdot z}}}{y} \]
      4. sqr-neg41.5%

        \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \sqrt{\color{blue}{\left(-z\right) \cdot \left(-z\right)}}}{y} \]
      5. sqrt-unprod25.8%

        \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \color{blue}{\left(\sqrt{-z} \cdot \sqrt{-z}\right)}}{y} \]
      6. add-sqr-sqrt48.7%

        \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \color{blue}{\left(-z\right)}}{y} \]
      7. associate-/l*48.3%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{x \cdot \frac{-z}{y}} \]
      8. distribute-frac-neg48.3%

        \[\leadsto \frac{x + 4}{y} - x \cdot \color{blue}{\left(-\frac{z}{y}\right)} \]
      9. distribute-rgt-neg-in48.3%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\left(-x \cdot \frac{z}{y}\right)} \]
      10. distribute-lft-neg-in48.3%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\left(-x\right) \cdot \frac{z}{y}} \]
      11. clear-num48.3%

        \[\leadsto \frac{x + 4}{y} - \left(-x\right) \cdot \color{blue}{\frac{1}{\frac{y}{z}}} \]
      12. un-div-inv48.4%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{\frac{y}{z}}} \]
    6. Applied egg-rr48.4%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{\frac{y}{z}}} \]
    7. Taylor expanded in x around 0 30.7%

      \[\leadsto \color{blue}{\frac{4}{y}} \]

    if 4 < x

    1. Initial program 89.3%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub89.3%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/78.1%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/90.8%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fma-neg93.8%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac93.8%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative93.8%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in93.8%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg93.8%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval93.8%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified93.8%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Taylor expanded in z around 0 58.6%

      \[\leadsto \left|\color{blue}{-1 \cdot \frac{4 + x}{y}}\right| \]
    6. Step-by-step derivation
      1. associate-*r/58.6%

        \[\leadsto \left|\color{blue}{\frac{-1 \cdot \left(4 + x\right)}{y}}\right| \]
      2. distribute-lft-in58.6%

        \[\leadsto \left|\frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y}\right| \]
      3. metadata-eval58.6%

        \[\leadsto \left|\frac{\color{blue}{-4} + -1 \cdot x}{y}\right| \]
      4. neg-mul-158.6%

        \[\leadsto \left|\frac{-4 + \color{blue}{\left(-x\right)}}{y}\right| \]
      5. sub-neg58.6%

        \[\leadsto \left|\frac{\color{blue}{-4 - x}}{y}\right| \]
    7. Simplified58.6%

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    8. Step-by-step derivation
      1. add-sqr-sqrt58.4%

        \[\leadsto \color{blue}{\sqrt{\left|\frac{-4 - x}{y}\right|} \cdot \sqrt{\left|\frac{-4 - x}{y}\right|}} \]
      2. sqrt-unprod52.8%

        \[\leadsto \color{blue}{\sqrt{\left|\frac{-4 - x}{y}\right| \cdot \left|\frac{-4 - x}{y}\right|}} \]
      3. neg-fabs52.8%

        \[\leadsto \sqrt{\color{blue}{\left|-\frac{-4 - x}{y}\right|} \cdot \left|\frac{-4 - x}{y}\right|} \]
      4. neg-fabs52.8%

        \[\leadsto \sqrt{\left|-\frac{-4 - x}{y}\right| \cdot \color{blue}{\left|-\frac{-4 - x}{y}\right|}} \]
      5. sqr-abs52.8%

        \[\leadsto \sqrt{\color{blue}{\left(-\frac{-4 - x}{y}\right) \cdot \left(-\frac{-4 - x}{y}\right)}} \]
      6. distribute-frac-neg252.8%

        \[\leadsto \sqrt{\color{blue}{\frac{-4 - x}{-y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      7. sub-neg52.8%

        \[\leadsto \sqrt{\frac{\color{blue}{-4 + \left(-x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      8. metadata-eval52.8%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      9. distribute-neg-in52.8%

        \[\leadsto \sqrt{\frac{\color{blue}{-\left(4 + x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      10. +-commutative52.8%

        \[\leadsto \sqrt{\frac{-\color{blue}{\left(x + 4\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      11. frac-2neg52.8%

        \[\leadsto \sqrt{\color{blue}{\frac{x + 4}{y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      12. distribute-frac-neg252.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{-4 - x}{-y}}} \]
      13. sub-neg52.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-4 + \left(-x\right)}}{-y}} \]
      14. metadata-eval52.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y}} \]
      15. distribute-neg-in52.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-\left(4 + x\right)}}{-y}} \]
      16. +-commutative52.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{-\color{blue}{\left(x + 4\right)}}{-y}} \]
      17. frac-2neg52.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{x + 4}{y}}} \]
      18. sqrt-unprod31.7%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}} \]
      19. add-sqr-sqrt32.0%

        \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
      20. clear-num32.0%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{x + 4}}} \]
    9. Applied egg-rr32.0%

      \[\leadsto \color{blue}{\frac{1}{\frac{y}{x + 4}}} \]
    10. Taylor expanded in x around inf 32.0%

      \[\leadsto \color{blue}{\frac{x}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 19: 40.2% 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 89.8%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-sqr-sqrt47.6%

      \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
    2. fabs-sqr47.6%

      \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
    3. add-sqr-sqrt48.5%

      \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
    4. associate-*l/47.9%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
    5. associate-*r/49.4%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}} \]
  4. Applied egg-rr49.4%

    \[\leadsto \color{blue}{\frac{x + 4}{y} - x \cdot \frac{z}{y}} \]
  5. Step-by-step derivation
    1. associate-*r/47.9%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
    2. add-sqr-sqrt21.4%

      \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)}}{y} \]
    3. sqrt-unprod38.5%

      \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \color{blue}{\sqrt{z \cdot z}}}{y} \]
    4. sqr-neg38.5%

      \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \sqrt{\color{blue}{\left(-z\right) \cdot \left(-z\right)}}}{y} \]
    5. sqrt-unprod22.8%

      \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \color{blue}{\left(\sqrt{-z} \cdot \sqrt{-z}\right)}}{y} \]
    6. add-sqr-sqrt45.7%

      \[\leadsto \frac{x + 4}{y} - \frac{x \cdot \color{blue}{\left(-z\right)}}{y} \]
    7. associate-/l*46.5%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{x \cdot \frac{-z}{y}} \]
    8. distribute-frac-neg46.5%

      \[\leadsto \frac{x + 4}{y} - x \cdot \color{blue}{\left(-\frac{z}{y}\right)} \]
    9. distribute-rgt-neg-in46.5%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\left(-x \cdot \frac{z}{y}\right)} \]
    10. distribute-lft-neg-in46.5%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\left(-x\right) \cdot \frac{z}{y}} \]
    11. clear-num46.5%

      \[\leadsto \frac{x + 4}{y} - \left(-x\right) \cdot \color{blue}{\frac{1}{\frac{y}{z}}} \]
    12. un-div-inv46.5%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{\frac{y}{z}}} \]
  6. Applied egg-rr46.5%

    \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{\frac{y}{z}}} \]
  7. Taylor expanded in x around 0 23.6%

    \[\leadsto \color{blue}{\frac{4}{y}} \]
  8. Add Preprocessing

Reproduce

?
herbie shell --seed 2024110 
(FPCore (x y z)
  :name "fabs fraction 1"
  :precision binary64
  (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))