fabs fraction 1

Percentage Accurate: 92.0% → 97.8%
Time: 6.5s
Alternatives: 7
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 7 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: 92.0% 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.8% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 90.4%

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

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

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

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

    if 2.8e82 < x

    1. Initial program 90.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 67.3% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|z \cdot \frac{x}{y}\right|\\ t_1 := \left|\frac{4}{y}\right|\\ \mathbf{if}\;x \leq -5.2 \cdot 10^{-79}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.66 \cdot 10^{-108}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.55 \cdot 10^{-77}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{+86} \lor \neg \left(x \leq 1.02 \cdot 10^{+119}\right):\\ \;\;\;\;\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)))) (t_1 (fabs (/ 4.0 y))))
   (if (<= x -5.2e-79)
     t_0
     (if (<= x 1.66e-108)
       t_1
       (if (<= x 2.55e-77)
         t_0
         (if (<= x 4.0)
           t_1
           (if (or (<= x 2.5e+86) (not (<= x 1.02e+119)))
             (fabs (/ x y))
             t_0)))))))
double code(double x, double y, double z) {
	double t_0 = fabs((z * (x / y)));
	double t_1 = fabs((4.0 / y));
	double tmp;
	if (x <= -5.2e-79) {
		tmp = t_0;
	} else if (x <= 1.66e-108) {
		tmp = t_1;
	} else if (x <= 2.55e-77) {
		tmp = t_0;
	} else if (x <= 4.0) {
		tmp = t_1;
	} else if ((x <= 2.5e+86) || !(x <= 1.02e+119)) {
		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) :: t_1
    real(8) :: tmp
    t_0 = abs((z * (x / y)))
    t_1 = abs((4.0d0 / y))
    if (x <= (-5.2d-79)) then
        tmp = t_0
    else if (x <= 1.66d-108) then
        tmp = t_1
    else if (x <= 2.55d-77) then
        tmp = t_0
    else if (x <= 4.0d0) then
        tmp = t_1
    else if ((x <= 2.5d+86) .or. (.not. (x <= 1.02d+119))) 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 t_1 = Math.abs((4.0 / y));
	double tmp;
	if (x <= -5.2e-79) {
		tmp = t_0;
	} else if (x <= 1.66e-108) {
		tmp = t_1;
	} else if (x <= 2.55e-77) {
		tmp = t_0;
	} else if (x <= 4.0) {
		tmp = t_1;
	} else if ((x <= 2.5e+86) || !(x <= 1.02e+119)) {
		tmp = Math.abs((x / y));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.fabs((z * (x / y)))
	t_1 = math.fabs((4.0 / y))
	tmp = 0
	if x <= -5.2e-79:
		tmp = t_0
	elif x <= 1.66e-108:
		tmp = t_1
	elif x <= 2.55e-77:
		tmp = t_0
	elif x <= 4.0:
		tmp = t_1
	elif (x <= 2.5e+86) or not (x <= 1.02e+119):
		tmp = math.fabs((x / y))
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = abs(Float64(z * Float64(x / y)))
	t_1 = abs(Float64(4.0 / y))
	tmp = 0.0
	if (x <= -5.2e-79)
		tmp = t_0;
	elseif (x <= 1.66e-108)
		tmp = t_1;
	elseif (x <= 2.55e-77)
		tmp = t_0;
	elseif (x <= 4.0)
		tmp = t_1;
	elseif ((x <= 2.5e+86) || !(x <= 1.02e+119))
		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)));
	t_1 = abs((4.0 / y));
	tmp = 0.0;
	if (x <= -5.2e-79)
		tmp = t_0;
	elseif (x <= 1.66e-108)
		tmp = t_1;
	elseif (x <= 2.55e-77)
		tmp = t_0;
	elseif (x <= 4.0)
		tmp = t_1;
	elseif ((x <= 2.5e+86) || ~((x <= 1.02e+119)))
		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]}, Block[{t$95$1 = N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -5.2e-79], t$95$0, If[LessEqual[x, 1.66e-108], t$95$1, If[LessEqual[x, 2.55e-77], t$95$0, If[LessEqual[x, 4.0], t$95$1, If[Or[LessEqual[x, 2.5e+86], N[Not[LessEqual[x, 1.02e+119]], $MachinePrecision]], 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|\\
t_1 := \left|\frac{4}{y}\right|\\
\mathbf{if}\;x \leq -5.2 \cdot 10^{-79}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 1.66 \cdot 10^{-108}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 2.55 \cdot 10^{-77}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 2.5 \cdot 10^{+86} \lor \neg \left(x \leq 1.02 \cdot 10^{+119}\right):\\
\;\;\;\;\left|\frac{x}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -5.19999999999999987e-79 or 1.65999999999999993e-108 < x < 2.55000000000000016e-77 or 2.4999999999999999e86 < x < 1.02e119

    1. Initial program 86.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.19999999999999987e-79 < x < 1.65999999999999993e-108 or 2.55000000000000016e-77 < x < 4

    1. Initial program 96.1%

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

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

    if 4 < x < 2.4999999999999999e86 or 1.02e119 < x

    1. Initial program 88.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.2 \cdot 10^{-79}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 1.66 \cdot 10^{-108}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 2.55 \cdot 10^{-77}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{+86} \lor \neg \left(x \leq 1.02 \cdot 10^{+119}\right):\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]

Alternative 3: 67.4% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|z \cdot \frac{x}{y}\right|\\ t_1 := \left|\frac{4}{y}\right|\\ \mathbf{if}\;x \leq -7.2 \cdot 10^{-77}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.66 \cdot 10^{-108}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{-78}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{+86} \lor \neg \left(x \leq 1.3 \cdot 10^{+120}\right):\\ \;\;\;\;\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)))) (t_1 (fabs (/ 4.0 y))))
   (if (<= x -7.2e-77)
     t_0
     (if (<= x 1.66e-108)
       t_1
       (if (<= x 2.2e-78)
         (fabs (* x (/ z y)))
         (if (<= x 4.0)
           t_1
           (if (or (<= x 3.1e+86) (not (<= x 1.3e+120)))
             (fabs (/ x y))
             t_0)))))))
