fabs fraction 1

Percentage Accurate: 91.1% → 99.6%
Time: 6.3s
Alternatives: 11
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 91.1% 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.6% accurate, 0.5× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 1.5 \cdot 10^{-70}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= y 1.5e-70)
   (fabs (/ (- (+ x 4.0) (* x z)) y))
   (fabs (fma x (/ z y) (/ (- -4.0 x) y)))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if (y <= 1.5e-70) {
		tmp = fabs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = fabs(fma(x, (z / y), ((-4.0 - x) / y)));
	}
	return tmp;
}
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if (y <= 1.5e-70)
		tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y));
	else
		tmp = abs(fma(x, Float64(z / y), Float64(Float64(-4.0 - x) / y)));
	end
	return tmp
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[y, 1.5e-70], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y), $MachinePrecision] + N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.5 \cdot 10^{-70}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\

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


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

    1. Initial program 91.5%

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

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

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

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

    if 1.5000000000000001e-70 < y

    1. Initial program 98.7%

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

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

Alternative 2: 97.2% accurate, 0.9× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} t_0 := \frac{x + 4}{y} - z \cdot \frac{x}{y}\\ \mathbf{if}\;t_0 \leq 5 \cdot 10^{+249}:\\ \;\;\;\;\left|t_0\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (/ (+ x 4.0) y) (* z (/ x y)))))
   (if (<= t_0 5e+249) (fabs t_0) (fabs (/ (- (+ x 4.0) (* x z)) y)))))
y = abs(y);
double code(double x, double y, double z) {
	double t_0 = ((x + 4.0) / y) - (z * (x / y));
	double tmp;
	if (t_0 <= 5e+249) {
		tmp = fabs(t_0);
	} else {
		tmp = fabs((((x + 4.0) - (x * z)) / y));
	}
	return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((x + 4.0d0) / y) - (z * (x / y))
    if (t_0 <= 5d+249) then
        tmp = abs(t_0)
    else
        tmp = abs((((x + 4.0d0) - (x * z)) / y))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double t_0 = ((x + 4.0) / y) - (z * (x / y));
	double tmp;
	if (t_0 <= 5e+249) {
		tmp = Math.abs(t_0);
	} else {
		tmp = Math.abs((((x + 4.0) - (x * z)) / y));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	t_0 = ((x + 4.0) / y) - (z * (x / y))
	tmp = 0
	if t_0 <= 5e+249:
		tmp = math.fabs(t_0)
	else:
		tmp = math.fabs((((x + 4.0) - (x * z)) / y))
	return tmp
y = abs(y)
function code(x, y, z)
	t_0 = Float64(Float64(Float64(x + 4.0) / y) - Float64(z * Float64(x / y)))
	tmp = 0.0
	if (t_0 <= 5e+249)
		tmp = abs(t_0);
	else
		tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	t_0 = ((x + 4.0) / y) - (z * (x / y));
	tmp = 0.0;
	if (t_0 <= 5e+249)
		tmp = abs(t_0);
	else
		tmp = abs((((x + 4.0) - (x * z)) / y));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e+249], N[Abs[t$95$0], $MachinePrecision], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \frac{x + 4}{y} - z \cdot \frac{x}{y}\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{+249}:\\
\;\;\;\;\left|t_0\right|\\

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


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

    1. Initial program 98.6%

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

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

    1. Initial program 67.4%

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

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

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

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

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

Alternative 3: 65.4% accurate, 0.9× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} t_0 := \left|x \cdot \frac{z}{y}\right|\\ t_1 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -1.3 \cdot 10^{+207}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{+129}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -4.5 \cdot 10^{+78}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -110000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3.9 \cdot 10^{-72}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5.1 \cdot 10^{-124}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{+141}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (* x (/ z y)))) (t_1 (fabs (/ x y))))
   (if (<= x -1.3e+207)
     t_0
     (if (<= x -3.1e+129)
       t_1
       (if (<= x -4.5e+78)
         t_0
         (if (<= x -110000000000.0)
           t_1
           (if (<= x -3.9e-72)
             t_0
             (if (<= x 5.1e-124)
               (fabs (/ 4.0 y))
               (if (<= x 1.22e+141) t_0 t_1)))))))))
