fabs fraction 1

Percentage Accurate: 91.6% → 99.4%
Time: 9.3s
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.4% accurate, 0.5× speedup?

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

    1. Initial program 90.5%

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

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

    if 5.0000000000000002e-85 < y

    1. Initial program 95.3%

      \[\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.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 5 \cdot 10^{-85}:\\ \;\;\;\;\left|\frac{\left(4 + x\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: 99.1% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \left|\frac{4 + x}{y_m} - z \cdot \frac{x}{y_m}\right|\\
\mathbf{if}\;t_0 \leq 10^{+69}:\\
\;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y_m}\right|\\

\mathbf{elif}\;t_0 \leq 7 \cdot 10^{+298}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{z + -1}{\frac{y_m}{x}}\right|\\


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

    1. Initial program 93.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| \]

    if 1.0000000000000001e69 < (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))) < 7.00000000000000018e298

    1. Initial program 99.9%

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

    if 7.00000000000000018e298 < (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z)))

    1. Initial program 73.3%

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

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

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

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

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

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

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

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

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

Alternative 3: 87.2% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -126000 \lor \neg \left(x \leq 4.7 \cdot 10^{-16}\right):\\ \;\;\;\;\left|x \cdot \left(\frac{z}{y_m} - \frac{1}{y_m}\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 -126000.0) (not (<= x 4.7e-16)))
   (fabs (* x (- (/ z y_m) (/ 1.0 y_m))))
   (fabs (/ (- -4.0 x) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if ((x <= -126000.0) || !(x <= 4.7e-16)) {
		tmp = fabs((x * ((z / y_m) - (1.0 / y_m))));
	} 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 <= (-126000.0d0)) .or. (.not. (x <= 4.7d-16))) then
        tmp = abs((x * ((z / y_m) - (1.0d0 / y_m))))
    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 <= -126000.0) || !(x <= 4.7e-16)) {
		tmp = Math.abs((x * ((z / y_m) - (1.0 / y_m))));
	} 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 <= -126000.0) or not (x <= 4.7e-16):
		tmp = math.fabs((x * ((z / y_m) - (1.0 / y_m))))
	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 <= -126000.0) || !(x <= 4.7e-16))
		tmp = abs(Float64(x * Float64(Float64(z / y_m) - Float64(1.0 / y_m))));
	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 <= -126000.0) || ~((x <= 4.7e-16)))
		tmp = abs((x * ((z / y_m) - (1.0 / y_m))));
	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, -126000.0], N[Not[LessEqual[x, 4.7e-16]], $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[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -126000 \lor \neg \left(x \leq 4.7 \cdot 10^{-16}\right):\\
\;\;\;\;\left|x \cdot \left(\frac{z}{y_m} - \frac{1}{y_m}\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 < -126000 or 4.70000000000000044e-16 < x

    1. Initial program 90.1%

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

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

    if -126000 < x < 4.70000000000000044e-16

    1. Initial program 93.7%

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

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

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

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

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

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

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

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

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

Alternative 4: 99.3% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.35 \cdot 10^{+107}:\\
\;\;\;\;\left|x \cdot \left(\frac{z}{y_m} - \frac{1}{y_m}\right)\right|\\

\mathbf{elif}\;x \leq 1.3 \cdot 10^{+86}:\\
\;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y_m}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|\frac{z + -1}{\frac{y_m}{x}}\right|\\


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

    1. Initial program 84.4%

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

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

    if -1.3500000000000001e107 < x < 1.2999999999999999e86

    1. Initial program 95.1%

      \[\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| \]

    if 1.2999999999999999e86 < x

    1. Initial program 87.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 87.8%

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

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

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

        \[\leadsto \left|\color{blue}{-\frac{x}{y}}\right| \]
      2. distribute-neg-frac75.2%

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

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

    if -5.9000000000000001e147 < x < -3.99999999999999984e-23

    1. Initial program 97.1%

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

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

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

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

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

    if -3.99999999999999984e-23 < x < 4

    1. Initial program 94.1%

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

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

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

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

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

\mathbf{elif}\;x \leq -3.85 \cdot 10^{-13}:\\
\;\;\;\;\left|z \cdot \frac{x}{y_m}\right|\\

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

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


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

    1. Initial program 87.8%

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

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

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

        \[\leadsto \left|\color{blue}{-\frac{x}{y}}\right| \]
      2. distribute-neg-frac75.2%

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

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

    if -8.40000000000000024e147 < x < -3.8499999999999998e-13

    1. Initial program 99.8%

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

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

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

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

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

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

    if -3.8499999999999998e-13 < x < 4

    1. Initial program 93.6%

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

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

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

Alternative 7: 87.2% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -270000 \lor \neg \left(x \leq 2.8 \cdot 10^{-18}\right):\\ \;\;\;\;\left|\frac{z + -1}{\frac{y_m}{x}}\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 -270000.0) (not (<= x 2.8e-18)))
   (fabs (/ (+ z -1.0) (/ y_m x)))
   (fabs (/ (- -4.0 x) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if ((x <= -270000.0) || !(x <= 2.8e-18)) {
		tmp = fabs(((z + -1.0) / (y_m / x)));
	} 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 <= (-270000.0d0)) .or. (.not. (x <= 2.8d-18))) then
        tmp = abs(((z + (-1.0d0)) / (y_m / x)))
    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 <= -270000.0) || !(x <= 2.8e-18)) {
		tmp = Math.abs(((z + -1.0) / (y_m / x)));
	} 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 <= -270000.0) or not (x <= 2.8e-18):
		tmp = math.fabs(((z + -1.0) / (y_m / x)))
	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 <= -270000.0) || !(x <= 2.8e-18))
		tmp = abs(Float64(Float64(z + -1.0) / Float64(y_m / x)));
	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 <= -270000.0) || ~((x <= 2.8e-18)))
		tmp = abs(((z + -1.0) / (y_m / x)));
	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, -270000.0], N[Not[LessEqual[x, 2.8e-18]], $MachinePrecision]], N[Abs[N[(N[(z + -1.0), $MachinePrecision] / N[(y$95$m / x), $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 -270000 \lor \neg \left(x \leq 2.8 \cdot 10^{-18}\right):\\
\;\;\;\;\left|\frac{z + -1}{\frac{y_m}{x}}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.7e5 or 2.80000000000000012e-18 < x

    1. Initial program 90.1%

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

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

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

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

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

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

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

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

    if -2.7e5 < x < 2.80000000000000012e-18

    1. Initial program 93.7%

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

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

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

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

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

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

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

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

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

Alternative 8: 99.8% accurate, 1.0× speedup?

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

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


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

    1. Initial program 90.8%

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

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

    if 1.60000000000000001e-49 < y

    1. Initial program 95.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-/r/99.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.8%

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

Alternative 9: 85.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{+15}:\\
\;\;\;\;\left|\frac{x}{\frac{y_m}{z}}\right|\\

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

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


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

    1. Initial program 91.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6e15 < z < 1.2e63

    1. Initial program 95.9%

      \[\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.0%

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

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

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

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

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

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

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

    if 1.2e63 < z

    1. Initial program 80.3%

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

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

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

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

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

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

Alternative 10: 68.1% accurate, 1.0× speedup?

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

    1. Initial program 90.1%

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

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

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

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

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

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

    if -10.5 < x < 4

    1. Initial program 93.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -10.5 \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: 39.8% 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 92.0%

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

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

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

Reproduce

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