fabs fraction 1

Percentage Accurate: 91.5% → 97.9%
Time: 9.0s
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.5% 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.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{+58}:\\ \;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4 + x \cdot \left(1 - z\right)}{y}\right|\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -2e+58)
   (fabs (fma x (/ z y) (/ (- -4.0 x) y)))
   (fabs (/ (+ 4.0 (* x (- 1.0 z))) y))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -2e+58) {
		tmp = fabs(fma(x, (z / y), ((-4.0 - x) / y)));
	} else {
		tmp = fabs(((4.0 + (x * (1.0 - z))) / y));
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (y <= -2e+58)
		tmp = abs(fma(x, Float64(z / y), Float64(Float64(-4.0 - x) / y)));
	else
		tmp = abs(Float64(Float64(4.0 + Float64(x * Float64(1.0 - z))) / y));
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[y, -2e+58], N[Abs[N[(x * N[(z / y), $MachinePrecision] + N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(4.0 + N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{+58}:\\
\;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|\\

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


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

    1. Initial program 96.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999989e58 < y

    1. Initial program 92.4%

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

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

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

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

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

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

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

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

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

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

        \[\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/94.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--98.9%

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

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

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

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

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

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

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

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

Alternative 2: 66.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ t_1 := \left|x \cdot \frac{z}{y}\right|\\ \mathbf{if}\;x \leq -2.15 \cdot 10^{+76}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.52 \cdot 10^{-21}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{-43}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{+120} \lor \neg \left(x \leq 4.2 \cdot 10^{+190}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (/ x y))) (t_1 (fabs (* x (/ z y)))))
   (if (<= x -2.15e+76)
     t_0
     (if (<= x -1.52e-21)
       t_1
       (if (<= x 3.3e-43)
         (fabs (/ 4.0 y))
         (if (or (<= x 1.7e+120) (not (<= x 4.2e+190))) t_1 t_0))))))
double code(double x, double y, double z) {
	double t_0 = fabs((x / y));
	double t_1 = fabs((x * (z / y)));
	double tmp;
	if (x <= -2.15e+76) {
		tmp = t_0;
	} else if (x <= -1.52e-21) {
		tmp = t_1;
	} else if (x <= 3.3e-43) {
		tmp = fabs((4.0 / y));
	} else if ((x <= 1.7e+120) || !(x <= 4.2e+190)) {
		tmp = t_1;
	} 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((x / y))
    t_1 = abs((x * (z / y)))
    if (x <= (-2.15d+76)) then
        tmp = t_0
    else if (x <= (-1.52d-21)) then
        tmp = t_1
    else if (x <= 3.3d-43) then
        tmp = abs((4.0d0 / y))
    else if ((x <= 1.7d+120) .or. (.not. (x <= 4.2d+190))) then
        tmp = t_1
    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 / y));
	double t_1 = Math.abs((x * (z / y)));
	double tmp;
	if (x <= -2.15e+76) {
		tmp = t_0;
	} else if (x <= -1.52e-21) {
		tmp = t_1;
	} else if (x <= 3.3e-43) {
		tmp = Math.abs((4.0 / y));
	} else if ((x <= 1.7e+120) || !(x <= 4.2e+190)) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.fabs((x / y))
	t_1 = math.fabs((x * (z / y)))
	tmp = 0
	if x <= -2.15e+76:
		tmp = t_0
	elif x <= -1.52e-21:
		tmp = t_1
	elif x <= 3.3e-43:
		tmp = math.fabs((4.0 / y))
	elif (x <= 1.7e+120) or not (x <= 4.2e+190):
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = abs(Float64(x / y))
	t_1 = abs(Float64(x * Float64(z / y)))
	tmp = 0.0
	if (x <= -2.15e+76)
		tmp = t_0;
	elseif (x <= -1.52e-21)
		tmp = t_1;
	elseif (x <= 3.3e-43)
		tmp = abs(Float64(4.0 / y));
	elseif ((x <= 1.7e+120) || !(x <= 4.2e+190))
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = abs((x / y));
	t_1 = abs((x * (z / y)));
	tmp = 0.0;
	if (x <= -2.15e+76)
		tmp = t_0;
	elseif (x <= -1.52e-21)
		tmp = t_1;
	elseif (x <= 3.3e-43)
		tmp = abs((4.0 / y));
	elseif ((x <= 1.7e+120) || ~((x <= 4.2e+190)))
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -2.15e+76], t$95$0, If[LessEqual[x, -1.52e-21], t$95$1, If[LessEqual[x, 3.3e-43], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 1.7e+120], N[Not[LessEqual[x, 4.2e+190]], $MachinePrecision]], t$95$1, t$95$0]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -1.52 \cdot 10^{-21}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x \leq 1.7 \cdot 10^{+120} \lor \neg \left(x \leq 4.2 \cdot 10^{+190}\right):\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.14999999999999989e76 or 1.69999999999999999e120 < x < 4.2000000000000001e190

    1. Initial program 86.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{-1}{y} \cdot \left(x + 4\right)} - \frac{-x \cdot z}{y}\right| \]
      10. neg-mul-181.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/81.7%

        \[\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--91.0%

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

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

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

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

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

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

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

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

    if -2.14999999999999989e76 < x < -1.52000000000000009e-21 or 3.30000000000000016e-43 < x < 1.69999999999999999e120 or 4.2000000000000001e190 < x

    1. Initial program 92.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{1 \cdot z}{\frac{y}{x}}}\right)} - 1\right| \]
      10. *-un-lft-identity30.8%

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

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

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

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

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

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

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

    if -1.52000000000000009e-21 < x < 3.30000000000000016e-43

    1. Initial program 96.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.15 \cdot 10^{+76}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.52 \cdot 10^{-21}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{-43}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{+120} \lor \neg \left(x \leq 4.2 \cdot 10^{+190}\right):\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 3: 68.5% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;x \leq -1.05 \cdot 10^{-20} \lor \neg \left(x \leq 4 \cdot 10^{-42}\right):\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.8e79

    1. Initial program 84.5%

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

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

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

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

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

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

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

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

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

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

        \[\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/77.3%

        \[\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--90.1%

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

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

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

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

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

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

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

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

    if -1.8e79 < x < -1.0499999999999999e-20 or 4.00000000000000015e-42 < x

    1. Initial program 92.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.0499999999999999e-20 < x < 4.00000000000000015e-42

    1. Initial program 96.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.8 \cdot 10^{+79}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.05 \cdot 10^{-20} \lor \neg \left(x \leq 4 \cdot 10^{-42}\right):\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array} \]