y = abs(y);
double code(double x, double y, double z) {
	double t_0 = fabs((x * (z / y)));
	double t_1 = fabs((x / y));
	double tmp;
	if (x <= -1.3e+207) {
		tmp = t_0;
	} else if (x <= -3.1e+129) {
		tmp = t_1;
	} else if (x <= -4.5e+78) {
		tmp = t_0;
	} else if (x <= -110000000000.0) {
		tmp = t_1;
	} else if (x <= -3.9e-72) {
		tmp = t_0;
	} else if (x <= 5.1e-124) {
		tmp = fabs((4.0 / y));
	} else if (x <= 1.22e+141) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = abs((x * (z / y)))
    t_1 = abs((x / y))
    if (x <= (-1.3d+207)) then
        tmp = t_0
    else if (x <= (-3.1d+129)) then
        tmp = t_1
    else if (x <= (-4.5d+78)) then
        tmp = t_0
    else if (x <= (-110000000000.0d0)) then
        tmp = t_1
    else if (x <= (-3.9d-72)) then
        tmp = t_0
    else if (x <= 5.1d-124) then
        tmp = abs((4.0d0 / y))
    else if (x <= 1.22d+141) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double t_0 = Math.abs((x * (z / y)));
	double t_1 = Math.abs((x / y));
	double tmp;
	if (x <= -1.3e+207) {
		tmp = t_0;
	} else if (x <= -3.1e+129) {
		tmp = t_1;
	} else if (x <= -4.5e+78) {
		tmp = t_0;
	} else if (x <= -110000000000.0) {
		tmp = t_1;
	} else if (x <= -3.9e-72) {
		tmp = t_0;
	} else if (x <= 5.1e-124) {
		tmp = Math.abs((4.0 / y));
	} else if (x <= 1.22e+141) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	t_0 = math.fabs((x * (z / y)))
	t_1 = math.fabs((x / y))
	tmp = 0
	if x <= -1.3e+207:
		tmp = t_0
	elif x <= -3.1e+129:
		tmp = t_1
	elif x <= -4.5e+78:
		tmp = t_0
	elif x <= -110000000000.0:
		tmp = t_1
	elif x <= -3.9e-72:
		tmp = t_0
	elif x <= 5.1e-124:
		tmp = math.fabs((4.0 / y))
	elif x <= 1.22e+141:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
y = abs(y)
function code(x, y, z)
	t_0 = abs(Float64(x * Float64(z / y)))
	t_1 = abs(Float64(x / y))
	tmp = 0.0
	if (x <= -1.3e+207)
		tmp = t_0;
	elseif (x <= -3.1e+129)
		tmp = t_1;
	elseif (x <= -4.5e+78)
		tmp = t_0;
	elseif (x <= -110000000000.0)
		tmp = t_1;
	elseif (x <= -3.9e-72)
		tmp = t_0;
	elseif (x <= 5.1e-124)
		tmp = abs(Float64(4.0 / y));
	elseif (x <= 1.22e+141)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	t_0 = abs((x * (z / y)));
	t_1 = abs((x / y));
	tmp = 0.0;
	if (x <= -1.3e+207)
		tmp = t_0;
	elseif (x <= -3.1e+129)
		tmp = t_1;
	elseif (x <= -4.5e+78)
		tmp = t_0;
	elseif (x <= -110000000000.0)
		tmp = t_1;
	elseif (x <= -3.9e-72)
		tmp = t_0;
	elseif (x <= 5.1e-124)
		tmp = abs((4.0 / y));
	elseif (x <= 1.22e+141)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.3e+207], t$95$0, If[LessEqual[x, -3.1e+129], t$95$1, If[LessEqual[x, -4.5e+78], t$95$0, If[LessEqual[x, -110000000000.0], t$95$1, If[LessEqual[x, -3.9e-72], t$95$0, If[LessEqual[x, 5.1e-124], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.22e+141], t$95$0, t$95$1]]]]]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|x \cdot \frac{z}{y}\right|\\
t_1 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -1.3 \cdot 10^{+207}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -3.1 \cdot 10^{+129}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -4.5 \cdot 10^{+78}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -110000000000:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -3.9 \cdot 10^{-72}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 5.1 \cdot 10^{-124}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\