double code(double x, double y, double z) {
	double t_0 = fabs((z * (x / y)));
	double t_1 = fabs((4.0 / y));
	double tmp;
	if (x <= -7.2e-77) {
		tmp = t_0;
	} else if (x <= 1.66e-108) {
		tmp = t_1;
	} else if (x <= 2.2e-78) {
		tmp = fabs((x * (z / y)));
	} else if (x <= 4.0) {
		tmp = t_1;
	} else if ((x <= 3.1e+86) || !(x <= 1.3e+120)) {
		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) :: t_1
    real(8) :: tmp
    t_0 = abs((z * (x / y)))
    t_1 = abs((4.0d0 / y))
    if (x <= (-7.2d-77)) then
        tmp = t_0
    else if (x <= 1.66d-108) then
        tmp = t_1
    else if (x <= 2.2d-78) then
        tmp = abs((x * (z / y)))
    else if (x <= 4.0d0) then
        tmp = t_1
    else if ((x <= 3.1d+86) .or. (.not. (x <= 1.3d+120))) 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 t_1 = Math.abs((4.0 / y));
	double tmp;
	if (x <= -7.2e-77) {
		tmp = t_0;
	} else if (x <= 1.66e-108) {
		tmp = t_1;
	} else if (x <= 2.2e-78) {
		tmp = Math.abs((x * (z / y)));
	} else if (x <= 4.0) {
		tmp = t_1;
	} else if ((x <= 3.1e+86) || !(x <= 1.3e+120)) {
		tmp = Math.abs((x / y));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.fabs((z * (x / y)))
	t_1 = math.fabs((4.0 / y))
	tmp = 0
	if x <= -7.2e-77:
		tmp = t_0
	elif x <= 1.66e-108:
		tmp = t_1
	elif x <= 2.2e-78:
		tmp = math.fabs((x * (z / y)))
	elif x <= 4.0:
		tmp = t_1
	elif (x <= 3.1e+86) or not (x <= 1.3e+120):
		tmp = math.fabs((x / y))
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = abs(Float64(z * Float64(x / y)))
	t_1 = abs(Float64(4.0 / y))
	tmp = 0.0
	if (x <= -7.2e-77)
		tmp = t_0;
	elseif (x <= 1.66e-108)
		tmp = t_1;
	elseif (x <= 2.2e-78)
		tmp = abs(Float64(x * Float64(z / y)));
	elseif (x <= 4.0)
		tmp = t_1;
	elseif ((x <= 3.1e+86) || !(x <= 1.3e+120))
		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)));
	t_1 = abs((4.0 / y));
	tmp = 0.0;
	if (x <= -7.2e-77)
		tmp = t_0;
	elseif (x <= 1.66e-108)
		tmp = t_1;
	elseif (x <= 2.2e-78)
		tmp = abs((x * (z / y)));
	elseif (x <= 4.0)
		tmp = t_1;
	elseif ((x <= 3.1e+86) || ~((x <= 1.3e+120)))
		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]}, Block[{t$95$1 = N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -7.2e-77], t$95$0, If[LessEqual[x, 1.66e-108], t$95$1, If[LessEqual[x, 2.2e-78], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.0], t$95$1, If[Or[LessEqual[x, 3.1e+86], N[Not[LessEqual[x, 1.3e+120]], $MachinePrecision]], 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|\\
t_1 := \left|\frac{4}{y}\right|\\
\mathbf{if}\;x \leq -7.2 \cdot 10^{-77}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 1.66 \cdot 10^{-108}:\\
\;\;\;\;t_1\\

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

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

\mathbf{elif}\;x \leq 3.1 \cdot 10^{+86} \lor \neg \left(x \leq 1.3 \cdot 10^{+120}\right):\\
\;\;\;\;\left|\frac{x}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -7.2e-77 or 3.1000000000000002e86 < x < 1.2999999999999999e120

    1. Initial program 86.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{z \cdot \left(-x\right)}{y}}\right| \]
      2. add-cube-cbrt57.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.2e-77 < x < 1.65999999999999993e-108 or 2.1999999999999999e-78 < x < 4

    1. Initial program 96.1%

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

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

    if 1.65999999999999993e-108 < x < 2.1999999999999999e-78

    1. Initial program 86.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4 < x < 3.1000000000000002e86 or 1.2999999999999999e120 < x

    1. Initial program 88.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7.2 \cdot 10^{-77}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 1.66 \cdot 10^{-108}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{-78}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{+86} \lor \neg \left(x \leq 1.3 \cdot 10^{+120}\right):\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]

