fabs fraction 1

Percentage Accurate: 91.8% → 99.9%
Time: 6.6s
Alternatives: 8
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 8 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.8% 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.9% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 0.008:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}} - \frac{x + 4}{y}\right|\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= y 0.008)
   (fabs (/ (- (+ x 4.0) (* x z)) y))
   (fabs (- (/ x (/ y z)) (/ (+ x 4.0) y)))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if (y <= 0.008) {
		tmp = fabs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = fabs(((x / (y / z)) - ((x + 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 (y <= 0.008d0) then
        tmp = abs((((x + 4.0d0) - (x * z)) / y))
    else
        tmp = abs(((x / (y / z)) - ((x + 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 (y <= 0.008) {
		tmp = Math.abs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = Math.abs(((x / (y / z)) - ((x + 4.0) / y)));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if y <= 0.008:
		tmp = math.fabs((((x + 4.0) - (x * z)) / y))
	else:
		tmp = math.fabs(((x / (y / z)) - ((x + 4.0) / y)))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if (y <= 0.008)
		tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y));
	else
		tmp = abs(Float64(Float64(x / Float64(y / z)) - Float64(Float64(x + 4.0) / y)));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= 0.008)
		tmp = abs((((x + 4.0) - (x * z)) / y));
	else
		tmp = abs(((x / (y / z)) - ((x + 4.0) / y)));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[y, 0.008], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision] - N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.008:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 0.0080000000000000002

    1. Initial program 90.6%

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

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

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

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

    if 0.0080000000000000002 < y

    1. Initial program 94.2%

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

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

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

Alternative 2: 67.5% 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|\\ t_2 := \left|\frac{4}{y}\right|\\ \mathbf{if}\;x \leq -3.4 \cdot 10^{+176}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{+153}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -10.2:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{-134}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-114}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-82}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2050:\\ \;\;\;\;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))) (t_2 (fabs (/ 4.0 y))))
   (if (<= x -3.4e+176)
     t_1
     (if (<= x -2.8e+153)
       t_0
       (if (<= x -10.2)
         t_1
         (if (<= x 1.35e-134)
           t_2
           (if (<= x 5e-114)
             t_0
             (if (<= x 2.5e-82) t_2 (if (<= x 2050.0) 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 t_2 = fabs((4.0 / y));
	double tmp;
	if (x <= -3.4e+176) {
		tmp = t_1;
	} else if (x <= -2.8e+153) {
		tmp = t_0;
	} else if (x <= -10.2) {
		tmp = t_1;
	} else if (x <= 1.35e-134) {
		tmp = t_2;
	} else if (x <= 5e-114) {
		tmp = t_0;
	} else if (x <= 2.5e-82) {
		tmp = t_2;
	} else if (x <= 2050.0) {
		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) :: t_2
    real(8) :: tmp
    t_0 = abs((x * (z / y)))
    t_1 = abs((x / y))
    t_2 = abs((4.0d0 / y))
    if (x <= (-3.4d+176)) then
        tmp = t_1
    else if (x <= (-2.8d+153)) then
        tmp = t_0
    else if (x <= (-10.2d0)) then
        tmp = t_1
    else if (x <= 1.35d-134) then
        tmp = t_2
    else if (x <= 5d-114) then
        tmp = t_0
    else if (x <= 2.5d-82) then
        tmp = t_2
    else if (x <= 2050.0d0) 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 t_2 = Math.abs((4.0 / y));
	double tmp;
	if (x <= -3.4e+176) {
		tmp = t_1;
	} else if (x <= -2.8e+153) {
		tmp = t_0;
	} else if (x <= -10.2) {
		tmp = t_1;
	} else if (x <= 1.35e-134) {
		tmp = t_2;
	} else if (x <= 5e-114) {
		tmp = t_0;
	} else if (x <= 2.5e-82) {
		tmp = t_2;
	} else if (x <= 2050.0) {
		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))
	t_2 = math.fabs((4.0 / y))
	tmp = 0
	if x <= -3.4e+176:
		tmp = t_1
	elif x <= -2.8e+153:
		tmp = t_0
	elif x <= -10.2:
		tmp = t_1
	elif x <= 1.35e-134:
		tmp = t_2
	elif x <= 5e-114:
		tmp = t_0
	elif x <= 2.5e-82:
		tmp = t_2
	elif x <= 2050.0:
		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))
	t_2 = abs(Float64(4.0 / y))
	tmp = 0.0
	if (x <= -3.4e+176)
		tmp = t_1;
	elseif (x <= -2.8e+153)
		tmp = t_0;
	elseif (x <= -10.2)
		tmp = t_1;
	elseif (x <= 1.35e-134)
		tmp = t_2;
	elseif (x <= 5e-114)
		tmp = t_0;
	elseif (x <= 2.5e-82)
		tmp = t_2;
	elseif (x <= 2050.0)
		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));
	t_2 = abs((4.0 / y));
	tmp = 0.0;
	if (x <= -3.4e+176)
		tmp = t_1;
	elseif (x <= -2.8e+153)
		tmp = t_0;
	elseif (x <= -10.2)
		tmp = t_1;
	elseif (x <= 1.35e-134)
		tmp = t_2;
	elseif (x <= 5e-114)
		tmp = t_0;
	elseif (x <= 2.5e-82)
		tmp = t_2;
	elseif (x <= 2050.0)
		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]}, Block[{t$95$2 = N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -3.4e+176], t$95$1, If[LessEqual[x, -2.8e+153], t$95$0, If[LessEqual[x, -10.2], t$95$1, If[LessEqual[x, 1.35e-134], t$95$2, If[LessEqual[x, 5e-114], t$95$0, If[LessEqual[x, 2.5e-82], t$95$2, If[LessEqual[x, 2050.0], 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|\\
t_2 := \left|\frac{4}{y}\right|\\
\mathbf{if}\;x \leq -3.4 \cdot 10^{+176}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;x \leq 1.35 \cdot 10^{-134}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 5 \cdot 10^{-114}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 2.5 \cdot 10^{-82}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 2050:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -3.40000000000000014e176 or -2.79999999999999985e153 < x < -10.199999999999999 or 2050 < x

    1. Initial program 86.3%

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

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

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

    if -3.40000000000000014e176 < x < -2.79999999999999985e153 or 1.3499999999999999e-134 < x < 4.99999999999999989e-114 or 2.4999999999999999e-82 < x < 2050

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -10.199999999999999 < x < 1.3499999999999999e-134 or 4.99999999999999989e-114 < x < 2.4999999999999999e-82

    1. Initial program 95.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.4 \cdot 10^{+176}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{+153}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq -10.2:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{-134}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-114}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-82}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 2050:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 3: 67.6% 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|\\ t_2 := \left|\frac{4}{y}\right|\\ \mathbf{if}\;x \leq -4.7 \cdot 10^{+176}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.8 \cdot 10^{+156}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -10.5:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{-134}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-114}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-82}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2050:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \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))) (t_2 (fabs (/ 4.0 y))))
   (if (<= x -4.7e+176)
     t_1
     (if (<= x -1.8e+156)
       t_0
       (if (<= x -10.5)
         t_1
         (if (<= x 1.35e-134)
           t_2
           (if (<= x 5e-114)
             t_0
             (if (<= x 8e-82)
               t_2
               (if (<= x 2050.0) (fabs (/ x (/ y z))) 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 t_2 = fabs((4.0 / y));
	double tmp;
	if (x <= -4.7e+176) {
		tmp = t_1;
	} else if (x <= -1.8e+156) {
		tmp = t_0;
	} else if (x <= -10.5) {
		tmp = t_1;
	} else if (x <= 1.35e-134) {
		tmp = t_2;
	} else if (x <= 5e-114) {
		tmp = t_0;
	} else if (x <= 8e-82) {
		tmp = t_2;
	} else if (x <= 2050.0) {
		tmp = fabs((x / (y / z)));
	} 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) :: t_2
    real(8) :: tmp
    t_0 = abs((x * (z / y)))
    t_1 = abs((x / y))
    t_2 = abs((4.0d0 / y))
    if (x <= (-4.7d+176)) then
        tmp = t_1
    else if (x <= (-1.8d+156)) then
        tmp = t_0
    else if (x <= (-10.5d0)) then
        tmp = t_1
    else if (x <= 1.35d-134) then
        tmp = t_2
    else if (x <= 5d-114) then
        tmp = t_0
    else if (x <= 8d-82) then
        tmp = t_2
    else if (x <= 2050.0d0) then
        tmp = abs((x / (y / z)))
    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 t_2 = Math.abs((4.0 / y));
	double tmp;
	if (x <= -4.7e+176) {
		tmp = t_1;
	} else if (x <= -1.8e+156) {
		tmp = t_0;
	} else if (x <= -10.5) {
		tmp = t_1;
	} else if (x <= 1.35e-134) {
		tmp = t_2;
	} else if (x <= 5e-114) {
		tmp = t_0;
	} else if (x <= 8e-82) {
		tmp = t_2;
	} else if (x <= 2050.0) {
		tmp = Math.abs((x / (y / z)));
	} 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))
	t_2 = math.fabs((4.0 / y))
	tmp = 0
	if x <= -4.7e+176:
		tmp = t_1
	elif x <= -1.8e+156:
		tmp = t_0
	elif x <= -10.5:
		tmp = t_1
	elif x <= 1.35e-134:
		tmp = t_2
	elif x <= 5e-114:
		tmp = t_0
	elif x <= 8e-82:
		tmp = t_2
	elif x <= 2050.0:
		tmp = math.fabs((x / (y / z)))
	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))
	t_2 = abs(Float64(4.0 / y))
	tmp = 0.0
	if (x <= -4.7e+176)
		tmp = t_1;
	elseif (x <= -1.8e+156)
		tmp = t_0;
	elseif (x <= -10.5)
		tmp = t_1;
	elseif (x <= 1.35e-134)
		tmp = t_2;
	elseif (x <= 5e-114)
		tmp = t_0;
	elseif (x <= 8e-82)
		tmp = t_2;
	elseif (x <= 2050.0)
		tmp = abs(Float64(x / Float64(y / z)));
	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));
	t_2 = abs((4.0 / y));
	tmp = 0.0;
	if (x <= -4.7e+176)
		tmp = t_1;
	elseif (x <= -1.8e+156)
		tmp = t_0;
	elseif (x <= -10.5)
		tmp = t_1;
	elseif (x <= 1.35e-134)
		tmp = t_2;
	elseif (x <= 5e-114)
		tmp = t_0;
	elseif (x <= 8e-82)
		tmp = t_2;
	elseif (x <= 2050.0)
		tmp = abs((x / (y / z)));
	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]}, Block[{t$95$2 = N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -4.7e+176], t$95$1, If[LessEqual[x, -1.8e+156], t$95$0, If[LessEqual[x, -10.5], t$95$1, If[LessEqual[x, 1.35e-134], t$95$2, If[LessEqual[x, 5e-114], t$95$0, If[LessEqual[x, 8e-82], t$95$2, If[LessEqual[x, 2050.0], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 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|\\
t_2 := \left|\frac{4}{y}\right|\\
\mathbf{if}\;x \leq -4.7 \cdot 10^{+176}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -1.8 \cdot 10^{+156}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 1.35 \cdot 10^{-134}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 5 \cdot 10^{-114}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 8 \cdot 10^{-82}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 2050:\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -4.69999999999999981e176 or -1.79999999999999989e156 < x < -10.5 or 2050 < x

    1. Initial program 86.3%

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

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

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

    if -4.69999999999999981e176 < x < -1.79999999999999989e156 or 1.3499999999999999e-134 < x < 4.99999999999999989e-114

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -10.5 < x < 1.3499999999999999e-134 or 4.99999999999999989e-114 < x < 8e-82

    1. Initial program 95.8%

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

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

    if 8e-82 < x < 2050

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.7 \cdot 10^{+176}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.8 \cdot 10^{+156}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq -10.5:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{-134}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-114}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-82}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 2050:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 4: 67.5% accurate, 0.9× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} t_0 := \left|\frac{z}{\frac{y}{x}}\right|\\ t_1 := \left|\frac{x}{y}\right|\\ t_2 := \left|\frac{4}{y}\right|\\ \mathbf{if}\;x \leq -2.15 \cdot 10^{+200}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.35 \cdot 10^{+156}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -10.5:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{-134}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{-114}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{-82}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2050:\\ \;\;\;\;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 (/ z (/ y x)))) (t_1 (fabs (/ x y))) (t_2 (fabs (/ 4.0 y))))
   (if (<= x -2.15e+200)
     t_1
     (if (<= x -1.35e+156)
       t_0
       (if (<= x -10.5)
         t_1
         (if (<= x 1.35e-134)
           t_2
           (if (<= x 5.8e-114)
             (fabs (* x (/ z y)))
             (if (<= x 4.4e-82) t_2 (if (<= x 2050.0) t_0 t_1)))))))))