\mathbf{elif}\;x \leq 1.22 \cdot 10^{+141}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.2999999999999999e207 or -3.1e129 < x < -4.4999999999999999e78 or -1.1e11 < x < -3.9e-72 or 5.1000000000000001e-124 < x < 1.2199999999999999e141

    1. Initial program 96.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|x \cdot \color{blue}{\frac{1}{\frac{y}{z}}}\right| \]
      7. expm1-log1p-u40.4%

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

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

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

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

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

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

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

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

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

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

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

    if -1.2999999999999999e207 < x < -3.1e129 or -4.4999999999999999e78 < x < -1.1e11 or 1.2199999999999999e141 < x

    1. Initial program 83.5%

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

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

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

        \[\leadsto \left|\frac{\color{blue}{4}}{y} + \frac{x}{y}\right| \]
    4. Simplified79.0%

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

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

    if -3.9e-72 < x < 5.1000000000000001e-124

    1. Initial program 97.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.3 \cdot 10^{+207}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{+129}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -4.5 \cdot 10^{+78}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq -110000000000:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -3.9 \cdot 10^{-72}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 5.1 \cdot 10^{-124}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{+141}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 4: 66.8% accurate, 0.9× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} t_0 := \left|z \cdot \frac{x}{y}\right|\\ t_1 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -1.4 \cdot 10^{+207}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -4.4 \cdot 10^{+129}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{+72}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3 \cdot 10^{+16}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3.8 \cdot 10^{-72}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 2.55 \cdot 10^{-124}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (* z (/ x y)))) (t_1 (fabs (/ x y))))
   (if (<= x -1.4e+207)
     t_0
     (if (<= x -4.4e+129)
       t_1
       (if (<= x -2.8e+72)
         t_0
         (if (<= x -3e+16)
           t_1
           (if (<= x -3.8e-72)
             (fabs (* x (/ z y)))
             (if (<= x 2.55e-124) (fabs (/ 4.0 y)) t_0))))))))
y = abs(y);
double code(double x, double y, double z) {
	double t_0 = fabs((z * (x / y)));
	double t_1 = fabs((x / y));
	double tmp;
	if (x <= -1.4e+207) {
		tmp = t_0;
	} else if (x <= -4.4e+129) {
		tmp = t_1;
	} else if (x <= -2.8e+72) {
		tmp = t_0;
	} else if (x <= -3e+16) {
		tmp = t_1;
	} else if (x <= -3.8e-72) {
		tmp = fabs((x * (z / y)));
	} else if (x <= 2.55e-124) {
		tmp = fabs((4.0 / y));
	} else {
		tmp = t_0;
	}
	return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = abs((z * (x / y)))
    t_1 = abs((x / y))
    if (x <= (-1.4d+207)) then
        tmp = t_0
    else if (x <= (-4.4d+129)) then
        tmp = t_1
    else if (x <= (-2.8d+72)) then
        tmp = t_0
    else if (x <= (-3d+16)) then
        tmp = t_1
    else if (x <= (-3.8d-72)) then
        tmp = abs((x * (z / y)))
    else if (x <= 2.55d-124) then
        tmp = abs((4.0d0 / y))
    else
        tmp = t_0
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double t_0 = Math.abs((z * (x / y)));
	double t_1 = Math.abs((x / y));
	double tmp;
	if (x <= -1.4e+207) {
		tmp = t_0;
	} else if (x <= -4.4e+129) {
		tmp = t_1;
	} else if (x <= -2.8e+72) {
		tmp = t_0;
	} else if (x <= -3e+16) {
		tmp = t_1;
	} else if (x <= -3.8e-72) {
		tmp = Math.abs((x * (z / y)));
	} else if (x <= 2.55e-124) {
		tmp = Math.abs((4.0 / y));
	} else {
		tmp = t_0;
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	t_0 = math.fabs((z * (x / y)))
	t_1 = math.fabs((x / y))
	tmp = 0
	if x <= -1.4e+207:
		tmp = t_0
	elif x <= -4.4e+129:
		tmp = t_1
	elif x <= -2.8e+72:
		tmp = t_0
	elif x <= -3e+16:
		tmp = t_1
	elif x <= -3.8e-72:
		tmp = math.fabs((x * (z / y)))
	elif x <= 2.55e-124:
		tmp = math.fabs((4.0 / y))
	else:
		tmp = t_0
	return tmp
y = abs(y)
function code(x, y, z)
	t_0 = abs(Float64(z * Float64(x / y)))
	t_1 = abs(Float64(x / y))
	tmp = 0.0
	if (x <= -1.4e+207)
		tmp = t_0;
	elseif (x <= -4.4e+129)
		tmp = t_1;
	elseif (x <= -2.8e+72)
		tmp = t_0;
	elseif (x <= -3e+16)
		tmp = t_1;
	elseif (x <= -3.8e-72)
		tmp = abs(Float64(x * Float64(z / y)));
	elseif (x <= 2.55e-124)
		tmp = abs(Float64(4.0 / y));
	else
		tmp = t_0;
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	t_0 = abs((z * (x / y)));
	t_1 = abs((x / y));
	tmp = 0.0;
	if (x <= -1.4e+207)
		tmp = t_0;
	elseif (x <= -4.4e+129)
		tmp = t_1;
	elseif (x <= -2.8e+72)
		tmp = t_0;
	elseif (x <= -3e+16)
		tmp = t_1;
	elseif (x <= -3.8e-72)
		tmp = abs((x * (z / y)));
	elseif (x <= 2.55e-124)
		tmp = abs((4.0 / y));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.4e+207], t$95$0, If[LessEqual[x, -4.4e+129], t$95$1, If[LessEqual[x, -2.8e+72], t$95$0, If[LessEqual[x, -3e+16], t$95$1, If[LessEqual[x, -3.8e-72], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 2.55e-124], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|z \cdot \frac{x}{y}\right|\\
t_1 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -1.4 \cdot 10^{+207}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -4.4 \cdot 10^{+129}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -2.8 \cdot 10^{+72}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -3 \cdot 10^{+16}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -3.8 \cdot 10^{-72}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\

\mathbf{elif}\;x \leq 2.55 \cdot 10^{-124}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -1.40000000000000005e207 or -4.3999999999999999e129 < x < -2.7999999999999999e72 or 2.5500000000000001e-124 < x

    1. Initial program 91.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|x \cdot \color{blue}{\frac{1}{\frac{y}{z}}}\right| \]
      7. expm1-log1p-u36.0%

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

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

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

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

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{x}{\frac{y}{z}}}\right)} - 1\right| \]
      12. div-inv28.3%

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

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

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

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

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

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

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

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

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

    if -1.40000000000000005e207 < x < -4.3999999999999999e129 or -2.7999999999999999e72 < x < -3e16

    1. Initial program 88.3%

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

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

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

        \[\leadsto \left|\frac{\color{blue}{4}}{y} + \frac{x}{y}\right| \]
    4. Simplified83.1%

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

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

    if -3e16 < x < -3.80000000000000002e-72

    1. Initial program 95.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|x \cdot \color{blue}{\frac{1}{\frac{y}{z}}}\right| \]
      7. expm1-log1p-u38.3%

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

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

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

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

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

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

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

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

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

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

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

    if -3.80000000000000002e-72 < x < 2.5500000000000001e-124

    1. Initial program 97.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.4 \cdot 10^{+207}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -4.4 \cdot 10^{+129}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{+72}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -3 \cdot 10^{+16}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -3.8 \cdot 10^{-72}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 2.55 \cdot 10^{-124}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]

