fabs fraction 1

Percentage Accurate: 91.8% → 99.9%
Time: 7.3s
Alternatives: 10
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 10 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, 0.5× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 4 \cdot 10^{-6}:\\ \;\;\;\;\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 4e-6)
   (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 <= 4e-6) {
		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 <= 4e-6)
		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, 4e-6], 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 4 \cdot 10^{-6}:\\
\;\;\;\;\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 < 3.99999999999999982e-6

    1. Initial program 90.9%

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

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

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

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

    if 3.99999999999999982e-6 < y

    1. Initial program 97.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 4 \cdot 10^{-6}:\\ \;\;\;\;\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: 68.2% accurate, 1.0× 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.35 \cdot 10^{+121}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -5.2 \cdot 10^{+43}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.25 \cdot 10^{-73}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-56}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.32 \cdot 10^{+44}:\\ \;\;\;\;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 (/ x y)))) (t_1 (fabs (/ x y))))
   (if (<= x -1.35e+121)
     t_0
     (if (<= x -5.2e+43)
       t_1
       (if (<= x -2.25e-73)
         t_0
         (if (<= x 5e-56) (fabs (/ 4.0 y)) (if (<= x 1.32e+44) t_0 t_1)))))))
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.35e+121) {
		tmp = t_0;
	} else if (x <= -5.2e+43) {
		tmp = t_1;
	} else if (x <= -2.25e-73) {
		tmp = t_0;
	} else if (x <= 5e-56) {
		tmp = fabs((4.0 / y));
	} else if (x <= 1.32e+44) {
		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((z * (x / y)))
    t_1 = abs((x / y))
    if (x <= (-1.35d+121)) then
        tmp = t_0
    else if (x <= (-5.2d+43)) then
        tmp = t_1
    else if (x <= (-2.25d-73)) then
        tmp = t_0
    else if (x <= 5d-56) then
        tmp = abs((4.0d0 / y))
    else if (x <= 1.32d+44) 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 * (x / y)));
	double t_1 = Math.abs((x / y));
	double tmp;
	if (x <= -1.35e+121) {
		tmp = t_0;
	} else if (x <= -5.2e+43) {
		tmp = t_1;
	} else if (x <= -2.25e-73) {
		tmp = t_0;
	} else if (x <= 5e-56) {
		tmp = Math.abs((4.0 / y));
	} else if (x <= 1.32e+44) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	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.35e+121:
		tmp = t_0
	elif x <= -5.2e+43:
		tmp = t_1
	elif x <= -2.25e-73:
		tmp = t_0
	elif x <= 5e-56:
		tmp = math.fabs((4.0 / y))
	elif x <= 1.32e+44:
		tmp = t_0
	else:
		tmp = t_1
	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.35e+121)
		tmp = t_0;
	elseif (x <= -5.2e+43)
		tmp = t_1;
	elseif (x <= -2.25e-73)
		tmp = t_0;
	elseif (x <= 5e-56)
		tmp = abs(Float64(4.0 / y));
	elseif (x <= 1.32e+44)
		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 * (x / y)));
	t_1 = abs((x / y));
	tmp = 0.0;
	if (x <= -1.35e+121)
		tmp = t_0;
	elseif (x <= -5.2e+43)
		tmp = t_1;
	elseif (x <= -2.25e-73)
		tmp = t_0;
	elseif (x <= 5e-56)
		tmp = abs((4.0 / y));
	elseif (x <= 1.32e+44)
		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[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.35e+121], t$95$0, If[LessEqual[x, -5.2e+43], t$95$1, If[LessEqual[x, -2.25e-73], t$95$0, If[LessEqual[x, 5e-56], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.32e+44], t$95$0, t$95$1]]]]]]]