y = abs(y);
double code(double x, double y, double z) {
	double t_0 = fabs((z / (y / x)));
	double t_1 = fabs((x / y));
	double t_2 = fabs((4.0 / y));
	double tmp;
	if (x <= -2.15e+200) {
		tmp = t_1;
	} else if (x <= -1.35e+156) {
		tmp = t_0;
	} else if (x <= -10.5) {
		tmp = t_1;
	} else if (x <= 1.35e-134) {
		tmp = t_2;
	} else if (x <= 5.8e-114) {
		tmp = fabs((x * (z / y)));
	} else if (x <= 4.4e-82) {
		tmp = t_2;
	} else if (x <= 2050.0) {
		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) :: t_2
    real(8) :: tmp
    t_0 = abs((z / (y / x)))
    t_1 = abs((x / y))
    t_2 = abs((4.0d0 / y))
    if (x <= (-2.15d+200)) then
        tmp = t_1
    else if (x <= (-1.35d+156)) then
        tmp = t_0
    else if (x <= (-10.5d0)) then
        tmp = t_1
    else if (x <= 1.35d-134) then
        tmp = t_2
    else if (x <= 5.8d-114) then
        tmp = abs((x * (z / y)))
    else if (x <= 4.4d-82) then
        tmp = t_2
    else if (x <= 2050.0d0) 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((z / (y / x)));
	double t_1 = Math.abs((x / y));
	double t_2 = Math.abs((4.0 / y));
	double tmp;
	if (x <= -2.15e+200) {
		tmp = t_1;
	} else if (x <= -1.35e+156) {
		tmp = t_0;
	} else if (x <= -10.5) {
		tmp = t_1;
	} else if (x <= 1.35e-134) {
		tmp = t_2;
	} else if (x <= 5.8e-114) {
		tmp = Math.abs((x * (z / y)));
	} else if (x <= 4.4e-82) {
		tmp = t_2;
	} else if (x <= 2050.0) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	t_0 = math.fabs((z / (y / x)))
	t_1 = math.fabs((x / y))
	t_2 = math.fabs((4.0 / y))
	tmp = 0
	if x <= -2.15e+200:
		tmp = t_1
	elif x <= -1.35e+156:
		tmp = t_0
	elif x <= -10.5:
		tmp = t_1
	elif x <= 1.35e-134:
		tmp = t_2
	elif x <= 5.8e-114:
		tmp = math.fabs((x * (z / y)))
	elif x <= 4.4e-82:
		tmp = t_2
	elif x <= 2050.0:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
y = abs(y)
function code(x, y, z)
	t_0 = abs(Float64(z / Float64(y / x)))
	t_1 = abs(Float64(x / y))
	t_2 = abs(Float64(4.0 / y))
	tmp = 0.0
	if (x <= -2.15e+200)
		tmp = t_1;
	elseif (x <= -1.35e+156)
		tmp = t_0;
	elseif (x <= -10.5)
		tmp = t_1;
	elseif (x <= 1.35e-134)
		tmp = t_2;
	elseif (x <= 5.8e-114)
		tmp = abs(Float64(x * Float64(z / y)));
	elseif (x <= 4.4e-82)
		tmp = t_2;
	elseif (x <= 2050.0)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	t_0 = abs((z / (y / x)));
	t_1 = abs((x / y));
	t_2 = abs((4.0 / y));
	tmp = 0.0;
	if (x <= -2.15e+200)
		tmp = t_1;
	elseif (x <= -1.35e+156)
		tmp = t_0;
	elseif (x <= -10.5)
		tmp = t_1;
	elseif (x <= 1.35e-134)
		tmp = t_2;
	elseif (x <= 5.8e-114)
		tmp = abs((x * (z / y)));
	elseif (x <= 4.4e-82)
		tmp = t_2;
	elseif (x <= 2050.0)
		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[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -2.15e+200], t$95$1, If[LessEqual[x, -1.35e+156], t$95$0, If[LessEqual[x, -10.5], t$95$1, If[LessEqual[x, 1.35e-134], t$95$2, If[LessEqual[x, 5.8e-114], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.4e-82], t$95$2, If[LessEqual[x, 2050.0], t$95$0, t$95$1]]]]]]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|\frac{z}{\frac{y}{x}}\right|\\