Alternative 5: 66.0% accurate, 0.9× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} t_0 := \left|z \cdot \frac{x}{y}\right|\\ t_1 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -2 \cdot 10^{+207}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;x \leq -4.9 \cdot 10^{+129}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -4.8 \cdot 10^{+72}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.06 \cdot 10^{+15}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-72}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{-124}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (* z (/ x y)))) (t_1 (fabs (/ x y))))
   (if (<= x -2e+207)
     (fabs (/ x (/ y z)))
     (if (<= x -4.9e+129)
       t_1
       (if (<= x -4.8e+72)
         t_0
         (if (<= x -1.06e+15)
           t_1
           (if (<= x -2e-72)
             (fabs (* x (/ z y)))
             (if (<= x 4.6e-124) (fabs (/ 4.0 y)) t_0))))))))
y = abs(y);
double code(double x, double y, double z) {
	double t_0 = fabs((z * (x / y)));
	double t_1 = fabs((x / y));
	double tmp;
	if (x <= -2e+207) {
		tmp = fabs((x / (y / z)));
	} else if (x <= -4.9e+129) {
		tmp = t_1;
	} else if (x <= -4.8e+72) {
		tmp = t_0;
	} else if (x <= -1.06e+15) {
		tmp = t_1;
	} else if (x <= -2e-72) {
		tmp = fabs((x * (z / y)));
	} else if (x <= 4.6e-124) {
		tmp = fabs((4.0 / y));
	} else {
		tmp = t_0;
	}
	return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = abs((z * (x / y)))
    t_1 = abs((x / y))
    if (x <= (-2d+207)) then
        tmp = abs((x / (y / z)))
    else if (x <= (-4.9d+129)) then
        tmp = t_1
    else if (x <= (-4.8d+72)) then
        tmp = t_0
    else if (x <= (-1.06d+15)) then
        tmp = t_1
    else if (x <= (-2d-72)) then
        tmp = abs((x * (z / y)))
    else if (x <= 4.6d-124) then
        tmp = abs((4.0d0 / y))
    else
        tmp = t_0
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double t_0 = Math.abs((z * (x / y)));
	double t_1 = Math.abs((x / y));
	double tmp;
	if (x <= -2e+207) {
		tmp = Math.abs((x / (y / z)));
	} else if (x <= -4.9e+129) {
		tmp = t_1;
	} else if (x <= -4.8e+72) {
		tmp = t_0;
	} else if (x <= -1.06e+15) {
		tmp = t_1;
	} else if (x <= -2e-72) {
		tmp = Math.abs((x * (z / y)));
	} else if (x <= 4.6e-124) {
		tmp = Math.abs((4.0 / y));
	} else {
		tmp = t_0;
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	t_0 = math.fabs((z * (x / y)))
	t_1 = math.fabs((x / y))
	tmp = 0
	if x <= -2e+207:
		tmp = math.fabs((x / (y / z)))
	elif x <= -4.9e+129:
		tmp = t_1
	elif x <= -4.8e+72:
		tmp = t_0
	elif x <= -1.06e+15:
		tmp = t_1
	elif x <= -2e-72:
		tmp = math.fabs((x * (z / y)))
	elif x <= 4.6e-124:
		tmp = math.fabs((4.0 / y))
	else:
		tmp = t_0
	return tmp
y = abs(y)
function code(x, y, z)
	t_0 = abs(Float64(z * Float64(x / y)))
	t_1 = abs(Float64(x / y))
	tmp = 0.0
	if (x <= -2e+207)
		tmp = abs(Float64(x / Float64(y / z)));
	elseif (x <= -4.9e+129)
		tmp = t_1;
	elseif (x <= -4.8e+72)
		tmp = t_0;
	elseif (x <= -1.06e+15)
		tmp = t_1;
	elseif (x <= -2e-72)
		tmp = abs(Float64(x * Float64(z / y)));
	elseif (x <= 4.6e-124)
		tmp = abs(Float64(4.0 / y));
	else
		tmp = t_0;
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	t_0 = abs((z * (x / y)));
	t_1 = abs((x / y));
	tmp = 0.0;
	if (x <= -2e+207)
		tmp = abs((x / (y / z)));
	elseif (x <= -4.9e+129)
		tmp = t_1;
	elseif (x <= -4.8e+72)
		tmp = t_0;
	elseif (x <= -1.06e+15)
		tmp = t_1;
	elseif (x <= -2e-72)
		tmp = abs((x * (z / y)));
	elseif (x <= 4.6e-124)
		tmp = abs((4.0 / y));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -2e+207], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, -4.9e+129], t$95$1, If[LessEqual[x, -4.8e+72], t$95$0, If[LessEqual[x, -1.06e+15], t$95$1, If[LessEqual[x, -2e-72], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.6e-124], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|z \cdot \frac{x}{y}\right|\\
t_1 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -2 \cdot 10^{+207}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\

\mathbf{elif}\;x \leq -4.9 \cdot 10^{+129}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -4.8 \cdot 10^{+72}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -1.06 \cdot 10^{+15}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -2 \cdot 10^{-72}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\

\mathbf{elif}\;x \leq 4.6 \cdot 10^{-124}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < -2.0000000000000001e207

    1. Initial program 87.8%

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

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

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

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

        \[\leadsto \left|\color{blue}{x \cdot \left(-\frac{z}{y}\right)}\right| \]
      4. distribute-neg-frac77.2%

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e207 < x < -4.9e129 or -4.8000000000000002e72 < x < -1.06e15

    1. Initial program 88.3%

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

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

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

        \[\leadsto \left|\frac{\color{blue}{4}}{y} + \frac{x}{y}\right| \]
    4. Simplified83.1%

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

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

    if -4.9e129 < x < -4.8000000000000002e72 or 4.60000000000000024e-124 < x

    1. Initial program 92.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|x \cdot \color{blue}{\frac{1}{\frac{y}{z}}}\right| \]
      7. expm1-log1p-u35.2%

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

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

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

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

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{x}{\frac{y}{z}}}\right)} - 1\right| \]
      12. div-inv25.5%

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

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

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

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

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

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

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

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

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

    if -1.06e15 < x < -1.9999999999999999e-72

    1. Initial program 95.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|x \cdot \color{blue}{\frac{1}{\frac{y}{z}}}\right| \]
      7. expm1-log1p-u38.3%

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

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

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

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

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

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

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

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

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

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

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

    if -1.9999999999999999e-72 < x < 4.60000000000000024e-124

    1. Initial program 97.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{+207}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;x \leq -4.9 \cdot 10^{+129}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -4.8 \cdot 10^{+72}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.06 \cdot 10^{+15}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-72}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{-124}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]