\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.35 \cdot 10^{+121}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -5.2 \cdot 10^{+43}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -2.25 \cdot 10^{-73}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 1.32 \cdot 10^{+44}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.3500000000000001e121 or -5.20000000000000042e43 < x < -2.25e-73 or 4.99999999999999997e-56 < x < 1.3200000000000001e44

    1. Initial program 90.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.3500000000000001e121 < x < -5.20000000000000042e43 or 1.3200000000000001e44 < x

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x}{y} + \color{blue}{\left(-z\right) \cdot \frac{x}{y}}\right| \]
      13. distribute-rgt1-in99.9%

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

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

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

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

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

    if -2.25e-73 < x < 4.99999999999999997e-56

    1. Initial program 97.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.35 \cdot 10^{+121}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -5.2 \cdot 10^{+43}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -2.25 \cdot 10^{-73}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-56}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.32 \cdot 10^{+44}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 3: 68.1% accurate, 1.0× 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 -4.3 \cdot 10^{+120}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.4 \cdot 10^{+42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.35 \cdot 10^{-73}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.85 \cdot 10^{-55}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.32 \cdot 10^{+44}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\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 (* z (/ x y)))) (t_1 (fabs (/ x y))))
   (if (<= x -4.3e+120)
     t_0
     (if (<= x -3.4e+42)
       t_1
       (if (<= x -1.35e-73)
         t_0
         (if (<= x 2.85e-55)
           (fabs (/ 4.0 y))
           (if (<= x 1.32e+44) (fabs (* x (/ z y))) t_1)))))))
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 <= -4.3e+120) {
		tmp = t_0;
	} else if (x <= -3.4e+42) {
		tmp = t_1;
	} else if (x <= -1.35e-73) {
		tmp = t_0;
	} else if (x <= 2.85e-55) {
		tmp = fabs((4.0 / y));
	} else if (x <= 1.32e+44) {
		tmp = fabs((x * (z / y)));
	} 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((z * (x / y)))
    t_1 = abs((x / y))
    if (x <= (-4.3d+120)) then
        tmp = t_0
    else if (x <= (-3.4d+42)) then
        tmp = t_1
    else if (x <= (-1.35d-73)) then
        tmp = t_0
    else if (x <= 2.85d-55) then
        tmp = abs((4.0d0 / y))
    else if (x <= 1.32d+44) then
        tmp = abs((x * (z / y)))
    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 * (x / y)));
	double t_1 = Math.abs((x / y));
	double tmp;
	if (x <= -4.3e+120) {
		tmp = t_0;
	} else if (x <= -3.4e+42) {
		tmp = t_1;
	} else if (x <= -1.35e-73) {
		tmp = t_0;
	} else if (x <= 2.85e-55) {
		tmp = Math.abs((4.0 / y));
	} else if (x <= 1.32e+44) {
		tmp = Math.abs((x * (z / y)));
	} else {
		tmp = t_1;
	}
	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 <= -4.3e+120:
		tmp = t_0
	elif x <= -3.4e+42:
		tmp = t_1
	elif x <= -1.35e-73:
		tmp = t_0
	elif x <= 2.85e-55:
		tmp = math.fabs((4.0 / y))
	elif x <= 1.32e+44:
		tmp = math.fabs((x * (z / y)))
	else:
		tmp = t_1
	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 <= -4.3e+120)
		tmp = t_0;
	elseif (x <= -3.4e+42)
		tmp = t_1;
	elseif (x <= -1.35e-73)
		tmp = t_0;
	elseif (x <= 2.85e-55)
		tmp = abs(Float64(4.0 / y));
	elseif (x <= 1.32e+44)
		tmp = abs(Float64(x * Float64(z / y)));
	else
		tmp = t_1;
	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 <= -4.3e+120)
		tmp = t_0;
	elseif (x <= -3.4e+42)
		tmp = t_1;
	elseif (x <= -1.35e-73)
		tmp = t_0;
	elseif (x <= 2.85e-55)
		tmp = abs((4.0 / y));
	elseif (x <= 1.32e+44)
		tmp = abs((x * (z / y)));
	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[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -4.3e+120], t$95$0, If[LessEqual[x, -3.4e+42], t$95$1, If[LessEqual[x, -1.35e-73], t$95$0, If[LessEqual[x, 2.85e-55], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.32e+44], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]]]]
