fabs fraction 1

Percentage Accurate: 91.9% → 97.6%
Time: 7.4s
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.9% 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: 97.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.5 \cdot 10^{+81}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\

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


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

    1. Initial program 94.2%

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

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

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

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

    if 6.4999999999999996e81 < x

    1. Initial program 87.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x}{y} + \color{blue}{\left(-x \cdot \frac{z}{y}\right)}\right| \]
      9. unsub-neg93.7%

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

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

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

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

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

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

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

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

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

Alternative 2: 64.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|\frac{4}{y}\right|\\ t_1 := \left|\frac{x}{y}\right|\\ t_2 := \left|x \cdot \frac{z}{y}\right|\\ \mathbf{if}\;x \leq -2.15 \cdot 10^{+172}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3.85 \cdot 10^{-32}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{-124}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{-51}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{+50} \lor \neg \left(x \leq 1.05 \cdot 10^{+120}\right) \land x \leq 1.35 \cdot 10^{+156}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (/ 4.0 y))) (t_1 (fabs (/ x y))) (t_2 (fabs (* x (/ z y)))))
   (if (<= x -2.15e+172)
     t_1
     (if (<= x -3.85e-32)
       t_2
       (if (<= x 2.9e-124)
         t_0
         (if (<= x 1.9e-51)
           t_2
           (if (<= x 4.0)
             t_0
             (if (or (<= x 2.6e+50)
                     (and (not (<= x 1.05e+120)) (<= x 1.35e+156)))
               t_1
               t_2))))))))