Alternative 4: 68.0% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;x \leq -1.3 \cdot 10^{-20} \lor \neg \left(x \leq 1.36 \cdot 10^{-41}\right):\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -5.5000000000000003e74

    1. Initial program 84.5%

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

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

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

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

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

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

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

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

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

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

        \[\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/77.3%

        \[\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--90.1%

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

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

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

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

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

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

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

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

    if -5.5000000000000003e74 < x < -1.29999999999999997e-20 or 1.36000000000000009e-41 < x

    1. Initial program 92.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.29999999999999997e-20 < x < 1.36000000000000009e-41

    1. Initial program 96.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.5 \cdot 10^{+74}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.3 \cdot 10^{-20} \lor \neg \left(x \leq 1.36 \cdot 10^{-41}\right):\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array} \]

Alternative 5: 86.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0001 \lor \neg \left(x \leq 1.42 \cdot 10^{-42}\right):\\
\;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.00000000000000005e-4 or 1.42000000000000005e-42 < x

    1. Initial program 90.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{-1}{y} \cdot \left(x + 4\right)} - \frac{-x \cdot z}{y}\right| \]
      10. neg-mul-188.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/88.7%

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000005e-4 < x < 1.42000000000000005e-42

    1. Initial program 96.8%

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

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

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

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

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

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

Alternative 6: 98.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -7800:\\ \;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \leq 40000000:\\ \;\;\;\;\left|\frac{4 - 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 -7800.0)
   (fabs (/ (- 1.0 z) (/ y x)))
   (if (<= x 40000000.0)
     (fabs (/ (- 4.0 (* x z)) y))
     (fabs (* x (/ (- 1.0 z) y))))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -7800.0) {
		tmp = fabs(((1.0 - z) / (y / x)));
	} else if (x <= 40000000.0) {
		tmp = fabs(((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 <= (-7800.0d0)) then
        tmp = abs(((1.0d0 - z) / (y / x)))
    else if (x <= 40000000.0d0) then
        tmp = abs(((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 <= -7800.0) {
		tmp = Math.abs(((1.0 - z) / (y / x)));
	} else if (x <= 40000000.0) {
		tmp = Math.abs(((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 <= -7800.0:
		tmp = math.fabs(((1.0 - z) / (y / x)))
	elif x <= 40000000.0:
		tmp = math.fabs(((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 <= -7800.0)
		tmp = abs(Float64(Float64(1.0 - z) / Float64(y / x)));
	elseif (x <= 40000000.0)
		tmp = abs(Float64(Float64(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 <= -7800.0)
		tmp = abs(((1.0 - z) / (y / x)));
	elseif (x <= 40000000.0)
		tmp = abs(((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, -7800.0], N[Abs[N[(N[(1.0 - z), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 40000000.0], N[Abs[N[(N[(4.0 - 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 -7800:\\
\;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\

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

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


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

    1. Initial program 87.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7800 < x < 4e7

    1. Initial program 97.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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 0 99.9%

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

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

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

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

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

    if 4e7 < x

    1. Initial program 89.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{-1}{y} \cdot \left(x + 4\right)} - \frac{-x \cdot z}{y}\right| \]
      10. neg-mul-189.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/89.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--94.9%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7800:\\ \;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \leq 40000000:\\ \;\;\;\;\left|\frac{4 - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \end{array} \]

Alternative 7: 84.6% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 97.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.15e66 < z < 1.8200000000000001e84

    1. Initial program 93.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.8200000000000001e84 < z

    1. Initial program 88.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 96.2% accurate, 1.0× speedup?

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

\\
\left|\frac{4 + x \cdot \left(1 - z\right)}{y}\right|
\end{array}
Derivation
  1. Initial program 93.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{-1}{y} \cdot \left(x + 4\right)} - \frac{-x \cdot z}{y}\right| \]
    10. neg-mul-194.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/94.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--97.2%

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

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

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

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

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

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

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

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

Alternative 9: 68.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.45 \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.45) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 y))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -1.45) || !(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.45d0)) .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.45) || !(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.45) 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.45) || !(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.45) || ~((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.45], 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.45 \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.44999999999999996 or 4 < x

    1. Initial program 89.1%

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

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

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

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

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

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

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

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

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

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

        \[\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/87.7%

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

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

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

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

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

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

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

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

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

    if -1.44999999999999996 < x < 4

    1. Initial program 97.1%

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

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

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

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

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

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

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

Reproduce

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