\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 -4.3 \cdot 10^{+120}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -3.4 \cdot 10^{+42}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;x \leq 1.32 \cdot 10^{+44}:\\
\;\;\;\;\left|x \cdot \frac{z}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -4.3000000000000002e120 or -3.39999999999999975e42 < x < -1.34999999999999997e-73

    1. Initial program 86.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.3000000000000002e120 < x < -3.39999999999999975e42 or 1.3200000000000001e44 < x

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x}{y} + \color{blue}{\left(-z\right) \cdot \frac{x}{y}}\right| \]
      13. distribute-rgt1-in99.9%

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

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

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

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

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

    if -1.34999999999999997e-73 < x < 2.8500000000000001e-55

    1. Initial program 97.2%

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

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

    if 2.8500000000000001e-55 < x < 1.3200000000000001e44

    1. Initial program 98.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.3 \cdot 10^{+120}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -3.4 \cdot 10^{+42}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.35 \cdot 10^{-73}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 2.85 \cdot 10^{-55}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.32 \cdot 10^{+44}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 4: 68.2% accurate, 1.0× 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 -3.2 \cdot 10^{+120}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.65 \cdot 10^{+41}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.25 \cdot 10^{-73}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.85 \cdot 10^{-55}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.32 \cdot 10^{+44}:\\ \;\;\;\;\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 (* z (/ x y)))) (t_1 (fabs (/ x y))))
   (if (<= x -3.2e+120)
     t_0
     (if (<= x -1.65e+41)
       t_1
       (if (<= x -2.25e-73)
         t_0
         (if (<= x 2.85e-55)
           (fabs (/ 4.0 y))
           (if (<= x 1.32e+44) (fabs (/ x (/ y z))) t_1)))))))
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 <= -3.2e+120) {
		tmp = t_0;
	} else if (x <= -1.65e+41) {
		tmp = t_1;
	} else if (x <= -2.25e-73) {
		tmp = t_0;
	} else if (x <= 2.85e-55) {
		tmp = fabs((4.0 / y));
	} else if (x <= 1.32e+44) {
		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) :: tmp
    t_0 = abs((z * (x / y)))
    t_1 = abs((x / y))
    if (x <= (-3.2d+120)) then
        tmp = t_0
    else if (x <= (-1.65d+41)) then
        tmp = t_1
    else if (x <= (-2.25d-73)) then
        tmp = t_0
    else if (x <= 2.85d-55) then
        tmp = abs((4.0d0 / y))
    else if (x <= 1.32d+44) 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((z * (x / y)));
	double t_1 = Math.abs((x / y));
	double tmp;
	if (x <= -3.2e+120) {
		tmp = t_0;
	} else if (x <= -1.65e+41) {
		tmp = t_1;
	} else if (x <= -2.25e-73) {
		tmp = t_0;
	} else if (x <= 2.85e-55) {
		tmp = Math.abs((4.0 / y));
	} else if (x <= 1.32e+44) {
		tmp = Math.abs((x / (y / z)));
	} else {
		tmp = t_1;
	}
	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 <= -3.2e+120:
		tmp = t_0
	elif x <= -1.65e+41:
		tmp = t_1
	elif x <= -2.25e-73:
		tmp = t_0
	elif x <= 2.85e-55:
		tmp = math.fabs((4.0 / y))
	elif x <= 1.32e+44:
		tmp = math.fabs((x / (y / z)))
	else:
		tmp = t_1
	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 <= -3.2e+120)
		tmp = t_0;
	elseif (x <= -1.65e+41)
		tmp = t_1;
	elseif (x <= -2.25e-73)
		tmp = t_0;
	elseif (x <= 2.85e-55)
		tmp = abs(Float64(4.0 / y));
	elseif (x <= 1.32e+44)
		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((z * (x / y)));
	t_1 = abs((x / y));
	tmp = 0.0;
	if (x <= -3.2e+120)
		tmp = t_0;
	elseif (x <= -1.65e+41)
		tmp = t_1;
	elseif (x <= -2.25e-73)
		tmp = t_0;
	elseif (x <= 2.85e-55)
		tmp = abs((4.0 / y));
	elseif (x <= 1.32e+44)
		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[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -3.2e+120], t$95$0, If[LessEqual[x, -1.65e+41], t$95$1, If[LessEqual[x, -2.25e-73], t$95$0, If[LessEqual[x, 2.85e-55], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.32e+44], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]]]]