double code(double x, double y, double z) {
	double t_0 = fabs((4.0 / y));
	double t_1 = fabs((x / y));
	double t_2 = fabs((x * (z / y)));
	double tmp;
	if (x <= -2.15e+172) {
		tmp = t_1;
	} else if (x <= -3.85e-32) {
		tmp = t_2;
	} else if (x <= 2.9e-124) {
		tmp = t_0;
	} else if (x <= 1.9e-51) {
		tmp = t_2;
	} else if (x <= 4.0) {
		tmp = t_0;
	} else if ((x <= 2.6e+50) || (!(x <= 1.05e+120) && (x <= 1.35e+156))) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = abs((4.0d0 / y))
    t_1 = abs((x / y))
    t_2 = abs((x * (z / y)))
    if (x <= (-2.15d+172)) then
        tmp = t_1
    else if (x <= (-3.85d-32)) then
        tmp = t_2
    else if (x <= 2.9d-124) then
        tmp = t_0
    else if (x <= 1.9d-51) then
        tmp = t_2
    else if (x <= 4.0d0) then
        tmp = t_0
    else if ((x <= 2.6d+50) .or. (.not. (x <= 1.05d+120)) .and. (x <= 1.35d+156)) then
        tmp = t_1
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = Math.abs((4.0 / y));
	double t_1 = Math.abs((x / y));
	double t_2 = Math.abs((x * (z / y)));
	double tmp;
	if (x <= -2.15e+172) {
		tmp = t_1;
	} else if (x <= -3.85e-32) {
		tmp = t_2;
	} else if (x <= 2.9e-124) {
		tmp = t_0;
	} else if (x <= 1.9e-51) {
		tmp = t_2;
	} else if (x <= 4.0) {
		tmp = t_0;
	} else if ((x <= 2.6e+50) || (!(x <= 1.05e+120) && (x <= 1.35e+156))) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.fabs((4.0 / y))
	t_1 = math.fabs((x / y))
	t_2 = math.fabs((x * (z / y)))
	tmp = 0
	if x <= -2.15e+172:
		tmp = t_1
	elif x <= -3.85e-32:
		tmp = t_2
	elif x <= 2.9e-124:
		tmp = t_0
	elif x <= 1.9e-51:
		tmp = t_2
	elif x <= 4.0:
		tmp = t_0
	elif (x <= 2.6e+50) or (not (x <= 1.05e+120) and (x <= 1.35e+156)):
		tmp = t_1
	else:
		tmp = t_2
	return tmp
function code(x, y, z)
	t_0 = abs(Float64(4.0 / y))
	t_1 = abs(Float64(x / y))
	t_2 = abs(Float64(x * Float64(z / y)))
	tmp = 0.0
	if (x <= -2.15e+172)
		tmp = t_1;
	elseif (x <= -3.85e-32)
		tmp = t_2;
	elseif (x <= 2.9e-124)
		tmp = t_0;
	elseif (x <= 1.9e-51)
		tmp = t_2;
	elseif (x <= 4.0)
		tmp = t_0;
	elseif ((x <= 2.6e+50) || (!(x <= 1.05e+120) && (x <= 1.35e+156)))
		tmp = t_1;
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = abs((4.0 / y));
	t_1 = abs((x / y));
	t_2 = abs((x * (z / y)));
	tmp = 0.0;
	if (x <= -2.15e+172)
		tmp = t_1;
	elseif (x <= -3.85e-32)
		tmp = t_2;
	elseif (x <= 2.9e-124)
		tmp = t_0;
	elseif (x <= 1.9e-51)
		tmp = t_2;
	elseif (x <= 4.0)
		tmp = t_0;
	elseif ((x <= 2.6e+50) || (~((x <= 1.05e+120)) && (x <= 1.35e+156)))
		tmp = t_1;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -2.15e+172], t$95$1, If[LessEqual[x, -3.85e-32], t$95$2, If[LessEqual[x, 2.9e-124], t$95$0, If[LessEqual[x, 1.9e-51], t$95$2, If[LessEqual[x, 4.0], t$95$0, If[Or[LessEqual[x, 2.6e+50], And[N[Not[LessEqual[x, 1.05e+120]], $MachinePrecision], LessEqual[x, 1.35e+156]]], t$95$1, t$95$2]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left|\frac{4}{y}\right|\\
t_1 := \left|\frac{x}{y}\right|\\
t_2 := \left|x \cdot \frac{z}{y}\right|\\
\mathbf{if}\;x \leq -2.15 \cdot 10^{+172}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -3.85 \cdot 10^{-32}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 2.9 \cdot 10^{-124}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 1.9 \cdot 10^{-51}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;x \leq 2.6 \cdot 10^{+50} \lor \neg \left(x \leq 1.05 \cdot 10^{+120}\right) \land x \leq 1.35 \cdot 10^{+156}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.1500000000000001e172 or 4 < x < 2.6000000000000002e50 or 1.05e120 < x < 1.35e156

    1. Initial program 89.3%

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

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

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

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

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

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

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

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

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

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

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

    if -2.1500000000000001e172 < x < -3.8499999999999998e-32 or 2.9000000000000002e-124 < x < 1.90000000000000001e-51 or 2.6000000000000002e50 < x < 1.05e120 or 1.35e156 < x

    1. Initial program 88.2%

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

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

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

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

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

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

    if -3.8499999999999998e-32 < x < 2.9000000000000002e-124 or 1.90000000000000001e-51 < x < 4

    1. Initial program 98.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.15 \cdot 10^{+172}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -3.85 \cdot 10^{-32}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{-124}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{-51}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{+50} \lor \neg \left(x \leq 1.05 \cdot 10^{+120}\right) \land x \leq 1.35 \cdot 10^{+156}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \end{array} \]

Alternative 3: 85.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|\frac{-4 - x}{y}\right|\\ t_1 := \left|x \cdot \frac{1 - z}{y}\right|\\ \mathbf{if}\;x \leq -3.5 \cdot 10^{-32}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-125}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.25 \cdot 10^{-51}:\\ \;\;\;\;\left|\frac{x \cdot z}{y}\right|\\ \mathbf{elif}\;x \leq 0.00335:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (/ (- -4.0 x) y))) (t_1 (fabs (* x (/ (- 1.0 z) y)))))
   (if (<= x -3.5e-32)
     t_1
     (if (<= x 4e-125)
       t_0
       (if (<= x 2.25e-51)
         (fabs (/ (* x z) y))
         (if (<= x 0.00335) t_0 t_1))))))
