fabs fraction 1

Percentage Accurate: 92.0% → 99.4%
Time: 6.2s
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: 92.0% 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 4 \cdot 10^{-91}:\\ \;\;\;\;\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 4e-91)
   (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 <= 4e-91) {
		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 <= 4e-91)
		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, 4e-91], 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 4 \cdot 10^{-91}:\\
\;\;\;\;\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 < 4.00000000000000009e-91

    1. Initial program 90.6%

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

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

    if 4.00000000000000009e-91 < y

    1. Initial program 94.3%

      \[\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. Recombined 2 regimes into one program.
  4. Final simplification97.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 4 \cdot 10^{-91}:\\ \;\;\;\;\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} \]

Alternative 2: 99.1% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t_1 \leq 10^{+304}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;\left|t_0\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.00000000000000005e-181

    1. Initial program 79.9%

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

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

    if 1.00000000000000005e-181 < (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))) < 9.9999999999999994e303

    1. Initial program 99.9%

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

    if 9.9999999999999994e303 < (fabs.f64 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z)))

    1. Initial program 72.2%

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x}{y} \cdot \left(-z\right)\right)\right)}\right| \]
      2. expm1-udef59.0%

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

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{\left(\sqrt{-z} \cdot \sqrt{-z}\right)}\right)} - 1\right| \]
      4. sqrt-unprod40.7%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}\right)} - 1\right| \]
      5. sqr-neg40.7%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \sqrt{\color{blue}{z \cdot z}}\right)} - 1\right| \]
      6. sqrt-unprod24.1%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)}\right)} - 1\right| \]
      7. add-sqr-sqrt40.7%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{z}\right)} - 1\right| \]
      8. associate-*l/37.2%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{x \cdot z}{y}}\right)} - 1\right| \]
      9. *-commutative37.2%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{\color{blue}{z \cdot x}}{y}\right)} - 1\right| \]
      10. associate-/l*40.7%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{z}{\frac{y}{x}}}\right)} - 1\right| \]
    6. Applied egg-rr40.7%

      \[\leadsto \left|\color{blue}{e^{\mathsf{log1p}\left(\frac{z}{\frac{y}{x}}\right)} - 1}\right| \]
    7. Step-by-step derivation
      1. expm1-def40.7%

        \[\leadsto \left|\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{z}{\frac{y}{x}}\right)\right)}\right| \]
      2. expm1-log1p100.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left|z \cdot \frac{x}{y} - \frac{4 + x}{y}\right| \leq 10^{-181}:\\ \;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y}\right|\\ \mathbf{elif}\;\left|z \cdot \frac{x}{y} - \frac{4 + x}{y}\right| \leq 10^{+304}:\\ \;\;\;\;\left|z \cdot \frac{x}{y} - \frac{4 + x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]