Alternative 4: 85.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|\frac{4}{y}\right|\\ t_1 := \left|\frac{1 - z}{\frac{y}{x}}\right|\\ \mathbf{if}\;x \leq -5.6 \cdot 10^{-77}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{-117}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.02 \cdot 10^{-78}:\\ \;\;\;\;\left|\frac{x \cdot \left(1 - z\right)}{y}\right|\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-9}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (/ 4.0 y))) (t_1 (fabs (/ (- 1.0 z) (/ y x)))))
   (if (<= x -5.6e-77)
     t_1
     (if (<= x 9.2e-117)
       t_0
       (if (<= x 2.02e-78)
         (fabs (/ (* x (- 1.0 z)) y))
         (if (<= x 2.7e-9) t_0 t_1))))))
double code(double x, double y, double z) {
	double t_0 = fabs((4.0 / y));
	double t_1 = fabs(((1.0 - z) / (y / x)));
	double tmp;
	if (x <= -5.6e-77) {
		tmp = t_1;
	} else if (x <= 9.2e-117) {
		tmp = t_0;
	} else if (x <= 2.02e-78) {
		tmp = fabs(((x * (1.0 - z)) / y));
	} else if (x <= 2.7e-9) {
		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 / y))
    t_1 = abs(((1.0d0 - z) / (y / x)))
    if (x <= (-5.6d-77)) then
        tmp = t_1
    else if (x <= 9.2d-117) then
        tmp = t_0
    else if (x <= 2.02d-78) then
        tmp = abs(((x * (1.0d0 - z)) / y))
    else if (x <= 2.7d-9) 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 / y));
	double t_1 = Math.abs(((1.0 - z) / (y / x)));
	double tmp;
	if (x <= -5.6e-77) {
		tmp = t_1;
	} else if (x <= 9.2e-117) {
		tmp = t_0;
	} else if (x <= 2.02e-78) {
		tmp = Math.abs(((x * (1.0 - z)) / y));
	} else if (x <= 2.7e-9) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.fabs((4.0 / y))
	t_1 = math.fabs(((1.0 - z) / (y / x)))
	tmp = 0
	if x <= -5.6e-77:
		tmp = t_1
	elif x <= 9.2e-117:
		tmp = t_0
	elif x <= 2.02e-78:
		tmp = math.fabs(((x * (1.0 - z)) / y))
	elif x <= 2.7e-9:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = abs(Float64(4.0 / y))
	t_1 = abs(Float64(Float64(1.0 - z) / Float64(y / x)))
	tmp = 0.0
	if (x <= -5.6e-77)
		tmp = t_1;
	elseif (x <= 9.2e-117)
		tmp = t_0;
	elseif (x <= 2.02e-78)
		tmp = abs(Float64(Float64(x * Float64(1.0 - z)) / y));
	elseif (x <= 2.7e-9)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = abs((4.0 / y));
	t_1 = abs(((1.0 - z) / (y / x)));
	tmp = 0.0;
	if (x <= -5.6e-77)
		tmp = t_1;
	elseif (x <= 9.2e-117)
		tmp = t_0;
	elseif (x <= 2.02e-78)
		tmp = abs(((x * (1.0 - z)) / y));
	elseif (x <= 2.7e-9)
		tmp = t_0;
	else
		tmp = t_1;
	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[(N[(1.0 - z), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -5.6e-77], t$95$1, If[LessEqual[x, 9.2e-117], t$95$0, If[LessEqual[x, 2.02e-78], N[Abs[N[(N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 2.7e-9], t$95$0, t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 9.2 \cdot 10^{-117}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 2.02 \cdot 10^{-78}:\\
\;\;\;\;\left|\frac{x \cdot \left(1 - z\right)}{y}\right|\\

\mathbf{elif}\;x \leq 2.7 \cdot 10^{-9}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -5.5999999999999999e-77 or 2.7000000000000002e-9 < x

    1. Initial program 87.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.5999999999999999e-77 < x < 9.19999999999999978e-117 or 2.0200000000000001e-78 < x < 2.7000000000000002e-9

    1. Initial program 95.9%

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

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

    if 9.19999999999999978e-117 < x < 2.0200000000000001e-78

    1. Initial program 91.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.6 \cdot 10^{-77}:\\ \;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{-117}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 2.02 \cdot 10^{-78}:\\ \;\;\;\;\left|\frac{x \cdot \left(1 - z\right)}{y}\right|\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-9}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\ \end{array} \]

Alternative 5: 85.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+38} \lor \neg \left(z \leq 4.5 \cdot 10^{+30}\right):\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.99999999999999995e38 or 4.49999999999999995e30 < z

    1. Initial program 91.7%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{z \cdot \left(-x\right)}{y}}\right| \]
      2. add-cube-cbrt72.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999995e38 < z < 4.49999999999999995e30

    1. Initial program 89.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 69.3% 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 85.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.55000000000000004 < x < 4

    1. Initial program 96.2%

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

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

    \[\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 7: 40.4% 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 90.3%

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

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

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

Reproduce

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