double code(double x, double y, double z) {
	double t_0 = fabs(((-4.0 - x) / y));
	double t_1 = fabs((x * ((1.0 - z) / y)));
	double tmp;
	if (x <= -3.5e-32) {
		tmp = t_1;
	} else if (x <= 4e-125) {
		tmp = t_0;
	} else if (x <= 2.25e-51) {
		tmp = fabs(((x * z) / y));
	} else if (x <= 0.00335) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
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((((-4.0d0) - x) / y))
    t_1 = abs((x * ((1.0d0 - z) / y)))
    if (x <= (-3.5d-32)) then
        tmp = t_1
    else if (x <= 4d-125) then
        tmp = t_0
    else if (x <= 2.25d-51) then
        tmp = abs(((x * z) / y))
    else if (x <= 0.00335d0) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = Math.abs(((-4.0 - x) / y));
	double t_1 = Math.abs((x * ((1.0 - z) / y)));
	double tmp;
	if (x <= -3.5e-32) {
		tmp = t_1;
	} else if (x <= 4e-125) {
		tmp = t_0;
	} else if (x <= 2.25e-51) {
		tmp = Math.abs(((x * z) / y));
	} else if (x <= 0.00335) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.fabs(((-4.0 - x) / y))
	t_1 = math.fabs((x * ((1.0 - z) / y)))
	tmp = 0
	if x <= -3.5e-32:
		tmp = t_1
	elif x <= 4e-125:
		tmp = t_0
	elif x <= 2.25e-51:
		tmp = math.fabs(((x * z) / y))
	elif x <= 0.00335:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = abs(Float64(Float64(-4.0 - x) / y))
	t_1 = abs(Float64(x * Float64(Float64(1.0 - z) / y)))
	tmp = 0.0
	if (x <= -3.5e-32)
		tmp = t_1;
	elseif (x <= 4e-125)
		tmp = t_0;
	elseif (x <= 2.25e-51)
		tmp = abs(Float64(Float64(x * z) / y));
	elseif (x <= 0.00335)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = abs(((-4.0 - x) / y));
	t_1 = abs((x * ((1.0 - z) / y)));
	tmp = 0.0;
	if (x <= -3.5e-32)
		tmp = t_1;
	elseif (x <= 4e-125)
		tmp = t_0;
	elseif (x <= 2.25e-51)
		tmp = abs(((x * z) / y));
	elseif (x <= 0.00335)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x * N[(N[(1.0 - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -3.5e-32], t$95$1, If[LessEqual[x, 4e-125], t$95$0, If[LessEqual[x, 2.25e-51], N[Abs[N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 0.00335], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left|\frac{-4 - x}{y}\right|\\
t_1 := \left|x \cdot \frac{1 - z}{y}\right|\\
\mathbf{if}\;x \leq -3.5 \cdot 10^{-32}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 4 \cdot 10^{-125}:\\
\;\;\;\;t_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -3.4999999999999999e-32 or 0.00335000000000000011 < x

    1. Initial program 88.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x}{y} + \color{blue}{\left(-x \cdot \frac{z}{y}\right)}\right| \]
      9. unsub-neg92.3%

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

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

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

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

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

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

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

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

    if -3.4999999999999999e-32 < x < 4.00000000000000005e-125 or 2.24999999999999987e-51 < x < 0.00335000000000000011

    1. Initial program 98.3%

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

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

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

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

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

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

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

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

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

    if 4.00000000000000005e-125 < x < 2.24999999999999987e-51

    1. Initial program 93.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.5 \cdot 10^{-32}:\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-125}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{elif}\;x \leq 2.25 \cdot 10^{-51}:\\ \;\;\;\;\left|\frac{x \cdot z}{y}\right|\\ \mathbf{elif}\;x \leq 0.00335:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \end{array} \]

Alternative 4: 85.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|x \cdot \frac{1 - z}{y}\right|\\ \mathbf{if}\;x \leq -4.8 \cdot 10^{-32}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{-124}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-51}:\\ \;\;\;\;\left|\frac{x \cdot z}{y}\right|\\ \mathbf{elif}\;x \leq 0.00385:\\ \;\;\;\;\left|\frac{4}{y} + \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (* x (/ (- 1.0 z) y)))))
   (if (<= x -4.8e-32)
     t_0
     (if (<= x 5.6e-124)
       (fabs (/ (- -4.0 x) y))
       (if (<= x 3e-51)
         (fabs (/ (* x z) y))
         (if (<= x 0.00385) (fabs (+ (/ 4.0 y) (/ x y))) t_0))))))