Alternative 6: 65.2% accurate, 0.9× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} t_0 := \left|z \cdot \frac{x}{y}\right|\\ t_1 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -1.65 \cdot 10^{+207}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;x \leq -1.3 \cdot 10^{+129}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -6.6 \cdot 10^{+72}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.25 \cdot 10^{+16}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -6 \cdot 10^{-123}:\\ \;\;\;\;\left|\frac{x \cdot z}{y}\right|\\ \mathbf{elif}\;x \leq 5.1 \cdot 10^{-124}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (* z (/ x y)))) (t_1 (fabs (/ x y))))
   (if (<= x -1.65e+207)
     (fabs (/ x (/ y z)))
     (if (<= x -1.3e+129)
       t_1
       (if (<= x -6.6e+72)
         t_0
         (if (<= x -1.25e+16)
           t_1
           (if (<= x -6e-123)
             (fabs (/ (* x z) y))
             (if (<= x 5.1e-124) (fabs (/ 4.0 y)) t_0))))))))
y = abs(y);
double code(double x, double y, double z) {
	double t_0 = fabs((z * (x / y)));
	double t_1 = fabs((x / y));
	double tmp;
	if (x <= -1.65e+207) {
		tmp = fabs((x / (y / z)));
	} else if (x <= -1.3e+129) {
		tmp = t_1;
	} else if (x <= -6.6e+72) {
		tmp = t_0;
	} else if (x <= -1.25e+16) {
		tmp = t_1;
	} else if (x <= -6e-123) {
		tmp = fabs(((x * z) / y));
	} else if (x <= 5.1e-124) {
		tmp = fabs((4.0 / y));
	} else {
		tmp = t_0;
	}
	return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = abs((z * (x / y)))
    t_1 = abs((x / y))
    if (x <= (-1.65d+207)) then
        tmp = abs((x / (y / z)))
    else if (x <= (-1.3d+129)) then
        tmp = t_1
    else if (x <= (-6.6d+72)) then
        tmp = t_0
    else if (x <= (-1.25d+16)) then
        tmp = t_1
    else if (x <= (-6d-123)) then
        tmp = abs(((x * z) / y))
    else if (x <= 5.1d-124) then
        tmp = abs((4.0d0 / y))
    else
        tmp = t_0
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double t_0 = Math.abs((z * (x / y)));
	double t_1 = Math.abs((x / y));
	double tmp;
	if (x <= -1.65e+207) {
		tmp = Math.abs((x / (y / z)));
	} else if (x <= -1.3e+129) {
		tmp = t_1;
	} else if (x <= -6.6e+72) {
		tmp = t_0;
	} else if (x <= -1.25e+16) {
		tmp = t_1;
	} else if (x <= -6e-123) {
		tmp = Math.abs(((x * z) / y));
	} else if (x <= 5.1e-124) {
		tmp = Math.abs((4.0 / y));
	} else {
		tmp = t_0;
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	t_0 = math.fabs((z * (x / y)))
	t_1 = math.fabs((x / y))
	tmp = 0
	if x <= -1.65e+207:
		tmp = math.fabs((x / (y / z)))
	elif x <= -1.3e+129:
		tmp = t_1
	elif x <= -6.6e+72:
		tmp = t_0
	elif x <= -1.25e+16:
		tmp = t_1
	elif x <= -6e-123:
		tmp = math.fabs(((x * z) / y))
	elif x <= 5.1e-124:
		tmp = math.fabs((4.0 / y))
	else:
		tmp = t_0
	return tmp
y = abs(y)
function code(x, y, z)
	t_0 = abs(Float64(z * Float64(x / y)))
	t_1 = abs(Float64(x / y))
	tmp = 0.0
	if (x <= -1.65e+207)
		tmp = abs(Float64(x / Float64(y / z)));
	elseif (x <= -1.3e+129)
		tmp = t_1;
	elseif (x <= -6.6e+72)
		tmp = t_0;
	elseif (x <= -1.25e+16)
		tmp = t_1;
	elseif (x <= -6e-123)
		tmp = abs(Float64(Float64(x * z) / y));
	elseif (x <= 5.1e-124)
		tmp = abs(Float64(4.0 / y));
	else
		tmp = t_0;
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	t_0 = abs((z * (x / y)));
	t_1 = abs((x / y));
	tmp = 0.0;
	if (x <= -1.65e+207)
		tmp = abs((x / (y / z)));
	elseif (x <= -1.3e+129)
		tmp = t_1;
	elseif (x <= -6.6e+72)
		tmp = t_0;
	elseif (x <= -1.25e+16)
		tmp = t_1;
	elseif (x <= -6e-123)
		tmp = abs(((x * z) / y));
	elseif (x <= 5.1e-124)
		tmp = abs((4.0 / y));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.65e+207], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, -1.3e+129], t$95$1, If[LessEqual[x, -6.6e+72], t$95$0, If[LessEqual[x, -1.25e+16], t$95$1, If[LessEqual[x, -6e-123], N[Abs[N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 5.1e-124], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|z \cdot \frac{x}{y}\right|\\
t_1 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -1.65 \cdot 10^{+207}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\

\mathbf{elif}\;x \leq -1.3 \cdot 10^{+129}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -6.6 \cdot 10^{+72}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -1.25 \cdot 10^{+16}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -6 \cdot 10^{-123}:\\
\;\;\;\;\left|\frac{x \cdot z}{y}\right|\\

\mathbf{elif}\;x \leq 5.1 \cdot 10^{-124}:\\
\;\;\;\;\left|\frac{4}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < -1.65e207

    1. Initial program 87.8%

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

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

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

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

        \[\leadsto \left|\color{blue}{x \cdot \left(-\frac{z}{y}\right)}\right| \]
      4. distribute-neg-frac77.2%

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

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

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

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

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

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

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

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

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

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

    if -1.65e207 < x < -1.30000000000000006e129 or -6.6e72 < x < -1.25e16

    1. Initial program 88.3%

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

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

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

        \[\leadsto \left|\frac{\color{blue}{4}}{y} + \frac{x}{y}\right| \]
    4. Simplified83.1%

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

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

    if -1.30000000000000006e129 < x < -6.6e72 or 5.1000000000000001e-124 < x

    1. Initial program 92.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|x \cdot \color{blue}{\frac{1}{\frac{y}{z}}}\right| \]
      7. expm1-log1p-u35.2%

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

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

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

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

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{x}{\frac{y}{z}}}\right)} - 1\right| \]
      12. div-inv25.5%

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

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

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

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

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

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

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

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

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

    if -1.25e16 < x < -5.99999999999999968e-123

    1. Initial program 96.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.99999999999999968e-123 < x < 5.1000000000000001e-124

    1. Initial program 97.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.65 \cdot 10^{+207}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;x \leq -1.3 \cdot 10^{+129}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -6.6 \cdot 10^{+72}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.25 \cdot 10^{+16}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -6 \cdot 10^{-123}:\\ \;\;\;\;\left|\frac{x \cdot z}{y}\right|\\ \mathbf{elif}\;x \leq 5.1 \cdot 10^{-124}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]