\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 -3.2 \cdot 10^{+120}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -1.65 \cdot 10^{+41}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -2.25 \cdot 10^{-73}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 1.32 \cdot 10^{+44}:\\
\;\;\;\;\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 < -3.19999999999999982e120 or -1.65e41 < x < -2.25e-73

    1. Initial program 86.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.19999999999999982e120 < x < -1.65e41 or 1.3200000000000001e44 < x

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x}{y} + \color{blue}{\left(-z\right) \cdot \frac{x}{y}}\right| \]
      13. distribute-rgt1-in99.9%

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

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

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

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

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

    if -2.25e-73 < x < 2.8500000000000001e-55

    1. Initial program 97.2%

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

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

    if 2.8500000000000001e-55 < x < 1.3200000000000001e44

    1. Initial program 98.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.2 \cdot 10^{+120}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.65 \cdot 10^{+41}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -2.25 \cdot 10^{-73}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 2.85 \cdot 10^{-55}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.32 \cdot 10^{+44}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 5: 68.1% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -1.3 \cdot 10^{+120}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{+42}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -2.05 \cdot 10^{-73}:\\ \;\;\;\;\left|\frac{x \cdot z}{y}\right|\\ \mathbf{elif}\;x \leq 2.85 \cdot 10^{-55}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.32 \cdot 10^{+44}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\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 (/ x y))))
   (if (<= x -1.3e+120)
     (fabs (* z (/ x y)))
     (if (<= x -2.8e+42)
       t_0
       (if (<= x -2.05e-73)
         (fabs (/ (* x z) y))
         (if (<= x 2.85e-55)
           (fabs (/ 4.0 y))
           (if (<= x 1.32e+44) (fabs (/ x (/ y z))) t_0)))))))