Alternative 3: 67.7% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \left|z \cdot \frac{x}{y_m}\right|\\ t_1 := \left|\frac{4}{y_m}\right|\\ \mathbf{if}\;x \leq -2.5 \cdot 10^{-16}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{-121}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-61}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{-20}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{+99} \lor \neg \left(x \leq 2.8 \cdot 10^{+186}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y_m}\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (let* ((t_0 (fabs (* z (/ x y_m)))) (t_1 (fabs (/ 4.0 y_m))))
   (if (<= x -2.5e-16)
     t_0
     (if (<= x 1.55e-121)
       t_1
       (if (<= x 8.5e-61)
         t_0
         (if (<= x 5.6e-20)
           t_1
           (if (or (<= x 1.75e+99) (not (<= x 2.8e+186)))
             t_0
             (fabs (/ x y_m)))))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = fabs((z * (x / y_m)));
	double t_1 = fabs((4.0 / y_m));
	double tmp;
	if (x <= -2.5e-16) {
		tmp = t_0;
	} else if (x <= 1.55e-121) {
		tmp = t_1;
	} else if (x <= 8.5e-61) {
		tmp = t_0;
	} else if (x <= 5.6e-20) {
		tmp = t_1;
	} else if ((x <= 1.75e+99) || !(x <= 2.8e+186)) {
		tmp = t_0;
	} else {
		tmp = fabs((x / y_m));
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = abs((z * (x / y_m)))
    t_1 = abs((4.0d0 / y_m))
    if (x <= (-2.5d-16)) then
        tmp = t_0
    else if (x <= 1.55d-121) then
        tmp = t_1
    else if (x <= 8.5d-61) then
        tmp = t_0
    else if (x <= 5.6d-20) then
        tmp = t_1
    else if ((x <= 1.75d+99) .or. (.not. (x <= 2.8d+186))) then
        tmp = t_0
    else
        tmp = abs((x / y_m))
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double t_0 = Math.abs((z * (x / y_m)));
	double t_1 = Math.abs((4.0 / y_m));
	double tmp;
	if (x <= -2.5e-16) {
		tmp = t_0;
	} else if (x <= 1.55e-121) {
		tmp = t_1;
	} else if (x <= 8.5e-61) {
		tmp = t_0;
	} else if (x <= 5.6e-20) {
		tmp = t_1;
	} else if ((x <= 1.75e+99) || !(x <= 2.8e+186)) {
		tmp = t_0;
	} else {
		tmp = Math.abs((x / y_m));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	t_0 = math.fabs((z * (x / y_m)))
	t_1 = math.fabs((4.0 / y_m))
	tmp = 0
	if x <= -2.5e-16:
		tmp = t_0
	elif x <= 1.55e-121:
		tmp = t_1
	elif x <= 8.5e-61:
		tmp = t_0
	elif x <= 5.6e-20:
		tmp = t_1
	elif (x <= 1.75e+99) or not (x <= 2.8e+186):
		tmp = t_0
	else:
		tmp = math.fabs((x / y_m))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	t_0 = abs(Float64(z * Float64(x / y_m)))
	t_1 = abs(Float64(4.0 / y_m))
	tmp = 0.0
	if (x <= -2.5e-16)
		tmp = t_0;
	elseif (x <= 1.55e-121)
		tmp = t_1;
	elseif (x <= 8.5e-61)
		tmp = t_0;
	elseif (x <= 5.6e-20)
		tmp = t_1;
	elseif ((x <= 1.75e+99) || !(x <= 2.8e+186))
		tmp = t_0;
	else
		tmp = abs(Float64(x / y_m));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	t_0 = abs((z * (x / y_m)));
	t_1 = abs((4.0 / y_m));
	tmp = 0.0;
	if (x <= -2.5e-16)
		tmp = t_0;
	elseif (x <= 1.55e-121)
		tmp = t_1;
	elseif (x <= 8.5e-61)
		tmp = t_0;
	elseif (x <= 5.6e-20)
		tmp = t_1;
	elseif ((x <= 1.75e+99) || ~((x <= 2.8e+186)))
		tmp = t_0;
	else
		tmp = abs((x / y_m));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[Abs[N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -2.5e-16], t$95$0, If[LessEqual[x, 1.55e-121], t$95$1, If[LessEqual[x, 8.5e-61], t$95$0, If[LessEqual[x, 5.6e-20], t$95$1, If[Or[LessEqual[x, 1.75e+99], N[Not[LessEqual[x, 2.8e+186]], $MachinePrecision]], t$95$0, N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]]]]]]]]
\begin{array}{l}
y_m = \left|y\right|

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

\mathbf{elif}\;x \leq 1.55 \cdot 10^{-121}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 8.5 \cdot 10^{-61}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 5.6 \cdot 10^{-20}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 1.75 \cdot 10^{+99} \lor \neg \left(x \leq 2.8 \cdot 10^{+186}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.5000000000000002e-16 or 1.5499999999999999e-121 < x < 8.50000000000000016e-61 or 5.6000000000000005e-20 < x < 1.7499999999999999e99 or 2.80000000000000018e186 < x

    1. Initial program 87.7%

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x}{y} \cdot \left(-z\right)\right)\right)}\right| \]
      2. expm1-udef39.4%

        \[\leadsto \left|\color{blue}{e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \left(-z\right)\right)} - 1}\right| \]
      3. add-sqr-sqrt19.8%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{\left(\sqrt{-z} \cdot \sqrt{-z}\right)}\right)} - 1\right| \]
      4. sqrt-unprod24.1%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}\right)} - 1\right| \]
      5. sqr-neg24.1%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \sqrt{\color{blue}{z \cdot z}}\right)} - 1\right| \]
      6. sqrt-unprod15.2%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)}\right)} - 1\right| \]
      7. add-sqr-sqrt30.8%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{z}\right)} - 1\right| \]
      8. associate-*l/27.8%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{x \cdot z}{y}}\right)} - 1\right| \]
      9. *-commutative27.8%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{\color{blue}{z \cdot x}}{y}\right)} - 1\right| \]
      10. associate-/l*30.8%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{z}{\frac{y}{x}}}\right)} - 1\right| \]
    6. Applied egg-rr30.8%

      \[\leadsto \left|\color{blue}{e^{\mathsf{log1p}\left(\frac{z}{\frac{y}{x}}\right)} - 1}\right| \]
    7. Step-by-step derivation
      1. expm1-def32.5%

        \[\leadsto \left|\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{z}{\frac{y}{x}}\right)\right)}\right| \]
      2. expm1-log1p71.8%

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

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

        \[\leadsto \left|\color{blue}{\frac{1}{\frac{\frac{y}{x}}{z}}}\right| \]
      2. associate-/r/71.7%

        \[\leadsto \left|\color{blue}{\frac{1}{\frac{y}{x}} \cdot z}\right| \]
      3. clear-num71.8%

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

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

    if -2.5000000000000002e-16 < x < 1.5499999999999999e-121 or 8.50000000000000016e-61 < x < 5.6000000000000005e-20

    1. Initial program 95.8%

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

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

    if 1.7499999999999999e99 < x < 2.80000000000000018e186

    1. Initial program 94.9%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{-16}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{-121}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-61}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{-20}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{+99} \lor \neg \left(x \leq 2.8 \cdot 10^{+186}\right):\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 4: 66.1% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \left|\frac{x}{y_m}\right|\\ t_1 := \left|x \cdot \frac{z}{y_m}\right|\\ \mathbf{if}\;x \leq -4.1 \cdot 10^{+123}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.8 \cdot 10^{-18}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-121}:\\ \;\;\;\;\left|\frac{4}{y_m}\right|\\ \mathbf{elif}\;x \leq 8 \cdot 10^{+98} \lor \neg \left(x \leq 6.8 \cdot 10^{+187}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (let* ((t_0 (fabs (/ x y_m))) (t_1 (fabs (* x (/ z y_m)))))
   (if (<= x -4.1e+123)
     t_0
     (if (<= x -3.8e-18)
       t_1
       (if (<= x 2.5e-121)
         (fabs (/ 4.0 y_m))
         (if (or (<= x 8e+98) (not (<= x 6.8e+187))) t_1 t_0))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = fabs((x / y_m));
	double t_1 = fabs((x * (z / y_m)));
	double tmp;
	if (x <= -4.1e+123) {
		tmp = t_0;
	} else if (x <= -3.8e-18) {
		tmp = t_1;
	} else if (x <= 2.5e-121) {
		tmp = fabs((4.0 / y_m));
	} else if ((x <= 8e+98) || !(x <= 6.8e+187)) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = abs((x / y_m))
    t_1 = abs((x * (z / y_m)))
    if (x <= (-4.1d+123)) then
        tmp = t_0
    else if (x <= (-3.8d-18)) then
        tmp = t_1
    else if (x <= 2.5d-121) then
        tmp = abs((4.0d0 / y_m))
    else if ((x <= 8d+98) .or. (.not. (x <= 6.8d+187))) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double t_0 = Math.abs((x / y_m));
	double t_1 = Math.abs((x * (z / y_m)));
	double tmp;
	if (x <= -4.1e+123) {
		tmp = t_0;
	} else if (x <= -3.8e-18) {
		tmp = t_1;
	} else if (x <= 2.5e-121) {
		tmp = Math.abs((4.0 / y_m));
	} else if ((x <= 8e+98) || !(x <= 6.8e+187)) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	t_0 = math.fabs((x / y_m))
	t_1 = math.fabs((x * (z / y_m)))
	tmp = 0
	if x <= -4.1e+123:
		tmp = t_0
	elif x <= -3.8e-18:
		tmp = t_1
	elif x <= 2.5e-121:
		tmp = math.fabs((4.0 / y_m))
	elif (x <= 8e+98) or not (x <= 6.8e+187):
		tmp = t_1
	else:
		tmp = t_0
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	t_0 = abs(Float64(x / y_m))
	t_1 = abs(Float64(x * Float64(z / y_m)))
	tmp = 0.0
	if (x <= -4.1e+123)
		tmp = t_0;
	elseif (x <= -3.8e-18)
		tmp = t_1;
	elseif (x <= 2.5e-121)
		tmp = abs(Float64(4.0 / y_m));
	elseif ((x <= 8e+98) || !(x <= 6.8e+187))
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	t_0 = abs((x / y_m));
	t_1 = abs((x * (z / y_m)));
	tmp = 0.0;
	if (x <= -4.1e+123)
		tmp = t_0;
	elseif (x <= -3.8e-18)
		tmp = t_1;
	elseif (x <= 2.5e-121)
		tmp = abs((4.0 / y_m));
	elseif ((x <= 8e+98) || ~((x <= 6.8e+187)))
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -4.1e+123], t$95$0, If[LessEqual[x, -3.8e-18], t$95$1, If[LessEqual[x, 2.5e-121], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 8e+98], N[Not[LessEqual[x, 6.8e+187]], $MachinePrecision]], t$95$1, t$95$0]]]]]]
\begin{array}{l}
y_m = \left|y\right|

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

