fabs fraction 1

Percentage Accurate: 91.3% → 99.8%
Time: 7.1s
Alternatives: 9
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 9 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.3% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.5× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 2 \cdot 10^{-29}:\\ \;\;\;\;\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 2e-29)
   (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 <= 2e-29) {
		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 <= 2e-29)
		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, 2e-29], 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 2 \cdot 10^{-29}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\

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


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

    1. Initial program 89.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.99999999999999989e-29 < y

    1. Initial program 98.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2 \cdot 10^{-29}:\\ \;\;\;\;\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: 69.7% 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 -5.2 \cdot 10^{+159}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{+34}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.24 \cdot 10^{-76}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.05 \cdot 10^{-13}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 5.1 \cdot 10^{+85}:\\ \;\;\;\;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 -5.2e+159)
     t_0
     (if (<= x -3.2e+34)
       t_1
       (if (<= x -1.24e-76)
         t_0
         (if (<= x 3.05e-13) (fabs (/ 4.0 y)) (if (<= x 5.1e+85) 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 <= -5.2e+159) {
		tmp = t_0;
	} else if (x <= -3.2e+34) {
		tmp = t_1;
	} else if (x <= -1.24e-76) {
		tmp = t_0;
	} else if (x <= 3.05e-13) {
		tmp = fabs((4.0 / y));
	} else if (x <= 5.1e+85) {
		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 <= (-5.2d+159)) then
        tmp = t_0
    else if (x <= (-3.2d+34)) then
        tmp = t_1
    else if (x <= (-1.24d-76)) then
        tmp = t_0
    else if (x <= 3.05d-13) then
        tmp = abs((4.0d0 / y))
    else if (x <= 5.1d+85) 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 <= -5.2e+159) {
		tmp = t_0;
	} else if (x <= -3.2e+34) {
		tmp = t_1;
	} else if (x <= -1.24e-76) {
		tmp = t_0;
	} else if (x <= 3.05e-13) {
		tmp = Math.abs((4.0 / y));
	} else if (x <= 5.1e+85) {
		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 <= -5.2e+159:
		tmp = t_0
	elif x <= -3.2e+34:
		tmp = t_1
	elif x <= -1.24e-76:
		tmp = t_0
	elif x <= 3.05e-13:
		tmp = math.fabs((4.0 / y))
	elif x <= 5.1e+85:
		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 <= -5.2e+159)
		tmp = t_0;
	elseif (x <= -3.2e+34)
		tmp = t_1;
	elseif (x <= -1.24e-76)
		tmp = t_0;
	elseif (x <= 3.05e-13)
		tmp = abs(Float64(4.0 / y));
	elseif (x <= 5.1e+85)
		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 <= -5.2e+159)
		tmp = t_0;
	elseif (x <= -3.2e+34)
		tmp = t_1;
	elseif (x <= -1.24e-76)
		tmp = t_0;
	elseif (x <= 3.05e-13)
		tmp = abs((4.0 / y));
	elseif (x <= 5.1e+85)
		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, -5.2e+159], t$95$0, If[LessEqual[x, -3.2e+34], t$95$1, If[LessEqual[x, -1.24e-76], t$95$0, If[LessEqual[x, 3.05e-13], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 5.1e+85], 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 -5.2 \cdot 10^{+159}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -3.2 \cdot 10^{+34}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -1.24 \cdot 10^{-76}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 5.1 \cdot 10^{+85}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -5.2000000000000001e159 or -3.1999999999999998e34 < x < -1.24000000000000003e-76 or 3.0500000000000001e-13 < x < 5.0999999999999998e85

    1. Initial program 87.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{1 \cdot z}{\frac{y}{x}}}\right| \]
      11. *-un-lft-identity73.9%

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

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

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

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

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

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

    if -5.2000000000000001e159 < x < -3.1999999999999998e34 or 5.0999999999999998e85 < x

    1. Initial program 87.1%

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

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

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

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

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

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

    if -1.24000000000000003e-76 < x < 3.0500000000000001e-13

    1. Initial program 97.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.2 \cdot 10^{+159}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{+34}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.24 \cdot 10^{-76}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 3.05 \cdot 10^{-13}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 5.1 \cdot 10^{+85}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 3: 69.7% 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 -5.6 \cdot 10^{+159}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -2.6 \cdot 10^{+34}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.6 \cdot 10^{-64}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{-13}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{+86}:\\ \;\;\;\;\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 -5.6e+159)
     t_0
     (if (<= x -2.6e+34)
       t_1
       (if (<= x -2.6e-64)
         t_0
         (if (<= x 2.9e-13)
           (fabs (/ 4.0 y))
           (if (<= x 1.35e+86) (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 <= -5.6e+159) {
		tmp = t_0;
	} else if (x <= -2.6e+34) {
		tmp = t_1;
	} else if (x <= -2.6e-64) {
		tmp = t_0;
	} else if (x <= 2.9e-13) {
		tmp = fabs((4.0 / y));
	} else if (x <= 1.35e+86) {
		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 <= (-5.6d+159)) then
        tmp = t_0
    else if (x <= (-2.6d+34)) then
        tmp = t_1
    else if (x <= (-2.6d-64)) then
        tmp = t_0
    else if (x <= 2.9d-13) then
        tmp = abs((4.0d0 / y))
    else if (x <= 1.35d+86) 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 <= -5.6e+159) {
		tmp = t_0;
	} else if (x <= -2.6e+34) {
		tmp = t_1;
	} else if (x <= -2.6e-64) {
		tmp = t_0;
	} else if (x <= 2.9e-13) {
		tmp = Math.abs((4.0 / y));
	} else if (x <= 1.35e+86) {
		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 <= -5.6e+159:
		tmp = t_0
	elif x <= -2.6e+34:
		tmp = t_1
	elif x <= -2.6e-64:
		tmp = t_0
	elif x <= 2.9e-13:
		tmp = math.fabs((4.0 / y))
	elif x <= 1.35e+86:
		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 <= -5.6e+159)
		tmp = t_0;
	elseif (x <= -2.6e+34)
		tmp = t_1;
	elseif (x <= -2.6e-64)
		tmp = t_0;
	elseif (x <= 2.9e-13)
		tmp = abs(Float64(4.0 / y));
	elseif (x <= 1.35e+86)
		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 <= -5.6e+159)
		tmp = t_0;
	elseif (x <= -2.6e+34)
		tmp = t_1;
	elseif (x <= -2.6e-64)
		tmp = t_0;
	elseif (x <= 2.9e-13)
		tmp = abs((4.0 / y));
	elseif (x <= 1.35e+86)
		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, -5.6e+159], t$95$0, If[LessEqual[x, -2.6e+34], t$95$1, If[LessEqual[x, -2.6e-64], t$95$0, If[LessEqual[x, 2.9e-13], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.35e+86], 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 -5.6 \cdot 10^{+159}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -2.6 \cdot 10^{+34}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -2.6 \cdot 10^{-64}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 1.35 \cdot 10^{+86}:\\
\;\;\;\;\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 < -5.6000000000000002e159 or -2.59999999999999997e34 < x < -2.6e-64

    1. Initial program 83.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{1 \cdot z}{\frac{y}{x}}}\right| \]
      11. *-un-lft-identity71.7%

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

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

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

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

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

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

    if -5.6000000000000002e159 < x < -2.59999999999999997e34 or 1.35000000000000009e86 < x

    1. Initial program 87.1%

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

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

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

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

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

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

    if -2.6e-64 < x < 2.8999999999999998e-13

    1. Initial program 97.0%

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

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

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

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

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

    if 2.8999999999999998e-13 < x < 1.35000000000000009e86

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.6 \cdot 10^{+159}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -2.6 \cdot 10^{+34}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -2.6 \cdot 10^{-64}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{-13}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{+86}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 4: 99.4% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -8.4e13 or 2.2000000000000002e127 < x

    1. Initial program 82.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.4e13 < x < 2.2000000000000002e127

    1. Initial program 97.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 99.8% accurate, 1.0× speedup?

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

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


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

    1. Initial program 89.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      12. div-sub97.0%

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

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

    if 3.4500000000000001e-18 < y

    1. Initial program 98.2%

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

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

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

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

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

Alternative 6: 87.8% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{-38} \lor \neg \left(x \leq 3.5 \cdot 10^{-13}\right):\\ \;\;\;\;\left|\frac{x}{\frac{y}{1 - z}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\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 (or (<= x -4.8e-38) (not (<= x 3.5e-13)))
   (fabs (/ x (/ y (- 1.0 z))))
   (fabs (/ (+ x 4.0) y))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -4.8e-38) || !(x <= 3.5e-13)) {
		tmp = fabs((x / (y / (1.0 - z))));
	} else {
		tmp = fabs(((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 ((x <= (-4.8d-38)) .or. (.not. (x <= 3.5d-13))) then
        tmp = abs((x / (y / (1.0d0 - z))))
    else
        tmp = abs(((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 ((x <= -4.8e-38) || !(x <= 3.5e-13)) {
		tmp = Math.abs((x / (y / (1.0 - z))));
	} else {
		tmp = Math.abs(((x + 4.0) / y));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if (x <= -4.8e-38) or not (x <= 3.5e-13):
		tmp = math.fabs((x / (y / (1.0 - z))))
	else:
		tmp = math.fabs(((x + 4.0) / y))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if ((x <= -4.8e-38) || !(x <= 3.5e-13))
		tmp = abs(Float64(x / Float64(y / Float64(1.0 - z))));
	else
		tmp = abs(Float64(Float64(x + 4.0) / y));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -4.8e-38) || ~((x <= 3.5e-13)))
		tmp = abs((x / (y / (1.0 - z))));
	else
		tmp = abs(((x + 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, -4.8e-38], N[Not[LessEqual[x, 3.5e-13]], $MachinePrecision]], N[Abs[N[(x / N[(y / N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.8 \cdot 10^{-38} \lor \neg \left(x \leq 3.5 \cdot 10^{-13}\right):\\
\;\;\;\;\left|\frac{x}{\frac{y}{1 - z}}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4.80000000000000044e-38 or 3.5000000000000002e-13 < x

    1. Initial program 86.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.80000000000000044e-38 < x < 3.5000000000000002e-13

    1. Initial program 97.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 86.6% accurate, 1.0× speedup?

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

\mathbf{elif}\;z \leq 6.8 \cdot 10^{+41}:\\
\;\;\;\;\left|\frac{x + 4}{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 < -7.0000000000000001e81

    1. Initial program 96.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{1 \cdot z}{\frac{y}{x}}}\right| \]
      11. *-un-lft-identity83.2%

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

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

    if -7.0000000000000001e81 < z < 6.79999999999999996e41

    1. Initial program 91.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.79999999999999996e41 < z

    1. Initial program 88.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{1 \cdot z}{\frac{y}{x}}}\right| \]
      11. *-un-lft-identity72.5%

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

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

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

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

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

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

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

Alternative 8: 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 85.5%

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

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

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

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

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

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

    if -10.5 < x < 4

    1. Initial program 97.3%

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

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

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

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

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

    \[\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 9: 39.7% 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.5%

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

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

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

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

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

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

Reproduce

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