Alternative 7: 99.8% accurate, 1.0× speedup?

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

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


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

    1. Initial program 91.9%

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

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

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

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

    if 2.6499999999999999e-45 < y

    1. Initial program 98.6%

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

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

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

Alternative 8: 86.1% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;z \leq -4.5 \cdot 10^{+40}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;z \leq 37000000000:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= z -4.5e+40)
   (fabs (* z (/ x y)))
   (if (<= z 37000000000.0) (fabs (/ (- -4.0 x) y)) (fabs (* x (/ z y))))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if (z <= -4.5e+40) {
		tmp = fabs((z * (x / y)));
	} else if (z <= 37000000000.0) {
		tmp = fabs(((-4.0 - x) / y));
	} else {
		tmp = fabs((x * (z / y)));
	}
	return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-4.5d+40)) then
        tmp = abs((z * (x / y)))
    else if (z <= 37000000000.0d0) then
        tmp = abs((((-4.0d0) - x) / y))
    else
        tmp = abs((x * (z / y)))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -4.5e+40) {
		tmp = Math.abs((z * (x / y)));
	} else if (z <= 37000000000.0) {
		tmp = Math.abs(((-4.0 - x) / y));
	} else {
		tmp = Math.abs((x * (z / y)));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if z <= -4.5e+40:
		tmp = math.fabs((z * (x / y)))
	elif z <= 37000000000.0:
		tmp = math.fabs(((-4.0 - x) / y))
	else:
		tmp = math.fabs((x * (z / y)))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if (z <= -4.5e+40)
		tmp = abs(Float64(z * Float64(x / y)));
	elseif (z <= 37000000000.0)
		tmp = abs(Float64(Float64(-4.0 - x) / y));
	else
		tmp = abs(Float64(x * Float64(z / y)));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -4.5e+40)
		tmp = abs((z * (x / y)));
	elseif (z <= 37000000000.0)
		tmp = abs(((-4.0 - x) / y));
	else
		tmp = abs((x * (z / y)));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[z, -4.5e+40], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 37000000000.0], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{+40}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\