\mathbf{elif}\;x \leq -3.8 \cdot 10^{-18}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x \leq 8 \cdot 10^{+98} \lor \neg \left(x \leq 6.8 \cdot 10^{+187}\right):\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -4.09999999999999989e123 or 7.99999999999999998e98 < x < 6.7999999999999999e187

    1. Initial program 87.2%

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

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

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

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

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

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

    if -4.09999999999999989e123 < x < -3.7999999999999998e-18 or 2.49999999999999995e-121 < x < 7.99999999999999998e98 or 6.7999999999999999e187 < x

    1. Initial program 89.5%

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x}{y} \cdot \left(-z\right)\right)\right)}\right| \]
      2. expm1-udef35.2%

        \[\leadsto \left|\color{blue}{e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \left(-z\right)\right)} - 1}\right| \]
      3. add-sqr-sqrt18.4%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{\left(\sqrt{-z} \cdot \sqrt{-z}\right)}\right)} - 1\right| \]
      4. sqrt-unprod27.0%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}\right)} - 1\right| \]
      5. sqr-neg27.0%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \sqrt{\color{blue}{z \cdot z}}\right)} - 1\right| \]
      6. sqrt-unprod18.5%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)}\right)} - 1\right| \]
      7. add-sqr-sqrt34.5%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{z}\right)} - 1\right| \]
      8. associate-*l/31.6%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{x \cdot z}{y}}\right)} - 1\right| \]
      9. *-commutative31.6%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{\color{blue}{z \cdot x}}{y}\right)} - 1\right| \]
      10. associate-/l*34.5%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{z}{\frac{y}{x}}}\right)} - 1\right| \]
    6. Applied egg-rr34.5%

      \[\leadsto \left|\color{blue}{e^{\mathsf{log1p}\left(\frac{z}{\frac{y}{x}}\right)} - 1}\right| \]
    7. Step-by-step derivation
      1. expm1-def36.6%

        \[\leadsto \left|\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{z}{\frac{y}{x}}\right)\right)}\right| \]
      2. expm1-log1p70.9%

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

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

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

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

    if -3.7999999999999998e-18 < x < 2.49999999999999995e-121

    1. Initial program 96.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.1 \cdot 10^{+123}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -3.8 \cdot 10^{-18}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-121}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 8 \cdot 10^{+98} \lor \neg \left(x \leq 6.8 \cdot 10^{+187}\right):\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 5: 67.1% accurate, 1.0× speedup?

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

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

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