t_1 := \left|\frac{x}{y}\right|\\
t_2 := \left|\frac{4}{y}\right|\\
\mathbf{if}\;x \leq -2.15 \cdot 10^{+200}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -1.35 \cdot 10^{+156}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 1.35 \cdot 10^{-134}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;x \leq 4.4 \cdot 10^{-82}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 2050:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -2.15000000000000016e200 or -1.35e156 < x < -10.5 or 2050 < x

    1. Initial program 88.1%

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

      \[\leadsto \left|\color{blue}{\frac{x}{y}} - \frac{x}{y} \cdot z\right| \]
    3. Taylor expanded in z around 0 74.7%

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

    if -2.15000000000000016e200 < x < -1.35e156 or 4.39999999999999971e-82 < x < 2050

    1. Initial program 87.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|-\color{blue}{z \cdot \frac{x}{y}}\right| \]
      6. distribute-lft-neg-in86.2%

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

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

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

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

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

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

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

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

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

    if -10.5 < x < 1.3499999999999999e-134 or 5.79999999999999993e-114 < x < 4.39999999999999971e-82

    1. Initial program 95.8%

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

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

    if 1.3499999999999999e-134 < x < 5.79999999999999993e-114

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.15 \cdot 10^{+200}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.35 \cdot 10^{+156}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \leq -10.5:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{-134}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{-114}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{-82}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 2050:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 5: 98.2% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1e18

    1. Initial program 93.5%

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

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

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

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

    if 1e18 < x

    1. Initial program 85.9%

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

      \[\leadsto \left|\color{blue}{\frac{x}{y}} - \frac{x}{y} \cdot z\right| \]
    3. Step-by-step derivation
      1. *-un-lft-identity85.9%

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

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

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

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

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