\mathbf{elif}\;z \leq 37000000000:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\

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


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

    1. Initial program 98.1%

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

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

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

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

        \[\leadsto \left|\color{blue}{x \cdot \left(-\frac{z}{y}\right)}\right| \]
      4. distribute-neg-frac73.3%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{x}{\frac{y}{z}}}\right)} - 1\right| \]
      12. div-inv31.1%

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

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

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

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

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

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

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

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

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

    if -4.50000000000000032e40 < z < 3.7e10

    1. Initial program 96.9%

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

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

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

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

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

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

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

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

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

    if 3.7e10 < z

    1. Initial program 84.7%

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

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

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

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

        \[\leadsto \left|\color{blue}{x \cdot \left(-\frac{z}{y}\right)}\right| \]
      4. distribute-neg-frac83.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{x}{\frac{y}{z}}}\right)} - 1\right| \]
      12. div-inv33.1%

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

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

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

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

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

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

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

Alternative 9: 96.0% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \left|\frac{\left(x + 4\right) - x \cdot z}{y}\right| \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z) :precision binary64 (fabs (/ (- (+ x 4.0) (* x z)) y)))
y = abs(y);
double code(double x, double y, double z) {
	return fabs((((x + 4.0) - (x * z)) / y));
}
NOTE: y should be positive before calling this function
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) - (x * z)) / y))
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	return Math.abs((((x + 4.0) - (x * z)) / y));
}
y = abs(y)
def code(x, y, z):
	return math.fabs((((x + 4.0) - (x * z)) / y))