\mathbf{elif}\;x \leq 8 \cdot 10^{+98}:\\
\;\;\;\;\left|\frac{x \cdot z}{y_m}\right|\\

\mathbf{elif}\;x \leq 1.55 \cdot 10^{+184}:\\
\;\;\;\;\left|\frac{x}{y_m}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -4.19999999999999962e-15 or 1.5499999999999999e184 < x

    1. Initial program 85.3%

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x}{y} \cdot \left(-z\right)\right)\right)}\right| \]
      2. expm1-udef39.5%

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

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{\left(\sqrt{-z} \cdot \sqrt{-z}\right)}\right)} - 1\right| \]
      4. sqrt-unprod22.8%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}\right)} - 1\right| \]
      5. sqr-neg22.8%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \sqrt{\color{blue}{z \cdot z}}\right)} - 1\right| \]
      6. sqrt-unprod14.1%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)}\right)} - 1\right| \]
      7. add-sqr-sqrt28.8%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{z}\right)} - 1\right| \]
      8. associate-*l/25.7%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{x \cdot z}{y}}\right)} - 1\right| \]
      9. *-commutative25.7%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{\color{blue}{z \cdot x}}{y}\right)} - 1\right| \]
      10. associate-/l*28.8%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{z}{\frac{y}{x}}}\right)} - 1\right| \]
    6. Applied egg-rr28.8%

      \[\leadsto \left|\color{blue}{e^{\mathsf{log1p}\left(\frac{z}{\frac{y}{x}}\right)} - 1}\right| \]
    7. Step-by-step derivation
      1. expm1-def28.9%

        \[\leadsto \left|\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{z}{\frac{y}{x}}\right)\right)}\right| \]
      2. expm1-log1p69.8%

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

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

        \[\leadsto \left|\color{blue}{\frac{1}{\frac{\frac{y}{x}}{z}}}\right| \]
      2. associate-/r/69.8%

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

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

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

    if -4.19999999999999962e-15 < x < 2.40000000000000003e-121

    1. Initial program 96.4%

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

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

    if 2.40000000000000003e-121 < x < 7.99999999999999998e98

    1. Initial program 92.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.99999999999999998e98 < x < 1.5499999999999999e184

    1. Initial program 94.9%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.2 \cdot 10^{-15}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-121}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 8 \cdot 10^{+98}:\\ \;\;\;\;\left|\frac{x \cdot z}{y}\right|\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{+184}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]

