fabs fraction 1

Percentage Accurate: 91.7% → 99.8%
Time: 8.1s
Alternatives: 11
Speedup: 0.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

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

Alternative 1: 99.8% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 88.4%

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

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

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

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

    if 2.00000000000000002e-35 < y

    1. Initial program 96.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.7% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 91.1%

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

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

    if 1.9999999999999998e-93 < (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)))

    1. Initial program 90.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 98.8% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 91.1%

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

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

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

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

    if 1.9999999999999998e-93 < (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)))

    1. Initial program 90.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 69.1% accurate, 0.8× 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^{+161}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -1.08 \cdot 10^{-51}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 0.0056:\\ \;\;\;\;\left|\frac{4}{y\_m}\right|\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{+51} \lor \neg \left(x \leq 1.1 \cdot 10^{+85}\right) \land \left(x \leq 5.6 \cdot 10^{+136} \lor \neg \left(x \leq 5.5 \cdot 10^{+213}\right) \land x \leq 1.45 \cdot 10^{+233}\right):\\ \;\;\;\;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 -6.5e+161)
     t_0
     (if (<= x -1.08e-51)
       t_1
       (if (<= x 0.0056)
         (fabs (/ 4.0 y_m))
         (if (or (<= x 1.1e+51)
                 (and (not (<= x 1.1e+85))
                      (or (<= x 5.6e+136)
                          (and (not (<= x 5.5e+213)) (<= x 1.45e+233)))))
           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 <= -6.5e+161) {
		tmp = t_0;
	} else if (x <= -1.08e-51) {
		tmp = t_1;
	} else if (x <= 0.0056) {
		tmp = fabs((4.0 / y_m));
	} else if ((x <= 1.1e+51) || (!(x <= 1.1e+85) && ((x <= 5.6e+136) || (!(x <= 5.5e+213) && (x <= 1.45e+233))))) {
		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 <= (-6.5d+161)) then
        tmp = t_0
    else if (x <= (-1.08d-51)) then
        tmp = t_1
    else if (x <= 0.0056d0) then
        tmp = abs((4.0d0 / y_m))
    else if ((x <= 1.1d+51) .or. (.not. (x <= 1.1d+85)) .and. (x <= 5.6d+136) .or. (.not. (x <= 5.5d+213)) .and. (x <= 1.45d+233)) 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 <= -6.5e+161) {
		tmp = t_0;
	} else if (x <= -1.08e-51) {
		tmp = t_1;
	} else if (x <= 0.0056) {
		tmp = Math.abs((4.0 / y_m));
	} else if ((x <= 1.1e+51) || (!(x <= 1.1e+85) && ((x <= 5.6e+136) || (!(x <= 5.5e+213) && (x <= 1.45e+233))))) {
		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 <= -6.5e+161:
		tmp = t_0
	elif x <= -1.08e-51:
		tmp = t_1
	elif x <= 0.0056:
		tmp = math.fabs((4.0 / y_m))
	elif (x <= 1.1e+51) or (not (x <= 1.1e+85) and ((x <= 5.6e+136) or (not (x <= 5.5e+213) and (x <= 1.45e+233)))):
		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 <= -6.5e+161)
		tmp = t_0;
	elseif (x <= -1.08e-51)
		tmp = t_1;
	elseif (x <= 0.0056)
		tmp = abs(Float64(4.0 / y_m));
	elseif ((x <= 1.1e+51) || (!(x <= 1.1e+85) && ((x <= 5.6e+136) || (!(x <= 5.5e+213) && (x <= 1.45e+233)))))
		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 <= -6.5e+161)
		tmp = t_0;
	elseif (x <= -1.08e-51)
		tmp = t_1;
	elseif (x <= 0.0056)
		tmp = abs((4.0 / y_m));
	elseif ((x <= 1.1e+51) || (~((x <= 1.1e+85)) && ((x <= 5.6e+136) || (~((x <= 5.5e+213)) && (x <= 1.45e+233)))))
		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, -6.5e+161], t$95$0, If[LessEqual[x, -1.08e-51], t$95$1, If[LessEqual[x, 0.0056], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 1.1e+51], And[N[Not[LessEqual[x, 1.1e+85]], $MachinePrecision], Or[LessEqual[x, 5.6e+136], And[N[Not[LessEqual[x, 5.5e+213]], $MachinePrecision], LessEqual[x, 1.45e+233]]]]], 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 -6.5 \cdot 10^{+161}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -1.08 \cdot 10^{-51}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;x \leq 1.1 \cdot 10^{+51} \lor \neg \left(x \leq 1.1 \cdot 10^{+85}\right) \land \left(x \leq 5.6 \cdot 10^{+136} \lor \neg \left(x \leq 5.5 \cdot 10^{+213}\right) \land x \leq 1.45 \cdot 10^{+233}\right):\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -6.5e161 or 0.00559999999999999994 < x < 1.09999999999999996e51 or 1.1000000000000001e85 < x < 5.6000000000000004e136 or 5.50000000000000059e213 < x < 1.45000000000000006e233

    1. Initial program 90.1%

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

      \[\leadsto \left|\color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}}\right| \]
    4. Taylor expanded in x around inf 69.9%

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

    if -6.5e161 < x < -1.08000000000000004e-51 or 1.09999999999999996e51 < x < 1.1000000000000001e85 or 5.6000000000000004e136 < x < 5.50000000000000059e213 or 1.45000000000000006e233 < x

    1. Initial program 82.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.08000000000000004e-51 < x < 0.00559999999999999994

    1. Initial program 96.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{+161}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.08 \cdot 10^{-51}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 0.0056:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{+51} \lor \neg \left(x \leq 1.1 \cdot 10^{+85}\right) \land \left(x \leq 5.6 \cdot 10^{+136} \lor \neg \left(x \leq 5.5 \cdot 10^{+213}\right) \land x \leq 1.45 \cdot 10^{+233}\right):\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 69.0% accurate, 0.8× 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^{+158}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -9.8 \cdot 10^{-52}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 0.0056:\\ \;\;\;\;\left|\frac{4}{y\_m}\right|\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{+53}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 8 \cdot 10^{+85}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{+132}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{+213}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{+232}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{z}{\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 (/ x y_m))) (t_1 (fabs (* z (/ x y_m)))))
   (if (<= x -6.5e+158)
     t_0
     (if (<= x -9.8e-52)
       t_1
       (if (<= x 0.0056)
         (fabs (/ 4.0 y_m))
         (if (<= x 1.3e+53)
           t_0
           (if (<= x 8e+85)
             t_1
             (if (<= x 1.4e+132)
               t_0
               (if (<= x 6.8e+213)
                 t_1
                 (if (<= x 4.8e+232) t_0 (fabs (/ z (/ y_m x)))))))))))))
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+158) {
		tmp = t_0;
	} else if (x <= -9.8e-52) {
		tmp = t_1;
	} else if (x <= 0.0056) {
		tmp = fabs((4.0 / y_m));
	} else if (x <= 1.3e+53) {
		tmp = t_0;
	} else if (x <= 8e+85) {
		tmp = t_1;
	} else if (x <= 1.4e+132) {
		tmp = t_0;
	} else if (x <= 6.8e+213) {
		tmp = t_1;
	} else if (x <= 4.8e+232) {
		tmp = t_0;
	} else {
		tmp = fabs((z / (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) :: t_1
    real(8) :: tmp
    t_0 = abs((x / y_m))
    t_1 = abs((z * (x / y_m)))
    if (x <= (-6.5d+158)) then
        tmp = t_0
    else if (x <= (-9.8d-52)) then
        tmp = t_1
    else if (x <= 0.0056d0) then
        tmp = abs((4.0d0 / y_m))
    else if (x <= 1.3d+53) then
        tmp = t_0
    else if (x <= 8d+85) then
        tmp = t_1
    else if (x <= 1.4d+132) then
        tmp = t_0
    else if (x <= 6.8d+213) then
        tmp = t_1
    else if (x <= 4.8d+232) then
        tmp = t_0
    else
        tmp = abs((z / (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((x / y_m));
	double t_1 = Math.abs((z * (x / y_m)));
	double tmp;
	if (x <= -6.5e+158) {
		tmp = t_0;
	} else if (x <= -9.8e-52) {
		tmp = t_1;
	} else if (x <= 0.0056) {
		tmp = Math.abs((4.0 / y_m));
	} else if (x <= 1.3e+53) {
		tmp = t_0;
	} else if (x <= 8e+85) {
		tmp = t_1;
	} else if (x <= 1.4e+132) {
		tmp = t_0;
	} else if (x <= 6.8e+213) {
		tmp = t_1;
	} else if (x <= 4.8e+232) {
		tmp = t_0;
	} else {
		tmp = Math.abs((z / (y_m / x)));
	}
	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+158:
		tmp = t_0
	elif x <= -9.8e-52:
		tmp = t_1
	elif x <= 0.0056:
		tmp = math.fabs((4.0 / y_m))
	elif x <= 1.3e+53:
		tmp = t_0
	elif x <= 8e+85:
		tmp = t_1
	elif x <= 1.4e+132:
		tmp = t_0
	elif x <= 6.8e+213:
		tmp = t_1
	elif x <= 4.8e+232:
		tmp = t_0
	else:
		tmp = math.fabs((z / (y_m / x)))
	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+158)
		tmp = t_0;
	elseif (x <= -9.8e-52)
		tmp = t_1;
	elseif (x <= 0.0056)
		tmp = abs(Float64(4.0 / y_m));
	elseif (x <= 1.3e+53)
		tmp = t_0;
	elseif (x <= 8e+85)
		tmp = t_1;
	elseif (x <= 1.4e+132)
		tmp = t_0;
	elseif (x <= 6.8e+213)
		tmp = t_1;
	elseif (x <= 4.8e+232)
		tmp = t_0;
	else
		tmp = abs(Float64(z / Float64(y_m / x)));
	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+158)
		tmp = t_0;
	elseif (x <= -9.8e-52)
		tmp = t_1;
	elseif (x <= 0.0056)
		tmp = abs((4.0 / y_m));
	elseif (x <= 1.3e+53)
		tmp = t_0;
	elseif (x <= 8e+85)
		tmp = t_1;
	elseif (x <= 1.4e+132)
		tmp = t_0;
	elseif (x <= 6.8e+213)
		tmp = t_1;
	elseif (x <= 4.8e+232)
		tmp = t_0;
	else
		tmp = abs((z / (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[(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+158], t$95$0, If[LessEqual[x, -9.8e-52], t$95$1, If[LessEqual[x, 0.0056], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.3e+53], t$95$0, If[LessEqual[x, 8e+85], t$95$1, If[LessEqual[x, 1.4e+132], t$95$0, If[LessEqual[x, 6.8e+213], t$95$1, If[LessEqual[x, 4.8e+232], t$95$0, N[Abs[N[(z / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]]]]]
\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^{+158}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -9.8 \cdot 10^{-52}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;x \leq 1.3 \cdot 10^{+53}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 8 \cdot 10^{+85}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 1.4 \cdot 10^{+132}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 6.8 \cdot 10^{+213}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 4.8 \cdot 10^{+232}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -6.5000000000000001e158 or 0.00559999999999999994 < x < 1.29999999999999999e53 or 8.0000000000000001e85 < x < 1.4e132 or 6.79999999999999983e213 < x < 4.8000000000000003e232

    1. Initial program 90.1%

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

      \[\leadsto \left|\color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}}\right| \]
    4. Taylor expanded in x around inf 69.9%

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

    if -6.5000000000000001e158 < x < -9.80000000000000037e-52 or 1.29999999999999999e53 < x < 8.0000000000000001e85 or 1.4e132 < x < 6.79999999999999983e213

    1. Initial program 87.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.80000000000000037e-52 < x < 0.00559999999999999994

    1. Initial program 96.6%

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

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

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

    if 4.8000000000000003e232 < x

    1. Initial program 64.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 81.3% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \left|\frac{x \cdot z}{y\_m}\right|\\ t_1 := \left|\frac{-4 - x}{y\_m}\right|\\ \mathbf{if}\;z \leq -2.05 \cdot 10^{+197}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 2.35 \cdot 10^{+112}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 7 \cdot 10^{+163}:\\ \;\;\;\;\left|x \cdot \frac{z}{y\_m}\right|\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{+178}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{+259}:\\ \;\;\;\;\left|z \cdot \frac{x}{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 z) y_m))) (t_1 (fabs (/ (- -4.0 x) y_m))))
   (if (<= z -2.05e+197)
     t_0
     (if (<= z 2.35e+112)
       t_1
       (if (<= z 7e+163)
         (fabs (* x (/ z y_m)))
         (if (<= z 4.5e+178)
           t_1
           (if (<= z 6.2e+259) (fabs (* z (/ x y_m))) t_0)))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = fabs(((x * z) / y_m));
	double t_1 = fabs(((-4.0 - x) / y_m));
	double tmp;
	if (z <= -2.05e+197) {
		tmp = t_0;
	} else if (z <= 2.35e+112) {
		tmp = t_1;
	} else if (z <= 7e+163) {
		tmp = fabs((x * (z / y_m)));
	} else if (z <= 4.5e+178) {
		tmp = t_1;
	} else if (z <= 6.2e+259) {
		tmp = fabs((z * (x / 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) :: t_1
    real(8) :: tmp
    t_0 = abs(((x * z) / y_m))
    t_1 = abs((((-4.0d0) - x) / y_m))
    if (z <= (-2.05d+197)) then
        tmp = t_0
    else if (z <= 2.35d+112) then
        tmp = t_1
    else if (z <= 7d+163) then
        tmp = abs((x * (z / y_m)))
    else if (z <= 4.5d+178) then
        tmp = t_1
    else if (z <= 6.2d+259) then
        tmp = abs((z * (x / 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 * z) / y_m));
	double t_1 = Math.abs(((-4.0 - x) / y_m));
	double tmp;
	if (z <= -2.05e+197) {
		tmp = t_0;
	} else if (z <= 2.35e+112) {
		tmp = t_1;
	} else if (z <= 7e+163) {
		tmp = Math.abs((x * (z / y_m)));
	} else if (z <= 4.5e+178) {
		tmp = t_1;
	} else if (z <= 6.2e+259) {
		tmp = Math.abs((z * (x / y_m)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	t_0 = math.fabs(((x * z) / y_m))
	t_1 = math.fabs(((-4.0 - x) / y_m))
	tmp = 0
	if z <= -2.05e+197:
		tmp = t_0
	elif z <= 2.35e+112:
		tmp = t_1
	elif z <= 7e+163:
		tmp = math.fabs((x * (z / y_m)))
	elif z <= 4.5e+178:
		tmp = t_1
	elif z <= 6.2e+259:
		tmp = math.fabs((z * (x / y_m)))
	else:
		tmp = t_0
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	t_0 = abs(Float64(Float64(x * z) / y_m))
	t_1 = abs(Float64(Float64(-4.0 - x) / y_m))
	tmp = 0.0
	if (z <= -2.05e+197)
		tmp = t_0;
	elseif (z <= 2.35e+112)
		tmp = t_1;
	elseif (z <= 7e+163)
		tmp = abs(Float64(x * Float64(z / y_m)));
	elseif (z <= 4.5e+178)
		tmp = t_1;
	elseif (z <= 6.2e+259)
		tmp = abs(Float64(z * Float64(x / 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 * z) / y_m));
	t_1 = abs(((-4.0 - x) / y_m));
	tmp = 0.0;
	if (z <= -2.05e+197)
		tmp = t_0;
	elseif (z <= 2.35e+112)
		tmp = t_1;
	elseif (z <= 7e+163)
		tmp = abs((x * (z / y_m)));
	elseif (z <= 4.5e+178)
		tmp = t_1;
	elseif (z <= 6.2e+259)
		tmp = abs((z * (x / 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[(N[(x * z), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[z, -2.05e+197], t$95$0, If[LessEqual[z, 2.35e+112], t$95$1, If[LessEqual[z, 7e+163], N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 4.5e+178], t$95$1, If[LessEqual[z, 6.2e+259], N[Abs[N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
y_m = \left|y\right|

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

\mathbf{elif}\;z \leq 2.35 \cdot 10^{+112}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;z \leq 4.5 \cdot 10^{+178}:\\
\;\;\;\;t\_1\\

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -2.05000000000000015e197 or 6.2000000000000007e259 < z

    1. Initial program 81.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.05000000000000015e197 < z < 2.34999999999999999e112 or 7.0000000000000005e163 < z < 4.4999999999999997e178

    1. Initial program 92.4%

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

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

      \[\leadsto \left|\color{blue}{\frac{4 + x}{y}}\right| \]
    5. Step-by-step derivation
      1. +-commutative84.3%

        \[\leadsto \left|\frac{\color{blue}{x + 4}}{y}\right| \]
      2. rem-square-sqrt49.0%

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

        \[\leadsto \left|\color{blue}{\left|\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}\right|}\right| \]
      4. rem-square-sqrt84.3%

        \[\leadsto \left|\left|\color{blue}{\frac{x + 4}{y}}\right|\right| \]
      5. fabs-neg84.3%

        \[\leadsto \left|\color{blue}{\left|-\frac{x + 4}{y}\right|}\right| \]
      6. distribute-neg-frac84.3%

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

        \[\leadsto \left|\left|\frac{\color{blue}{\left(-x\right) + \left(-4\right)}}{y}\right|\right| \]
      8. metadata-eval84.3%

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

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

        \[\leadsto \left|\left|\frac{\color{blue}{-4 - x}}{y}\right|\right| \]
      11. rem-square-sqrt34.8%

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

        \[\leadsto \left|\color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}}\right| \]
      13. rem-square-sqrt84.3%

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

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

    if 2.34999999999999999e112 < z < 7.0000000000000005e163

    1. Initial program 76.6%

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{x \cdot \left(-z\right)}{y}}\right| \]
    7. Step-by-step derivation
      1. distribute-rgt-neg-out65.3%

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{z}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}} \cdot x\right| \]
      10. add-sqr-sqrt94.6%

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

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

    if 4.4999999999999997e178 < z < 6.2000000000000007e259

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.05 \cdot 10^{+197}:\\ \;\;\;\;\left|\frac{x \cdot z}{y}\right|\\ \mathbf{elif}\;z \leq 2.35 \cdot 10^{+112}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{elif}\;z \leq 7 \cdot 10^{+163}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{+178}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{+259}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x \cdot z}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 99.2% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+87} \lor \neg \left(x \leq 0.0056\right):\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y\_m}\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+87) (not (<= x 0.0056)))
   (fabs (* x (/ (- 1.0 z) 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+87) || !(x <= 0.0056)) {
		tmp = fabs((x * ((1.0 - z) / 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+87)) .or. (.not. (x <= 0.0056d0))) then
        tmp = abs((x * ((1.0d0 - z) / 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+87) || !(x <= 0.0056)) {
		tmp = Math.abs((x * ((1.0 - z) / 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+87) or not (x <= 0.0056):
		tmp = math.fabs((x * ((1.0 - z) / 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+87) || !(x <= 0.0056))
		tmp = abs(Float64(x * Float64(Float64(1.0 - z) / 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+87) || ~((x <= 0.0056)))
		tmp = abs((x * ((1.0 - z) / 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+87], N[Not[LessEqual[x, 0.0056]], $MachinePrecision]], N[Abs[N[(x * N[(N[(1.0 - z), $MachinePrecision] / y$95$m), $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^{+87} \lor \neg \left(x \leq 0.0056\right):\\
\;\;\;\;\left|x \cdot \frac{1 - z}{y\_m}\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 < -9.9999999999999996e86 or 0.00559999999999999994 < x

    1. Initial program 82.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.9999999999999996e86 < x < 0.00559999999999999994

    1. Initial program 96.0%

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

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

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

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

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

Alternative 8: 86.7% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.00000000000000007e-10 or 1.49999999999999994e-38 < x

    1. Initial program 85.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.00000000000000007e-10 < x < 1.49999999999999994e-38

    1. Initial program 96.5%

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

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

        \[\leadsto \left|4 \cdot \frac{1}{y} + \color{blue}{x \cdot \frac{1}{y}}\right| \]
      2. distribute-rgt-out80.4%

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

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

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

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

Alternative 9: 86.7% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{-9} \lor \neg \left(x \leq 3.4 \cdot 10^{-39}\right):\\
\;\;\;\;\left|x \cdot \frac{1 - z}{y\_m}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.6999999999999999e-9 or 3.3999999999999999e-39 < x

    1. Initial program 85.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.6999999999999999e-9 < x < 3.3999999999999999e-39

    1. Initial program 96.5%

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\left|\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}\right|}\right| \]
      4. rem-square-sqrt80.4%

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

        \[\leadsto \left|\color{blue}{\left|-\frac{x + 4}{y}\right|}\right| \]
      6. distribute-neg-frac80.4%

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

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

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

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

        \[\leadsto \left|\left|\frac{\color{blue}{-4 - x}}{y}\right|\right| \]
      11. rem-square-sqrt35.2%

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

        \[\leadsto \left|\color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}}\right| \]
      13. rem-square-sqrt80.4%

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

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

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

Alternative 10: 68.4% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -380000000000 \lor \neg \left(x \leq 1.75 \cdot 10^{-10}\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 -380000000000.0) (not (<= x 1.75e-10)))
   (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 <= -380000000000.0) || !(x <= 1.75e-10)) {
		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 <= (-380000000000.0d0)) .or. (.not. (x <= 1.75d-10))) 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 <= -380000000000.0) || !(x <= 1.75e-10)) {
		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 <= -380000000000.0) or not (x <= 1.75e-10):
		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 <= -380000000000.0) || !(x <= 1.75e-10))
		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 <= -380000000000.0) || ~((x <= 1.75e-10)))
		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, -380000000000.0], N[Not[LessEqual[x, 1.75e-10]], $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 -380000000000 \lor \neg \left(x \leq 1.75 \cdot 10^{-10}\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 < -3.8e11 or 1.7499999999999999e-10 < x

    1. Initial program 83.9%

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

      \[\leadsto \left|\color{blue}{4 \cdot \frac{1}{y} + \frac{x}{y}}\right| \]
    4. Taylor expanded in x around inf 61.1%

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

    if -3.8e11 < x < 1.7499999999999999e-10

    1. Initial program 96.9%

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

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

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

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

Alternative 11: 40.4% 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.5%

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

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

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

Reproduce

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