y = abs(y)
function code(x, y, z)
	return abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y))
end
y = abs(y)
function tmp = code(x, y, z)
	tmp = abs((((x + 4.0) - (x * z)) / y));
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|
\end{array}
Derivation
  1. Initial program 93.7%

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

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

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

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

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

Alternative 10: 69.4% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \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} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -10.5) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 y))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -10.5) || !(x <= 4.0)) {
		tmp = fabs((x / y));
	} else {
		tmp = fabs((4.0 / y));
	}
	return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x <= (-10.5d0)) .or. (.not. (x <= 4.0d0))) then
        tmp = abs((x / y))
    else
        tmp = abs((4.0d0 / y))
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -10.5) || !(x <= 4.0)) {
		tmp = Math.abs((x / y));
	} else {
		tmp = Math.abs((4.0 / y));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if (x <= -10.5) or not (x <= 4.0):
		tmp = math.fabs((x / y))
	else:
		tmp = math.fabs((4.0 / y))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if ((x <= -10.5) || !(x <= 4.0))
		tmp = abs(Float64(x / y));
	else
		tmp = abs(Float64(4.0 / y));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -10.5) || ~((x <= 4.0)))
		tmp = abs((x / y));
	else
		tmp = abs((4.0 / y));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[Or[LessEqual[x, -10.5], N[Not[LessEqual[x, 4.0]], $MachinePrecision]], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\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}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -10.5 or 4 < x

    1. Initial program 89.5%

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

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

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

        \[\leadsto \left|\frac{\color{blue}{4}}{y} + \frac{x}{y}\right| \]
    4. Simplified58.8%

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

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

    if -10.5 < x < 4

    1. Initial program 97.8%

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

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

    \[\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: 40.6% accurate, 1.1× speedup?

\[\begin{array}{l} y = |y|\\ \\ \left|\frac{4}{y}\right| \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z) :precision binary64 (fabs (/ 4.0 y)))
y = abs(y);
double code(double x, double y, double z) {
	return fabs((4.0 / y));
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = abs((4.0d0 / y))
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	return Math.abs((4.0 / y));
}
y = abs(y)
def code(x, y, z):
	return math.fabs((4.0 / y))
y = abs(y)
function code(x, y, z)
	return abs(Float64(4.0 / y))
end
y = abs(y)
function tmp = code(x, y, z)
	tmp = abs((4.0 / y));
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\left|\frac{4}{y}\right|
\end{array}
Derivation
  1. Initial program 93.7%

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

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

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

Reproduce

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