Alternative 6: 84.8% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;z \leq -4.5 \cdot 10^{+94}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{+102}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\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 (<= z -4.5e+94)
   (fabs (* x (/ z y)))
   (if (<= z 1.9e+102) (fabs (/ (- -4.0 x) y)) (fabs (/ x (/ y z))))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if (z <= -4.5e+94) {
		tmp = fabs((x * (z / y)));
	} else if (z <= 1.9e+102) {
		tmp = fabs(((-4.0 - x) / y));
	} else {
		tmp = fabs((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 (z <= (-4.5d+94)) then
        tmp = abs((x * (z / y)))
    else if (z <= 1.9d+102) then
        tmp = abs((((-4.0d0) - x) / y))
    else
        tmp = abs((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 (z <= -4.5e+94) {
		tmp = Math.abs((x * (z / y)));
	} else if (z <= 1.9e+102) {
		tmp = Math.abs(((-4.0 - x) / y));
	} else {
		tmp = Math.abs((x / (y / z)));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if z <= -4.5e+94:
		tmp = math.fabs((x * (z / y)))
	elif z <= 1.9e+102:
		tmp = math.fabs(((-4.0 - x) / y))
	else:
		tmp = math.fabs((x / (y / z)))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if (z <= -4.5e+94)
		tmp = abs(Float64(x * Float64(z / y)));
	elseif (z <= 1.9e+102)
		tmp = abs(Float64(Float64(-4.0 - x) / y));
	else
		tmp = abs(Float64(x / Float64(y / z)));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -4.5e+94)
		tmp = abs((x * (z / y)));
	elseif (z <= 1.9e+102)
		tmp = abs(((-4.0 - x) / y));
	else
		tmp = abs((x / (y / z)));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[z, -4.5e+94], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 1.9e+102], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{+94}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\

\mathbf{elif}\;z \leq 1.9 \cdot 10^{+102}:\\
\;\;\;\;\left|\frac{-4 - x}{y}\right|\\

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


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

    1. Initial program 94.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.49999999999999972e94 < z < 1.89999999999999989e102

    1. Initial program 93.3%

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

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

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

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

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

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

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

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

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

    if 1.89999999999999989e102 < z

    1. Initial program 80.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 69.2% 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 86.9%

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

      \[\leadsto \left|\color{blue}{\frac{x}{y}} - \frac{x}{y} \cdot z\right| \]
    3. Taylor expanded in z around 0 72.0%

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

    if -10.5 < x < 4

    1. Initial program 96.4%

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

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

    \[\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 8: 41.0% 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 91.6%

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

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

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

Reproduce

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