fabs fraction 1

Percentage Accurate: 91.8% → 99.7%
Time: 8.4s
Alternatives: 10
Speedup: 1.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 10 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.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;y\_m \leq 1.5 \cdot 10^{-59}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y\_m}\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 1.5e-59)
   (fabs (/ (- (+ x 4.0) (* x z)) y_m))
   (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 <= 1.5e-59) {
		tmp = fabs((((x + 4.0) - (x * z)) / y_m));
	} 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 <= 1.5e-59)
		tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y_m));
	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, 1.5e-59], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $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 1.5 \cdot 10^{-59}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y\_m}\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 < 1.5e-59

    1. Initial program 88.3%

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

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

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

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

    if 1.5e-59 < y

    1. Initial program 98.7%

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

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

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/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. Final simplification97.7%

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

Alternative 2: 97.4% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z)) < 4.9999999999999999e267

    1. Initial program 98.6%

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

    if 4.9999999999999999e267 < (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))

    1. Initial program 52.5%

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

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

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

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

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

Alternative 3: 68.4% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \left|\frac{x}{y\_m}\right|\\
\mathbf{if}\;x \leq -10.2:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;x \leq 5.6 \cdot 10^{+169} \lor \neg \left(x \leq 1.2 \cdot 10^{+195}\right):\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\left|x \cdot \frac{z}{y\_m}\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -10.199999999999999 or 4 < x < 5.6000000000000003e169 or 1.2000000000000001e195 < x

    1. Initial program 87.2%

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

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

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

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

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

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

    if -10.199999999999999 < x < 4

    1. Initial program 97.7%

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

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

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

    if 5.6000000000000003e169 < x < 1.2000000000000001e195

    1. Initial program 63.6%

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

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

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

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

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

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

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

        \[\leadsto \left|x \cdot \color{blue}{\frac{1}{\frac{-y}{z}}}\right| \]
      2. un-div-inv91.5%

        \[\leadsto \left|\color{blue}{\frac{x}{\frac{-y}{z}}}\right| \]
      3. add-sqr-sqrt27.1%

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

        \[\leadsto \left|\frac{x}{\frac{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}{z}}\right| \]
      5. sqr-neg73.7%

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

        \[\leadsto \left|\frac{x}{\frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{z}}\right| \]
      7. add-sqr-sqrt91.5%

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

      \[\leadsto \left|\color{blue}{\frac{x}{\frac{y}{z}}}\right| \]
    9. Step-by-step derivation
      1. associate-/r/100.0%

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

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

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}}\right| \]
    10. Simplified91.5%

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

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

Alternative 4: 69.4% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.7 \cdot 10^{+99}:\\
\;\;\;\;\left|\frac{x}{y\_m}\right|\\

\mathbf{elif}\;x \leq -4.2 \cdot 10^{-15} \lor \neg \left(x \leq 1.4 \cdot 10^{-19}\right):\\
\;\;\;\;\left|z \cdot \frac{x}{y\_m}\right|\\

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


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

    1. Initial program 87.7%

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

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

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

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

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

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

    if -5.70000000000000003e99 < x < -4.19999999999999962e-15 or 1.40000000000000001e-19 < x

    1. Initial program 85.0%

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{x \cdot \frac{z}{-y}}\right| \]
    7. Step-by-step derivation
      1. clear-num59.1%

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

        \[\leadsto \left|\color{blue}{\frac{x}{\frac{-y}{z}}}\right| \]
      3. add-sqr-sqrt27.1%

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

        \[\leadsto \left|\frac{x}{\frac{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}{z}}\right| \]
      5. sqr-neg53.2%

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

        \[\leadsto \left|\frac{x}{\frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{z}}\right| \]
      7. add-sqr-sqrt59.1%

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

      \[\leadsto \left|\color{blue}{\frac{x}{\frac{y}{z}}}\right| \]
    9. Step-by-step derivation
      1. associate-/r/69.3%

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

        \[\leadsto \left|\color{blue}{z \cdot \frac{x}{y}}\right| \]
    10. Simplified69.3%

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

    if -4.19999999999999962e-15 < x < 1.40000000000000001e-19

    1. Initial program 97.6%

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

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

      \[\leadsto \left|\color{blue}{\frac{4}{y}}\right| \]
  3. Recombined 3 regimes into one program.
  4. Final simplification78.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.7 \cdot 10^{+99}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -4.2 \cdot 10^{-15} \lor \neg \left(x \leq 1.4 \cdot 10^{-19}\right):\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 87.1% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.55e-20 or 2.3500000000000001e-22 < x

    1. Initial program 85.8%

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

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

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

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

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

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

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

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

    if -1.55e-20 < x < 2.3500000000000001e-22

    1. Initial program 97.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 99.8% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 89.6%

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

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

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

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

    if 2.00000000000000009e48 < y

    1. Initial program 98.1%

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

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

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

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

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

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

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