double code(double x, double y, double z) {
	double t_0 = fabs((x * ((1.0 - z) / y)));
	double tmp;
	if (x <= -4.8e-32) {
		tmp = t_0;
	} else if (x <= 5.6e-124) {
		tmp = fabs(((-4.0 - x) / y));
	} else if (x <= 3e-51) {
		tmp = fabs(((x * z) / y));
	} else if (x <= 0.00385) {
		tmp = fabs(((4.0 / y) + (x / y)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
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 * ((1.0d0 - z) / y)))
    if (x <= (-4.8d-32)) then
        tmp = t_0
    else if (x <= 5.6d-124) then
        tmp = abs((((-4.0d0) - x) / y))
    else if (x <= 3d-51) then
        tmp = abs(((x * z) / y))
    else if (x <= 0.00385d0) then
        tmp = abs(((4.0d0 / y) + (x / y)))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = Math.abs((x * ((1.0 - z) / y)));
	double tmp;
	if (x <= -4.8e-32) {
		tmp = t_0;
	} else if (x <= 5.6e-124) {
		tmp = Math.abs(((-4.0 - x) / y));
	} else if (x <= 3e-51) {
		tmp = Math.abs(((x * z) / y));
	} else if (x <= 0.00385) {
		tmp = Math.abs(((4.0 / y) + (x / y)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.fabs((x * ((1.0 - z) / y)))
	tmp = 0
	if x <= -4.8e-32:
		tmp = t_0
	elif x <= 5.6e-124:
		tmp = math.fabs(((-4.0 - x) / y))
	elif x <= 3e-51:
		tmp = math.fabs(((x * z) / y))
	elif x <= 0.00385:
		tmp = math.fabs(((4.0 / y) + (x / y)))
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = abs(Float64(x * Float64(Float64(1.0 - z) / y)))
	tmp = 0.0
	if (x <= -4.8e-32)
		tmp = t_0;
	elseif (x <= 5.6e-124)
		tmp = abs(Float64(Float64(-4.0 - x) / y));
	elseif (x <= 3e-51)
		tmp = abs(Float64(Float64(x * z) / y));
	elseif (x <= 0.00385)
		tmp = abs(Float64(Float64(4.0 / y) + Float64(x / y)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = abs((x * ((1.0 - z) / y)));
	tmp = 0.0;
	if (x <= -4.8e-32)
		tmp = t_0;
	elseif (x <= 5.6e-124)
		tmp = abs(((-4.0 - x) / y));
	elseif (x <= 3e-51)
		tmp = abs(((x * z) / y));
	elseif (x <= 0.00385)
		tmp = abs(((4.0 / y) + (x / y)));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(x * N[(N[(1.0 - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -4.8e-32], t$95$0, If[LessEqual[x, 5.6e-124], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 3e-51], N[Abs[N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 0.00385], N[Abs[N[(N[(4.0 / y), $MachinePrecision] + N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left|x \cdot \frac{1 - z}{y}\right|\\
\mathbf{if}\;x \leq -4.8 \cdot 10^{-32}:\\
\;\;\;\;t_0\\

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

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

\mathbf{elif}\;x \leq 0.00385:\\
\;\;\;\;\left|\frac{4}{y} + \frac{x}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -4.8000000000000003e-32 or 0.0038500000000000001 < x

    1. Initial program 88.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{x}{y} + \color{blue}{\left(-x \cdot \frac{z}{y}\right)}\right| \]
      9. unsub-neg92.3%

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

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

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

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

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

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

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

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

    if -4.8000000000000003e-32 < x < 5.59999999999999996e-124

    1. Initial program 98.2%

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

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

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

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

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

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

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

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

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

    if 5.59999999999999996e-124 < x < 3.00000000000000002e-51

    1. Initial program 93.0%

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

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

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

    if 3.00000000000000002e-51 < x < 0.0038500000000000001

    1. Initial program 99.7%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{-32}:\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{-124}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-51}:\\ \;\;\;\;\left|\frac{x \cdot z}{y}\right|\\ \mathbf{elif}\;x \leq 0.00385:\\ \;\;\;\;\left|\frac{4}{y} + \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \end{array} \]

Alternative 5: 67.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|z \cdot \frac{x}{y}\right|\\ \mathbf{if}\;x \leq -8.2 \cdot 10^{-32}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{-124}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.06 \cdot 10^{+119} \lor \neg \left(x \leq 1.2 \cdot 10^{+156}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (* z (/ x y)))))
   (if (<= x -8.2e-32)
     t_0
     (if (<= x 5.6e-124)
       (fabs (/ 4.0 y))
       (if (or (<= x 1.06e+119) (not (<= x 1.2e+156))) t_0 (fabs (/ x y)))))))
double code(double x, double y, double z) {
	double t_0 = fabs((z * (x / y)));
	double tmp;
	if (x <= -8.2e-32) {
		tmp = t_0;
	} else if (x <= 5.6e-124) {
		tmp = fabs((4.0 / y));
	} else if ((x <= 1.06e+119) || !(x <= 1.2e+156)) {
		tmp = t_0;
	} else {
		tmp = fabs((x / y));
	}
	return tmp;
}
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((z * (x / y)))
    if (x <= (-8.2d-32)) then
        tmp = t_0
    else if (x <= 5.6d-124) then
        tmp = abs((4.0d0 / y))
    else if ((x <= 1.06d+119) .or. (.not. (x <= 1.2d+156))) then
        tmp = t_0
    else
        tmp = abs((x / y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = Math.abs((z * (x / y)));
	double tmp;
	if (x <= -8.2e-32) {
		tmp = t_0;
	} else if (x <= 5.6e-124) {
		tmp = Math.abs((4.0 / y));
	} else if ((x <= 1.06e+119) || !(x <= 1.2e+156)) {
		tmp = t_0;
	} else {
		tmp = Math.abs((x / y));
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.fabs((z * (x / y)))
	tmp = 0
	if x <= -8.2e-32:
		tmp = t_0
	elif x <= 5.6e-124:
		tmp = math.fabs((4.0 / y))
	elif (x <= 1.06e+119) or not (x <= 1.2e+156):
		tmp = t_0
	else:
		tmp = math.fabs((x / y))
	return tmp
function code(x, y, z)
	t_0 = abs(Float64(z * Float64(x / y)))
	tmp = 0.0
	if (x <= -8.2e-32)
		tmp = t_0;
	elseif (x <= 5.6e-124)
		tmp = abs(Float64(4.0 / y));
	elseif ((x <= 1.06e+119) || !(x <= 1.2e+156))
		tmp = t_0;
	else
		tmp = abs(Float64(x / y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = abs((z * (x / y)));
	tmp = 0.0;
	if (x <= -8.2e-32)
		tmp = t_0;
	elseif (x <= 5.6e-124)
		tmp = abs((4.0 / y));
	elseif ((x <= 1.06e+119) || ~((x <= 1.2e+156)))
		tmp = t_0;
	else
		tmp = abs((x / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -8.2e-32], t$95$0, If[LessEqual[x, 5.6e-124], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 1.06e+119], N[Not[LessEqual[x, 1.2e+156]], $MachinePrecision]], t$95$0, N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left|z \cdot \frac{x}{y}\right|\\
\mathbf{if}\;x \leq -8.2 \cdot 10^{-32}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 1.06 \cdot 10^{+119} \lor \neg \left(x \leq 1.2 \cdot 10^{+156}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -8.1999999999999995e-32 or 5.59999999999999996e-124 < x < 1.0599999999999999e119 or 1.2000000000000001e156 < x

    1. Initial program 88.5%

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

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

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

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

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

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

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

    if -8.1999999999999995e-32 < x < 5.59999999999999996e-124

    1. Initial program 98.2%

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

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

    if 1.0599999999999999e119 < x < 1.2000000000000001e156

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -8.2 \cdot 10^{-32}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{-124}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.06 \cdot 10^{+119} \lor \neg \left(x \leq 1.2 \cdot 10^{+156}\right):\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 6: 67.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|z \cdot \frac{x}{y}\right|\\ \mathbf{if}\;x \leq -9.3 \cdot 10^{-32}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-124}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{+119}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{+156}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (* z (/ x y)))))
   (if (<= x -9.3e-32)
     t_0
     (if (<= x 5.5e-124)
       (fabs (/ 4.0 y))
       (if (<= x 2.1e+119)
         (fabs (/ z (/ y x)))
         (if (<= x 1.2e+156) (fabs (/ x y)) t_0))))))
double code(double x, double y, double z) {
	double t_0 = fabs((z * (x / y)));
	double tmp;
	if (x <= -9.3e-32) {
		tmp = t_0;
	} else if (x <= 5.5e-124) {
		tmp = fabs((4.0 / y));
	} else if (x <= 2.1e+119) {
		tmp = fabs((z / (y / x)));
	} else if (x <= 1.2e+156) {
		tmp = fabs((x / y));
	} else {
		tmp = t_0;
	}
	return tmp;
}
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((z * (x / y)))
    if (x <= (-9.3d-32)) then
        tmp = t_0
    else if (x <= 5.5d-124) then
        tmp = abs((4.0d0 / y))
    else if (x <= 2.1d+119) then
        tmp = abs((z / (y / x)))
    else if (x <= 1.2d+156) then
        tmp = abs((x / y))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = Math.abs((z * (x / y)));
	double tmp;
	if (x <= -9.3e-32) {
		tmp = t_0;
	} else if (x <= 5.5e-124) {
		tmp = Math.abs((4.0 / y));
	} else if (x <= 2.1e+119) {
		tmp = Math.abs((z / (y / x)));
	} else if (x <= 1.2e+156) {
		tmp = Math.abs((x / y));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.fabs((z * (x / y)))
	tmp = 0
	if x <= -9.3e-32:
		tmp = t_0
	elif x <= 5.5e-124:
		tmp = math.fabs((4.0 / y))
	elif x <= 2.1e+119:
		tmp = math.fabs((z / (y / x)))
	elif x <= 1.2e+156:
		tmp = math.fabs((x / y))
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = abs(Float64(z * Float64(x / y)))
	tmp = 0.0
	if (x <= -9.3e-32)
		tmp = t_0;
	elseif (x <= 5.5e-124)
		tmp = abs(Float64(4.0 / y));
	elseif (x <= 2.1e+119)
		tmp = abs(Float64(z / Float64(y / x)));
	elseif (x <= 1.2e+156)
		tmp = abs(Float64(x / y));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = abs((z * (x / y)));
	tmp = 0.0;
	if (x <= -9.3e-32)
		tmp = t_0;
	elseif (x <= 5.5e-124)
		tmp = abs((4.0 / y));
	elseif (x <= 2.1e+119)
		tmp = abs((z / (y / x)));
	elseif (x <= 1.2e+156)
		tmp = abs((x / y));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -9.3e-32], t$95$0, If[LessEqual[x, 5.5e-124], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 2.1e+119], N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.2e+156], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left|z \cdot \frac{x}{y}\right|\\
\mathbf{if}\;x \leq -9.3 \cdot 10^{-32}:\\
\;\;\;\;t_0\\

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

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

\mathbf{elif}\;x \leq 1.2 \cdot 10^{+156}:\\
\;\;\;\;\left|\frac{x}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -9.29999999999999977e-32 or 1.2000000000000001e156 < x

    1. Initial program 85.7%

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

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

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

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

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

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

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

    if -9.29999999999999977e-32 < x < 5.50000000000000016e-124

    1. Initial program 98.2%

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

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

    if 5.50000000000000016e-124 < x < 2.09999999999999983e119

    1. Initial program 95.2%

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

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

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

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

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

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

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

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

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

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

    if 2.09999999999999983e119 < x < 1.2000000000000001e156

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9.3 \cdot 10^{-32}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-124}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{+119}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{+156}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]

Alternative 7: 84.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-32} \lor \neg \left(x \leq 5.6 \cdot 10^{-124}\right):\\ \;\;\;\;\left|\frac{z + -1}{\frac{y}{x}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -5e-32) (not (<= x 5.6e-124)))
   (fabs (/ (+ z -1.0) (/ y x)))
   (fabs (/ (- -4.0 x) y))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -5e-32) || !(x <= 5.6e-124)) {
		tmp = fabs(((z + -1.0) / (y / x)));
	} else {
		tmp = fabs(((-4.0 - x) / y));
	}
	return tmp;
}
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 <= (-5d-32)) .or. (.not. (x <= 5.6d-124))) then
        tmp = abs(((z + (-1.0d0)) / (y / x)))
    else
        tmp = abs((((-4.0d0) - x) / y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -5e-32) || !(x <= 5.6e-124)) {
		tmp = Math.abs(((z + -1.0) / (y / x)));
	} else {
		tmp = Math.abs(((-4.0 - x) / y));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -5e-32) or not (x <= 5.6e-124):
		tmp = math.fabs(((z + -1.0) / (y / x)))
	else:
		tmp = math.fabs(((-4.0 - x) / y))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -5e-32) || !(x <= 5.6e-124))
		tmp = abs(Float64(Float64(z + -1.0) / Float64(y / x)));
	else
		tmp = abs(Float64(Float64(-4.0 - x) / y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -5e-32) || ~((x <= 5.6e-124)))
		tmp = abs(((z + -1.0) / (y / x)));
	else
		tmp = abs(((-4.0 - x) / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -5e-32], N[Not[LessEqual[x, 5.6e-124]], $MachinePrecision]], N[Abs[N[(N[(z + -1.0), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-32} \lor \neg \left(x \leq 5.6 \cdot 10^{-124}\right):\\
\;\;\;\;\left|\frac{z + -1}{\frac{y}{x}}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5e-32 or 5.59999999999999996e-124 < x

    1. Initial program 89.3%

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

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

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

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

        \[\leadsto \left|\frac{\color{blue}{z + \left(-1\right)}}{\frac{y}{x}}\right| \]
      3. metadata-eval92.1%

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

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

    if -5e-32 < x < 5.59999999999999996e-124

    1. Initial program 98.2%

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

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

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

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

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

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

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

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

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

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

Alternative 8: 86.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{+42}:\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\

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

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


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

    1. Initial program 98.4%

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

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

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

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

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

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

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

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

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

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

    if -9.00000000000000025e42 < z < 3.6e34

    1. Initial program 92.9%

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

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

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

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

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

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

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

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

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

    if 3.6e34 < z

    1. Initial program 87.8%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 69.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.55 \lor \neg \left(x \leq 4\right):\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -1.55) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 y))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -1.55) || !(x <= 4.0)) {
		tmp = fabs((x / y));
	} else {
		tmp = fabs((4.0 / y));
	}
	return tmp;
}
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.55d0)) .or. (.not. (x <= 4.0d0))) then
        tmp = abs((x / y))
    else
        tmp = abs((4.0d0 / y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -1.55) || !(x <= 4.0)) {
		tmp = Math.abs((x / y));
	} else {
		tmp = Math.abs((4.0 / y));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -1.55) or not (x <= 4.0):
		tmp = math.fabs((x / y))
	else:
		tmp = math.fabs((4.0 / y))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -1.55) || !(x <= 4.0))
		tmp = abs(Float64(x / y));
	else
		tmp = abs(Float64(4.0 / y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -1.55) || ~((x <= 4.0)))
		tmp = abs((x / y));
	else
		tmp = abs((4.0 / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.55], 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}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \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.55000000000000004 or 4 < x

    1. Initial program 87.4%

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

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

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

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

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

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

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

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

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

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

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

    if -1.55000000000000004 < x < 4

    1. Initial program 97.9%

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

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

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

Alternative 10: 40.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \left|\frac{4}{y}\right| \end{array} \]
(FPCore (x y z) :precision binary64 (fabs (/ 4.0 y)))
double code(double x, double y, double z) {
	return fabs((4.0 / y));
}
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
public static double code(double x, double y, double z) {
	return Math.abs((4.0 / y));
}
def code(x, y, z):
	return math.fabs((4.0 / y))
function code(x, y, z)
	return abs(Float64(4.0 / y))
end
function tmp = code(x, y, z)
	tmp = abs((4.0 / y));
end
code[x_, y_, z_] := N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

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

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

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

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

Reproduce

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