y = abs(y);
double code(double x, double y, double z) {
	double t_0 = fabs((x / y));
	double tmp;
	if (x <= -1.3e+120) {
		tmp = fabs((z * (x / y)));
	} else if (x <= -2.8e+42) {
		tmp = t_0;
	} else if (x <= -2.05e-73) {
		tmp = fabs(((x * z) / y));
	} else if (x <= 2.85e-55) {
		tmp = fabs((4.0 / y));
	} else if (x <= 1.32e+44) {
		tmp = fabs((x / (y / z)));
	} 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) :: tmp
    t_0 = abs((x / y))
    if (x <= (-1.3d+120)) then
        tmp = abs((z * (x / y)))
    else if (x <= (-2.8d+42)) then
        tmp = t_0
    else if (x <= (-2.05d-73)) then
        tmp = abs(((x * z) / y))
    else if (x <= 2.85d-55) then
        tmp = abs((4.0d0 / y))
    else if (x <= 1.32d+44) then
        tmp = abs((x / (y / z)))
    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((x / y));
	double tmp;
	if (x <= -1.3e+120) {
		tmp = Math.abs((z * (x / y)));
	} else if (x <= -2.8e+42) {
		tmp = t_0;
	} else if (x <= -2.05e-73) {
		tmp = Math.abs(((x * z) / y));
	} else if (x <= 2.85e-55) {
		tmp = Math.abs((4.0 / y));
	} else if (x <= 1.32e+44) {
		tmp = Math.abs((x / (y / z)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	t_0 = math.fabs((x / y))
	tmp = 0
	if x <= -1.3e+120:
		tmp = math.fabs((z * (x / y)))
	elif x <= -2.8e+42:
		tmp = t_0
	elif x <= -2.05e-73:
		tmp = math.fabs(((x * z) / y))
	elif x <= 2.85e-55:
		tmp = math.fabs((4.0 / y))
	elif x <= 1.32e+44:
		tmp = math.fabs((x / (y / z)))
	else:
		tmp = t_0
	return tmp
y = abs(y)
function code(x, y, z)
	t_0 = abs(Float64(x / y))
	tmp = 0.0
	if (x <= -1.3e+120)
		tmp = abs(Float64(z * Float64(x / y)));
	elseif (x <= -2.8e+42)
		tmp = t_0;
	elseif (x <= -2.05e-73)
		tmp = abs(Float64(Float64(x * z) / y));
	elseif (x <= 2.85e-55)
		tmp = abs(Float64(4.0 / y));
	elseif (x <= 1.32e+44)
		tmp = abs(Float64(x / Float64(y / z)));
	else
		tmp = t_0;
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	t_0 = abs((x / y));
	tmp = 0.0;
	if (x <= -1.3e+120)
		tmp = abs((z * (x / y)));
	elseif (x <= -2.8e+42)
		tmp = t_0;
	elseif (x <= -2.05e-73)
		tmp = abs(((x * z) / y));
	elseif (x <= 2.85e-55)
		tmp = abs((4.0 / y));
	elseif (x <= 1.32e+44)
		tmp = abs((x / (y / z)));
	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[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.3e+120], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, -2.8e+42], t$95$0, If[LessEqual[x, -2.05e-73], N[Abs[N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 2.85e-55], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.32e+44], N[Abs[N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -1.3 \cdot 10^{+120}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\

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

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

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

\mathbf{elif}\;x \leq 1.32 \cdot 10^{+44}:\\
\;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\

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


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

    1. Initial program 77.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.2999999999999999e120 < x < -2.7999999999999999e42 or 1.3200000000000001e44 < x

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x}{y} + \color{blue}{\left(-z\right) \cdot \frac{x}{y}}\right| \]
      13. distribute-rgt1-in99.9%

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

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

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

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

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

    if -2.7999999999999999e42 < x < -2.05000000000000008e-73

    1. Initial program 99.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{z \cdot x}{y}}\right| \]
    3. Step-by-step derivation
      1. associate-*r/62.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.05000000000000008e-73 < x < 2.8500000000000001e-55

    1. Initial program 97.2%

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

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

    if 2.8500000000000001e-55 < x < 1.3200000000000001e44

    1. Initial program 98.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.3 \cdot 10^{+120}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{+42}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -2.05 \cdot 10^{-73}:\\ \;\;\;\;\left|\frac{x \cdot z}{y}\right|\\ \mathbf{elif}\;x \leq 2.85 \cdot 10^{-55}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.32 \cdot 10^{+44}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 6: 97.9% accurate, 1.0× speedup?

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

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


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

    1. Initial program 90.9%

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

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

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

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

    if 4.00000000000000019e-4 < y

    1. Initial program 97.6%

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

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

Alternative 7: 97.5% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 2 \cdot 10^{+143}:\\ \;\;\;\;\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 2e+143)
   (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 <= 2e+143) {
		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 <= 2d+143) 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 <= 2e+143) {
		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 <= 2e+143:
		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 <= 2e+143)
		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 <= 2e+143)
		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, 2e+143], 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 2 \cdot 10^{+143}:\\
\;\;\;\;\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 < 2e143

    1. Initial program 93.0%

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

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

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

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

    if 2e143 < x

    1. Initial program 91.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x}{y} + \color{blue}{\left(-z\right) \cdot \frac{x}{y}}\right| \]
      13. distribute-rgt1-in99.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2 \cdot 10^{+143}:\\ \;\;\;\;\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 8: 85.4% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 96.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.2e18 < z < 2.30000000000000007e-10

    1. Initial program 95.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.30000000000000007e-10 < z

    1. Initial program 83.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 68.8% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq -1.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 -1.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 <= -1.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 <= (-1.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 <= -1.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 <= -1.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 <= -1.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 <= -1.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, -1.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 -1.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 < -1.5 or 4 < x

    1. Initial program 88.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x}{y} + \color{blue}{\left(-z\right) \cdot \frac{x}{y}}\right| \]
      13. distribute-rgt1-in96.8%

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

        \[\leadsto \left|\color{blue}{\left(1 + \left(-z\right)\right)} \cdot \frac{x}{y}\right| \]
      15. sub-neg96.8%

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

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

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

    if -1.5 < x < 4

    1. Initial program 97.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.5 \lor \neg \left(x \leq 4\right):\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array} \]

Alternative 10: 39.4% 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 92.8%

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

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

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

Reproduce

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