Alternative 6: 99.7% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 83.3%

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

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

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

    if -1.29999999999999991e72 < x < 6e8

    1. Initial program 96.0%

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

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

    if 6e8 < x

    1. Initial program 88.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.3 \cdot 10^{+72}:\\ \;\;\;\;\left|x \cdot \left(\frac{z}{y} + \frac{-1}{y}\right)\right|\\ \mathbf{elif}\;x \leq 600000000:\\ \;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{1 - z}}\right|\\ \end{array} \]

Alternative 7: 85.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.6 \cdot 10^{-17} \lor \neg \left(x \leq 2.5 \cdot 10^{-121}\right):\\
\;\;\;\;\left|\frac{x}{\frac{y_m}{1 - z}}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.59999999999999995e-17 or 2.49999999999999995e-121 < x

    1. Initial program 88.7%

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

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

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

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

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

    if -3.59999999999999995e-17 < x < 2.49999999999999995e-121

    1. Initial program 96.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.6 \cdot 10^{-17} \lor \neg \left(x \leq 2.5 \cdot 10^{-121}\right):\\ \;\;\;\;\left|\frac{x}{\frac{y}{1 - z}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array} \]

Alternative 8: 85.8% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 86.6%

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

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

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

    if -2.00000000000000014e-17 < x < 2.49999999999999995e-121

    1. Initial program 96.4%

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

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

    if 2.49999999999999995e-121 < x

    1. Initial program 90.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-17}:\\ \;\;\;\;\left|x \cdot \left(\frac{z}{y} + \frac{-1}{y}\right)\right|\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-121}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{1 - z}}\right|\\ \end{array} \]

