fabs fraction 1

Percentage Accurate: 91.6% → 99.8%
Time: 7.9s
Alternatives: 11
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 11 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.6% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.5× speedup?

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

    1. Initial program 89.3%

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

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

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

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

    if 3.00000000000000018e34 < y

    1. Initial program 94.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 3 \cdot 10^{+34}:\\ \;\;\;\;\left|\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{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.9% accurate, 0.9× 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}\\ \mathbf{if}\;t_0 - t_1 \leq 5 \cdot 10^{+292}:\\ \;\;\;\;\left|t_1 - 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)) (t_1 (* z (/ x y_m))))
   (if (<= (- t_0 t_1) 5e+292)
     (fabs (- t_1 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;
	double t_1 = z * (x / y_m);
	double tmp;
	if ((t_0 - t_1) <= 5e+292) {
		tmp = fabs((t_1 - 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) :: t_1
    real(8) :: tmp
    t_0 = (x + 4.0d0) / y_m
    t_1 = z * (x / y_m)
    if ((t_0 - t_1) <= 5d+292) then
        tmp = abs((t_1 - 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;
	double t_1 = z * (x / y_m);
	double tmp;
	if ((t_0 - t_1) <= 5e+292) {
		tmp = Math.abs((t_1 - 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
	t_1 = z * (x / y_m)
	tmp = 0
	if (t_0 - t_1) <= 5e+292:
		tmp = math.fabs((t_1 - 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(x + 4.0) / y_m)
	t_1 = Float64(z * Float64(x / y_m))
	tmp = 0.0
	if (Float64(t_0 - t_1) <= 5e+292)
		tmp = abs(Float64(t_1 - 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;
	t_1 = z * (x / y_m);
	tmp = 0.0;
	if ((t_0 - t_1) <= 5e+292)
		tmp = abs((t_1 - 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[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - t$95$1), $MachinePrecision], 5e+292], N[Abs[N[(t$95$1 - t$95$0), $MachinePrecision]], $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}\\
t_1 := z \cdot \frac{x}{y_m}\\
\mathbf{if}\;t_0 - t_1 \leq 5 \cdot 10^{+292}:\\
\;\;\;\;\left|t_1 - 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.9999999999999996e292

    1. Initial program 98.2%

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

    if 4.9999999999999996e292 < (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))

    1. Initial program 52.4%

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

      \[\leadsto \left|\color{blue}{\frac{\left(4 + x\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^{+292}:\\ \;\;\;\;\left|z \cdot \frac{x}{y} - \frac{x + 4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 65.6% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \left|\frac{x}{y_m}\right|\\ t_1 := \left|x \cdot \frac{z}{y_m}\right|\\ \mathbf{if}\;x \leq -1.95 \cdot 10^{+127}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.1 \cdot 10^{-7}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-111}:\\ \;\;\;\;\left|\frac{4}{y_m}\right|\\ \mathbf{elif}\;x \leq 185000000 \lor \neg \left(x \leq 1.46 \cdot 10^{+164}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (let* ((t_0 (fabs (/ x y_m))) (t_1 (fabs (* x (/ z y_m)))))
   (if (<= x -1.95e+127)
     t_0
     (if (<= x -1.1e-7)
       t_1
       (if (<= x 4.2e-111)
         (fabs (/ 4.0 y_m))
         (if (or (<= x 185000000.0) (not (<= x 1.46e+164))) t_1 t_0))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = fabs((x / y_m));
	double t_1 = fabs((x * (z / y_m)));
	double tmp;
	if (x <= -1.95e+127) {
		tmp = t_0;
	} else if (x <= -1.1e-7) {
		tmp = t_1;
	} else if (x <= 4.2e-111) {
		tmp = fabs((4.0 / y_m));
	} else if ((x <= 185000000.0) || !(x <= 1.46e+164)) {
		tmp = t_1;
	} else {
		tmp = 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 = abs((x / y_m))
    t_1 = abs((x * (z / y_m)))
    if (x <= (-1.95d+127)) then
        tmp = t_0
    else if (x <= (-1.1d-7)) then
        tmp = t_1
    else if (x <= 4.2d-111) then
        tmp = abs((4.0d0 / y_m))
    else if ((x <= 185000000.0d0) .or. (.not. (x <= 1.46d+164))) then
        tmp = t_1
    else
        tmp = 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 = Math.abs((x / y_m));
	double t_1 = Math.abs((x * (z / y_m)));
	double tmp;
	if (x <= -1.95e+127) {
		tmp = t_0;
	} else if (x <= -1.1e-7) {
		tmp = t_1;
	} else if (x <= 4.2e-111) {
		tmp = Math.abs((4.0 / y_m));
	} else if ((x <= 185000000.0) || !(x <= 1.46e+164)) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	t_0 = math.fabs((x / y_m))
	t_1 = math.fabs((x * (z / y_m)))
	tmp = 0
	if x <= -1.95e+127:
		tmp = t_0
	elif x <= -1.1e-7:
		tmp = t_1
	elif x <= 4.2e-111:
		tmp = math.fabs((4.0 / y_m))
	elif (x <= 185000000.0) or not (x <= 1.46e+164):
		tmp = t_1
	else:
		tmp = t_0
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	t_0 = abs(Float64(x / y_m))
	t_1 = abs(Float64(x * Float64(z / y_m)))
	tmp = 0.0
	if (x <= -1.95e+127)
		tmp = t_0;
	elseif (x <= -1.1e-7)
		tmp = t_1;
	elseif (x <= 4.2e-111)
		tmp = abs(Float64(4.0 / y_m));
	elseif ((x <= 185000000.0) || !(x <= 1.46e+164))
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	t_0 = abs((x / y_m));
	t_1 = abs((x * (z / y_m)));
	tmp = 0.0;
	if (x <= -1.95e+127)
		tmp = t_0;
	elseif (x <= -1.1e-7)
		tmp = t_1;
	elseif (x <= 4.2e-111)
		tmp = abs((4.0 / y_m));
	elseif ((x <= 185000000.0) || ~((x <= 1.46e+164)))
		tmp = t_1;
	else
		tmp = t_0;
	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]}, Block[{t$95$1 = N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.95e+127], t$95$0, If[LessEqual[x, -1.1e-7], t$95$1, If[LessEqual[x, 4.2e-111], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 185000000.0], N[Not[LessEqual[x, 1.46e+164]], $MachinePrecision]], t$95$1, t$95$0]]]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := \left|\frac{x}{y_m}\right|\\
t_1 := \left|x \cdot \frac{z}{y_m}\right|\\
\mathbf{if}\;x \leq -1.95 \cdot 10^{+127}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -1.1 \cdot 10^{-7}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 4.2 \cdot 10^{-111}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\

\mathbf{elif}\;x \leq 185000000 \lor \neg \left(x \leq 1.46 \cdot 10^{+164}\right):\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.94999999999999991e127 or 1.85e8 < x < 1.45999999999999994e164

    1. Initial program 81.9%

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

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

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

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

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

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

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

    if -1.94999999999999991e127 < x < -1.1000000000000001e-7 or 4.1999999999999997e-111 < x < 1.85e8 or 1.45999999999999994e164 < x

    1. Initial program 90.8%

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

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

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

      \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{y}}\right| \]
    6. Taylor expanded in z around inf 61.7%

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

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

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

    if -1.1000000000000001e-7 < x < 4.1999999999999997e-111

    1. Initial program 96.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.95 \cdot 10^{+127}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.1 \cdot 10^{-7}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-111}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 185000000 \lor \neg \left(x \leq 1.46 \cdot 10^{+164}\right):\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 67.6% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \left|\frac{x}{y_m}\right|\\ t_1 := \left|z \cdot \frac{x}{y_m}\right|\\ \mathbf{if}\;x \leq -6.5 \cdot 10^{+127}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.85 \cdot 10^{-7}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-111}:\\ \;\;\;\;\left|\frac{4}{y_m}\right|\\ \mathbf{elif}\;x \leq 180000000 \lor \neg \left(x \leq 3.6 \cdot 10^{+166}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (let* ((t_0 (fabs (/ x y_m))) (t_1 (fabs (* z (/ x y_m)))))
   (if (<= x -6.5e+127)
     t_0
     (if (<= x -1.85e-7)
       t_1
       (if (<= x 4.2e-111)
         (fabs (/ 4.0 y_m))
         (if (or (<= x 180000000.0) (not (<= x 3.6e+166))) t_1 t_0))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = fabs((x / y_m));
	double t_1 = fabs((z * (x / y_m)));
	double tmp;
	if (x <= -6.5e+127) {
		tmp = t_0;
	} else if (x <= -1.85e-7) {
		tmp = t_1;
	} else if (x <= 4.2e-111) {
		tmp = fabs((4.0 / y_m));
	} else if ((x <= 180000000.0) || !(x <= 3.6e+166)) {
		tmp = t_1;
	} else {
		tmp = 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 = abs((x / y_m))
    t_1 = abs((z * (x / y_m)))
    if (x <= (-6.5d+127)) then
        tmp = t_0
    else if (x <= (-1.85d-7)) then
        tmp = t_1
    else if (x <= 4.2d-111) then
        tmp = abs((4.0d0 / y_m))
    else if ((x <= 180000000.0d0) .or. (.not. (x <= 3.6d+166))) then
        tmp = t_1
    else
        tmp = 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 = Math.abs((x / y_m));
	double t_1 = Math.abs((z * (x / y_m)));
	double tmp;
	if (x <= -6.5e+127) {
		tmp = t_0;
	} else if (x <= -1.85e-7) {
		tmp = t_1;
	} else if (x <= 4.2e-111) {
		tmp = Math.abs((4.0 / y_m));
	} else if ((x <= 180000000.0) || !(x <= 3.6e+166)) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	t_0 = math.fabs((x / y_m))
	t_1 = math.fabs((z * (x / y_m)))
	tmp = 0
	if x <= -6.5e+127:
		tmp = t_0
	elif x <= -1.85e-7:
		tmp = t_1
	elif x <= 4.2e-111:
		tmp = math.fabs((4.0 / y_m))
	elif (x <= 180000000.0) or not (x <= 3.6e+166):
		tmp = t_1
	else:
		tmp = t_0
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	t_0 = abs(Float64(x / y_m))
	t_1 = abs(Float64(z * Float64(x / y_m)))
	tmp = 0.0
	if (x <= -6.5e+127)
		tmp = t_0;
	elseif (x <= -1.85e-7)
		tmp = t_1;
	elseif (x <= 4.2e-111)
		tmp = abs(Float64(4.0 / y_m));
	elseif ((x <= 180000000.0) || !(x <= 3.6e+166))
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	t_0 = abs((x / y_m));
	t_1 = abs((z * (x / y_m)));
	tmp = 0.0;
	if (x <= -6.5e+127)
		tmp = t_0;
	elseif (x <= -1.85e-7)
		tmp = t_1;
	elseif (x <= 4.2e-111)
		tmp = abs((4.0 / y_m));
	elseif ((x <= 180000000.0) || ~((x <= 3.6e+166)))
		tmp = t_1;
	else
		tmp = t_0;
	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]}, Block[{t$95$1 = N[Abs[N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -6.5e+127], t$95$0, If[LessEqual[x, -1.85e-7], t$95$1, If[LessEqual[x, 4.2e-111], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 180000000.0], N[Not[LessEqual[x, 3.6e+166]], $MachinePrecision]], t$95$1, t$95$0]]]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := \left|\frac{x}{y_m}\right|\\
t_1 := \left|z \cdot \frac{x}{y_m}\right|\\
\mathbf{if}\;x \leq -6.5 \cdot 10^{+127}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -1.85 \cdot 10^{-7}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 4.2 \cdot 10^{-111}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\

\mathbf{elif}\;x \leq 180000000 \lor \neg \left(x \leq 3.6 \cdot 10^{+166}\right):\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -6.5e127 or 1.8e8 < x < 3.5999999999999997e166

    1. Initial program 81.9%

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

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

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

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

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

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

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

    if -6.5e127 < x < -1.85000000000000002e-7 or 4.1999999999999997e-111 < x < 1.8e8 or 3.5999999999999997e166 < x

    1. Initial program 90.8%

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

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

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

      \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{y}}\right| \]
    6. Taylor expanded in z around inf 61.7%

      \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}}\right| \]
    7. Step-by-step derivation
      1. associate-*l/75.1%

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

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

    if -1.85000000000000002e-7 < x < 4.1999999999999997e-111

    1. Initial program 96.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{+127}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.85 \cdot 10^{-7}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-111}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 180000000 \lor \neg \left(x \leq 3.6 \cdot 10^{+166}\right):\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 67.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \left|\frac{x}{y_m}\right|\\
t_1 := \left|z \cdot \frac{x}{y_m}\right|\\
\mathbf{if}\;x \leq -7 \cdot 10^{+127}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -1.85 \cdot 10^{-7}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 3.8 \cdot 10^{-112}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\

\mathbf{elif}\;x \leq 5000000:\\
\;\;\;\;\left|\frac{x \cdot z}{y_m}\right|\\

\mathbf{elif}\;x \leq 6.5 \cdot 10^{+166}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -6.99999999999999956e127 or 5e6 < x < 6.5000000000000005e166

    1. Initial program 81.9%

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

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

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

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

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

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

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

    if -6.99999999999999956e127 < x < -1.85000000000000002e-7 or 6.5000000000000005e166 < x

    1. Initial program 88.0%

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

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

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

      \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{y}}\right| \]
    6. Taylor expanded in z around inf 58.4%

      \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}}\right| \]
    7. Step-by-step derivation
      1. associate-*l/77.8%

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

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

    if -1.85000000000000002e-7 < x < 3.79999999999999995e-112

    1. Initial program 96.8%

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

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

    if 3.79999999999999995e-112 < x < 5e6

    1. Initial program 97.9%

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

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

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

      \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{y}}\right| \]
    6. Taylor expanded in z around inf 70.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7 \cdot 10^{+127}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.85 \cdot 10^{-7}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{-112}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 5000000:\\ \;\;\;\;\left|\frac{x \cdot z}{y}\right|\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{+166}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 84.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.75 \cdot 10^{-7} \lor \neg \left(x \leq 4.2 \cdot 10^{-111}\right):\\
\;\;\;\;\left|x \cdot \left(\frac{z}{y_m} + \frac{-1}{y_m}\right)\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.74999999999999992e-7 or 4.1999999999999997e-111 < x

    1. Initial program 86.6%

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

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

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

    if -1.74999999999999992e-7 < x < 4.1999999999999997e-111

    1. Initial program 96.8%

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{\color{blue}{-4 - x}}{y}\right| \]
    6. Simplified83.2%

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

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

Alternative 7: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+40} \lor \neg \left(x \leq 75000000000000\right):\\ \;\;\;\;\left|x \cdot \left(\frac{z}{y_m} + \frac{-1}{y_m}\right)\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
 (if (or (<= x -1e+40) (not (<= x 75000000000000.0)))
   (fabs (* x (+ (/ z y_m) (/ -1.0 y_m))))
   (fabs (/ (- (+ x 4.0) (* x z)) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if ((x <= -1e+40) || !(x <= 75000000000000.0)) {
		tmp = fabs((x * ((z / y_m) + (-1.0 / y_m))));
	} 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) :: tmp
    if ((x <= (-1d+40)) .or. (.not. (x <= 75000000000000.0d0))) then
        tmp = abs((x * ((z / y_m) + ((-1.0d0) / y_m))))
    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 tmp;
	if ((x <= -1e+40) || !(x <= 75000000000000.0)) {
		tmp = Math.abs((x * ((z / y_m) + (-1.0 / y_m))));
	} else {
		tmp = Math.abs((((x + 4.0) - (x * z)) / y_m));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if (x <= -1e+40) or not (x <= 75000000000000.0):
		tmp = math.fabs((x * ((z / y_m) + (-1.0 / y_m))))
	else:
		tmp = math.fabs((((x + 4.0) - (x * z)) / y_m))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if ((x <= -1e+40) || !(x <= 75000000000000.0))
		tmp = abs(Float64(x * Float64(Float64(z / y_m) + Float64(-1.0 / y_m))));
	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)
	tmp = 0.0;
	if ((x <= -1e+40) || ~((x <= 75000000000000.0)))
		tmp = abs((x * ((z / y_m) + (-1.0 / y_m))));
	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_] := If[Or[LessEqual[x, -1e+40], N[Not[LessEqual[x, 75000000000000.0]], $MachinePrecision]], N[Abs[N[(x * N[(N[(z / y$95$m), $MachinePrecision] + N[(-1.0 / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $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}
\mathbf{if}\;x \leq -1 \cdot 10^{+40} \lor \neg \left(x \leq 75000000000000\right):\\
\;\;\;\;\left|x \cdot \left(\frac{z}{y_m} + \frac{-1}{y_m}\right)\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 x < -1.00000000000000003e40 or 7.5e13 < x

    1. Initial program 83.2%

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

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

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

    if -1.00000000000000003e40 < x < 7.5e13

    1. Initial program 97.2%

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

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

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

Alternative 8: 85.0% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -1.14 \cdot 10^{-7} \lor \neg \left(x \leq 4.2 \cdot 10^{-111}\right):\\ \;\;\;\;\left|\frac{z + -1}{\frac{y_m}{x}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x - -4}{y_m}\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (or (<= x -1.14e-7) (not (<= x 4.2e-111)))
   (fabs (/ (+ z -1.0) (/ y_m x)))
   (fabs (/ (- x -4.0) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if ((x <= -1.14e-7) || !(x <= 4.2e-111)) {
		tmp = fabs(((z + -1.0) / (y_m / x)));
	} else {
		tmp = fabs(((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 <= (-1.14d-7)) .or. (.not. (x <= 4.2d-111))) then
        tmp = abs(((z + (-1.0d0)) / (y_m / x)))
    else
        tmp = abs(((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 <= -1.14e-7) || !(x <= 4.2e-111)) {
		tmp = Math.abs(((z + -1.0) / (y_m / x)));
	} else {
		tmp = Math.abs(((x - -4.0) / y_m));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if (x <= -1.14e-7) or not (x <= 4.2e-111):
		tmp = math.fabs(((z + -1.0) / (y_m / x)))
	else:
		tmp = math.fabs(((x - -4.0) / y_m))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if ((x <= -1.14e-7) || !(x <= 4.2e-111))
		tmp = abs(Float64(Float64(z + -1.0) / Float64(y_m / x)));
	else
		tmp = abs(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 <= -1.14e-7) || ~((x <= 4.2e-111)))
		tmp = abs(((z + -1.0) / (y_m / x)));
	else
		tmp = abs(((x - -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, -1.14e-7], N[Not[LessEqual[x, 4.2e-111]], $MachinePrecision]], N[Abs[N[(N[(z + -1.0), $MachinePrecision] / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x - -4.0), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.14 \cdot 10^{-7} \lor \neg \left(x \leq 4.2 \cdot 10^{-111}\right):\\
\;\;\;\;\left|\frac{z + -1}{\frac{y_m}{x}}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.14000000000000002e-7 or 4.1999999999999997e-111 < x

    1. Initial program 86.6%

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

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

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

      \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{y}}\right| \]
    6. Taylor expanded in x around inf 85.6%

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{z + -1}{\frac{y}{x}}}\right| \]
    8. Simplified93.9%

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

    if -1.14000000000000002e-7 < x < 4.1999999999999997e-111

    1. Initial program 96.8%

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{\color{blue}{-4 - x}}{y}\right| \]
    6. Simplified83.2%

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

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

Alternative 9: 85.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -180000000000:\\
\;\;\;\;\left|x \cdot \frac{z}{y_m}\right|\\

\mathbf{elif}\;z \leq 1.8 \cdot 10^{+30}:\\
\;\;\;\;\left|\frac{x - -4}{y_m}\right|\\

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


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

    1. Initial program 96.0%

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

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

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

      \[\leadsto \left|\color{blue}{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{y}}\right| \]
    6. Taylor expanded in z around inf 67.8%

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

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

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

    if -1.8e11 < z < 1.8000000000000001e30

    1. Initial program 91.8%

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

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

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

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

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

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

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

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

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

    if 1.8000000000000001e30 < z

    1. Initial program 83.3%

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}}\right| \]
    7. Step-by-step derivation
      1. associate-*l/76.4%

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

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

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

Alternative 10: 69.0% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -10.2 \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 -10.2) (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 <= -10.2) || !(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 <= (-10.2d0)) .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 <= -10.2) || !(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 <= -10.2) 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 <= -10.2) || !(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 <= -10.2) || ~((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, -10.2], 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 -10.2 \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 < -10.199999999999999 or 4 < x

    1. Initial program 84.7%

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

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

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

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

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

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

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

    if -10.199999999999999 < x < 4

    1. Initial program 96.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -10.2 \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 11: 40.3% 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 90.7%

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

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

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

Reproduce

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