Alternative 7: 84.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.5 \cdot 10^{+152}:\\
\;\;\;\;\left|z \cdot \frac{x}{y\_m}\right|\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -6.4999999999999997e152

    1. Initial program 99.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Simplified81.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 67.0%

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

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

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

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

      \[\leadsto \left|\color{blue}{x \cdot \frac{z}{-y}}\right| \]
    7. Step-by-step derivation
      1. clear-num81.2%

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

        \[\leadsto \left|\color{blue}{\frac{x}{\frac{-y}{z}}}\right| \]
      3. add-sqr-sqrt52.6%

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

        \[\leadsto \left|\frac{x}{\frac{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}{z}}\right| \]
      5. sqr-neg57.7%

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

        \[\leadsto \left|\frac{x}{\frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{z}}\right| \]
      7. add-sqr-sqrt81.3%

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

      \[\leadsto \left|\color{blue}{\frac{x}{\frac{y}{z}}}\right| \]
    9. Step-by-step derivation
      1. associate-/r/85.7%

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

        \[\leadsto \left|\color{blue}{z \cdot \frac{x}{y}}\right| \]
    10. Simplified85.7%

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

    if -6.4999999999999997e152 < z < 3.99999999999999993e73

    1. Initial program 93.4%

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

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

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

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

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

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

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

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

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

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

      \[\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 92.3%

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

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

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

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

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

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

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

    if 3.99999999999999993e73 < z

    1. Initial program 78.9%

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{x \cdot \frac{z}{-y}}\right| \]
    7. Step-by-step derivation
      1. clear-num78.6%

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

        \[\leadsto \left|\color{blue}{\frac{x}{\frac{-y}{z}}}\right| \]
      3. add-sqr-sqrt41.2%

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

        \[\leadsto \left|\frac{x}{\frac{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}{z}}\right| \]
      5. sqr-neg59.2%

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

        \[\leadsto \left|\frac{x}{\frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{z}}\right| \]
      7. add-sqr-sqrt79.8%

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

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

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

Alternative 8: 97.9% accurate, 1.0× speedup?

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

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

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


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

    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. associate-*l/95.4%

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

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

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

    if 5.5e14 < x

    1. Initial program 81.9%

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

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

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

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

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

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

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

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

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

Alternative 9: 68.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.6 \lor \neg \left(x \leq 4\right):\\
\;\;\;\;\left|\frac{x}{y\_m}\right|\\

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


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

    1. Initial program 85.2%

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

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

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

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

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

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

    if -9.59999999999999964 < x < 4

    1. Initial program 97.7%

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

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

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

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

Alternative 10: 39.7% accurate, 1.1× speedup?

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

\\
\left|\frac{4}{y\_m}\right|
\end{array}
Derivation
  1. Initial program 91.4%

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

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

    \[\leadsto \left|\color{blue}{\frac{4}{y}}\right| \]
  5. Final simplification44.5%

    \[\leadsto \left|\frac{4}{y}\right| \]
  6. Add Preprocessing

Reproduce

?
herbie shell --seed 2024047 
(FPCore (x y z)
  :name "fabs fraction 1"
  :precision binary64
  (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))