Alternative 9: 85.8% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;z \leq -8500:\\ \;\;\;\;\left|z \cdot \frac{x}{y_m}\right|\\ \mathbf{elif}\;z \leq 4000000000000:\\ \;\;\;\;\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 -8500.0)
   (fabs (* z (/ x y_m)))
   (if (<= z 4000000000000.0)
     (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 <= -8500.0) {
		tmp = fabs((z * (x / y_m)));
	} else if (z <= 4000000000000.0) {
		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 <= (-8500.0d0)) then
        tmp = abs((z * (x / y_m)))
    else if (z <= 4000000000000.0d0) 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 <= -8500.0) {
		tmp = Math.abs((z * (x / y_m)));
	} else if (z <= 4000000000000.0) {
		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 <= -8500.0:
		tmp = math.fabs((z * (x / y_m)))
	elif z <= 4000000000000.0:
		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 <= -8500.0)
		tmp = abs(Float64(z * Float64(x / y_m)));
	elseif (z <= 4000000000000.0)
		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 <= -8500.0)
		tmp = abs((z * (x / y_m)));
	elseif (z <= 4000000000000.0)
		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, -8500.0], N[Abs[N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 4000000000000.0], 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 -8500:\\
\;\;\;\;\left|z \cdot \frac{x}{y_m}\right|\\

\mathbf{elif}\;z \leq 4000000000000:\\
\;\;\;\;\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 < -8500

    1. Initial program 97.2%

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x}{y} \cdot \left(-z\right)\right)\right)}\right| \]
      2. expm1-udef37.1%

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

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{\left(\sqrt{-z} \cdot \sqrt{-z}\right)}\right)} - 1\right| \]
      4. sqrt-unprod26.4%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}\right)} - 1\right| \]
      5. sqr-neg26.4%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \sqrt{\color{blue}{z \cdot z}}\right)} - 1\right| \]
      6. sqrt-unprod0.0%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)}\right)} - 1\right| \]
      7. add-sqr-sqrt33.4%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{z}\right)} - 1\right| \]
      8. associate-*l/32.1%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{x \cdot z}{y}}\right)} - 1\right| \]
      9. *-commutative32.1%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{\color{blue}{z \cdot x}}{y}\right)} - 1\right| \]
      10. associate-/l*33.4%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{z}{\frac{y}{x}}}\right)} - 1\right| \]
    6. Applied egg-rr33.4%

      \[\leadsto \left|\color{blue}{e^{\mathsf{log1p}\left(\frac{z}{\frac{y}{x}}\right)} - 1}\right| \]
    7. Step-by-step derivation
      1. expm1-def36.1%

        \[\leadsto \left|\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{z}{\frac{y}{x}}\right)\right)}\right| \]
      2. expm1-log1p72.0%

        \[\leadsto \left|\color{blue}{\frac{z}{\frac{y}{x}}}\right| \]
    8. Simplified72.0%

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

        \[\leadsto \left|\color{blue}{\frac{1}{\frac{\frac{y}{x}}{z}}}\right| \]
      2. associate-/r/71.9%

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

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

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

    if -8500 < z < 4e12

    1. Initial program 96.0%

      \[\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. Taylor expanded in z around 0 97.7%

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

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

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

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

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

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

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

    if 4e12 < z

    1. Initial program 77.3%

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x}{y} \cdot \left(-z\right)\right)\right)}\right| \]
      2. expm1-udef42.5%

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

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{\left(\sqrt{-z} \cdot \sqrt{-z}\right)}\right)} - 1\right| \]
      4. sqrt-unprod22.7%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{\sqrt{\left(-z\right) \cdot \left(-z\right)}}\right)} - 1\right| \]
      5. sqr-neg22.7%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \sqrt{\color{blue}{z \cdot z}}\right)} - 1\right| \]
      6. sqrt-unprod31.8%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{\left(\sqrt{z} \cdot \sqrt{z}\right)}\right)} - 1\right| \]
      7. add-sqr-sqrt31.8%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \color{blue}{z}\right)} - 1\right| \]
      8. associate-*l/30.4%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{x \cdot z}{y}}\right)} - 1\right| \]
      9. *-commutative30.4%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\frac{\color{blue}{z \cdot x}}{y}\right)} - 1\right| \]
      10. associate-/l*31.8%

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{z}{\frac{y}{x}}}\right)} - 1\right| \]
    6. Applied egg-rr31.8%

      \[\leadsto \left|\color{blue}{e^{\mathsf{log1p}\left(\frac{z}{\frac{y}{x}}\right)} - 1}\right| \]
    7. Step-by-step derivation
      1. expm1-def35.3%

        \[\leadsto \left|\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{z}{\frac{y}{x}}\right)\right)}\right| \]
      2. expm1-log1p77.6%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -8500:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;z \leq 4000000000000:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \end{array} \]

Alternative 10: 68.7% 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 87.7%

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

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

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

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

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

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

    if -10.5 < x < 4

    1. Initial program 95.7%

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

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

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

Alternative 11: 39.6% accurate, 1.1× speedup?

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

\\
\left|\frac{4}{y_m}\right|
\end{array}
Derivation
  1. Initial program 91.9%

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

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

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

Reproduce

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