fabs fraction 1

Percentage Accurate: 91.9% → 99.2%
Time: 8.3s
Alternatives: 11
Speedup: 0.9×

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 11 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 91.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.2% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|\frac{x + 4}{y} - z \cdot \frac{x}{y}\right|\\ \mathbf{if}\;t\_0 \leq 5 \cdot 10^{-27}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{elif}\;t\_0 \leq 1.1 \cdot 10^{+296}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(z + -1\right)\right|\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (- (/ (+ x 4.0) y) (* z (/ x y))))))
   (if (<= t_0 5e-27)
     (fabs (/ (- (+ x 4.0) (* x z)) y))
     (if (<= t_0 1.1e+296) t_0 (fabs (* (/ x y) (+ z -1.0)))))))
double code(double x, double y, double z) {
	double t_0 = fabs((((x + 4.0) / y) - (z * (x / y))));
	double tmp;
	if (t_0 <= 5e-27) {
		tmp = fabs((((x + 4.0) - (x * z)) / y));
	} else if (t_0 <= 1.1e+296) {
		tmp = t_0;
	} else {
		tmp = fabs(((x / y) * (z + -1.0)));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = abs((((x + 4.0d0) / y) - (z * (x / y))))
    if (t_0 <= 5d-27) then
        tmp = abs((((x + 4.0d0) - (x * z)) / y))
    else if (t_0 <= 1.1d+296) then
        tmp = t_0
    else
        tmp = abs(((x / y) * (z + (-1.0d0))))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = Math.abs((((x + 4.0) / y) - (z * (x / y))));
	double tmp;
	if (t_0 <= 5e-27) {
		tmp = Math.abs((((x + 4.0) - (x * z)) / y));
	} else if (t_0 <= 1.1e+296) {
		tmp = t_0;
	} else {
		tmp = Math.abs(((x / y) * (z + -1.0)));
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.fabs((((x + 4.0) / y) - (z * (x / y))))
	tmp = 0
	if t_0 <= 5e-27:
		tmp = math.fabs((((x + 4.0) - (x * z)) / y))
	elif t_0 <= 1.1e+296:
		tmp = t_0
	else:
		tmp = math.fabs(((x / y) * (z + -1.0)))
	return tmp
function code(x, y, z)
	t_0 = abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(z * Float64(x / y))))
	tmp = 0.0
	if (t_0 <= 5e-27)
		tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y));
	elseif (t_0 <= 1.1e+296)
		tmp = t_0;
	else
		tmp = abs(Float64(Float64(x / y) * Float64(z + -1.0)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = abs((((x + 4.0) / y) - (z * (x / y))));
	tmp = 0.0;
	if (t_0 <= 5e-27)
		tmp = abs((((x + 4.0) - (x * z)) / y));
	elseif (t_0 <= 1.1e+296)
		tmp = t_0;
	else
		tmp = abs(((x / y) * (z + -1.0)));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 5e-27], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$0, 1.1e+296], t$95$0, N[Abs[N[(N[(x / y), $MachinePrecision] * N[(z + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left|\frac{x + 4}{y} - z \cdot \frac{x}{y}\right|\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{-27}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\

\mathbf{elif}\;t\_0 \leq 1.1 \cdot 10^{+296}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))) < 5.0000000000000002e-27

    1. Initial program 91.6%

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

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

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

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

    if 5.0000000000000002e-27 < (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))) < 1.10000000000000007e296

    1. Initial program 99.8%

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

    if 1.10000000000000007e296 < (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)))

    1. Initial program 81.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left|\frac{x + 4}{y} - z \cdot \frac{x}{y}\right| \leq 5 \cdot 10^{-27}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{elif}\;\left|\frac{x + 4}{y} - z \cdot \frac{x}{y}\right| \leq 1.1 \cdot 10^{+296}:\\ \;\;\;\;\left|\frac{x + 4}{y} - z \cdot \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(z + -1\right)\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 97.9% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 9.49999999999999994e52

    1. Initial program 93.9%

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

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

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

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

    if 9.49999999999999994e52 < y

    1. Initial program 93.8%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 9.5 \cdot 10^{+52}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 69.6% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|z \cdot \frac{x}{y}\right|\\ \mathbf{if}\;x \leq -6.5 \cdot 10^{-26}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-14}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{+136} \lor \neg \left(x \leq 1.15 \cdot 10^{+234}\right):\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (* z (/ x y)))))
   (if (<= x -6.5e-26)
     t_0
     (if (<= x 6.2e-14)
       (fabs (/ 4.0 y))
       (if (or (<= x 7.5e+136) (not (<= x 1.15e+234))) t_0 (fabs (/ x y)))))))
double code(double x, double y, double z) {
	double t_0 = fabs((z * (x / y)));
	double tmp;
	if (x <= -6.5e-26) {
		tmp = t_0;
	} else if (x <= 6.2e-14) {
		tmp = fabs((4.0 / y));
	} else if ((x <= 7.5e+136) || !(x <= 1.15e+234)) {
		tmp = t_0;
	} else {
		tmp = fabs((x / y));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = abs((z * (x / y)))
    if (x <= (-6.5d-26)) then
        tmp = t_0
    else if (x <= 6.2d-14) then
        tmp = abs((4.0d0 / y))
    else if ((x <= 7.5d+136) .or. (.not. (x <= 1.15d+234))) then
        tmp = t_0
    else
        tmp = abs((x / y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = Math.abs((z * (x / y)));
	double tmp;
	if (x <= -6.5e-26) {
		tmp = t_0;
	} else if (x <= 6.2e-14) {
		tmp = Math.abs((4.0 / y));
	} else if ((x <= 7.5e+136) || !(x <= 1.15e+234)) {
		tmp = t_0;
	} else {
		tmp = Math.abs((x / y));
	}
	return tmp;
}
def code(x, y, z):
	t_0 = math.fabs((z * (x / y)))
	tmp = 0
	if x <= -6.5e-26:
		tmp = t_0
	elif x <= 6.2e-14:
		tmp = math.fabs((4.0 / y))
	elif (x <= 7.5e+136) or not (x <= 1.15e+234):
		tmp = t_0
	else:
		tmp = math.fabs((x / y))
	return tmp
function code(x, y, z)
	t_0 = abs(Float64(z * Float64(x / y)))
	tmp = 0.0
	if (x <= -6.5e-26)
		tmp = t_0;
	elseif (x <= 6.2e-14)
		tmp = abs(Float64(4.0 / y));
	elseif ((x <= 7.5e+136) || !(x <= 1.15e+234))
		tmp = t_0;
	else
		tmp = abs(Float64(x / y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = abs((z * (x / y)));
	tmp = 0.0;
	if (x <= -6.5e-26)
		tmp = t_0;
	elseif (x <= 6.2e-14)
		tmp = abs((4.0 / y));
	elseif ((x <= 7.5e+136) || ~((x <= 1.15e+234)))
		tmp = t_0;
	else
		tmp = abs((x / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -6.5e-26], t$95$0, If[LessEqual[x, 6.2e-14], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 7.5e+136], N[Not[LessEqual[x, 1.15e+234]], $MachinePrecision]], t$95$0, N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;x \leq 7.5 \cdot 10^{+136} \lor \neg \left(x \leq 1.15 \cdot 10^{+234}\right):\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -6.5e-26 or 6.20000000000000009e-14 < x < 7.5000000000000002e136 or 1.15e234 < x

    1. Initial program 93.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.5e-26 < x < 6.20000000000000009e-14

    1. Initial program 95.4%

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

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

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

    if 7.5000000000000002e136 < x < 1.15e234

    1. Initial program 86.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{-26}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-14}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{+136} \lor \neg \left(x \leq 1.15 \cdot 10^{+234}\right):\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 98.7% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -200 \lor \neg \left(x \leq 4\right):\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(z + -1\right)\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -200 or 4 < x

    1. Initial program 91.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -200 < x < 4

    1. Initial program 95.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -200 \lor \neg \left(x \leq 4\right):\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(z + -1\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{z \cdot \left(\frac{4}{z} - x\right)}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 99.7% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.00000000000000015e70 or 8.9999999999999999e51 < x

    1. Initial program 90.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.00000000000000015e70 < x < 8.9999999999999999e51

    1. Initial program 95.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{+70} \lor \neg \left(x \leq 9 \cdot 10^{+51}\right):\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(z + -1\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 87.1% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.6000000000000001e-26 or 3e9 < x

    1. Initial program 92.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.6000000000000001e-26 < x < 3e9

    1. Initial program 95.6%

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

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

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

        \[\leadsto \left|\frac{\color{blue}{x + 4}}{y}\right| \]
      2. rem-square-sqrt29.5%

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

        \[\leadsto \left|\color{blue}{\left|\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}\right|}\right| \]
      4. rem-square-sqrt79.5%

        \[\leadsto \left|\left|\color{blue}{\frac{x + 4}{y}}\right|\right| \]
      5. fabs-neg79.5%

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

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

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

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

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

        \[\leadsto \left|\left|\frac{\color{blue}{-4 - x}}{y}\right|\right| \]
      11. rem-square-sqrt49.5%

        \[\leadsto \left|\left|\color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}}\right|\right| \]
      12. fabs-sqr49.5%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}}\right| \]
      13. rem-square-sqrt79.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.6 \cdot 10^{-26} \lor \neg \left(x \leq 3000000000\right):\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 87.3% accurate, 0.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.49999999999999993e-29 or 2.2e9 < x

    1. Initial program 92.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.49999999999999993e-29 < x < 2.2e9

    1. Initial program 95.6%

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

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

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

        \[\leadsto \left|\frac{\color{blue}{x + 4}}{y}\right| \]
      2. rem-square-sqrt29.5%

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

        \[\leadsto \left|\color{blue}{\left|\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}\right|}\right| \]
      4. rem-square-sqrt79.5%

        \[\leadsto \left|\left|\color{blue}{\frac{x + 4}{y}}\right|\right| \]
      5. fabs-neg79.5%

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

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

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

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

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

        \[\leadsto \left|\left|\frac{\color{blue}{-4 - x}}{y}\right|\right| \]
      11. rem-square-sqrt49.5%

        \[\leadsto \left|\left|\color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}}\right|\right| \]
      12. fabs-sqr49.5%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}}\right| \]
      13. rem-square-sqrt79.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{-29} \lor \neg \left(x \leq 2200000000\right):\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(z + -1\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 85.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -210000000000:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\

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

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


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

    1. Initial program 98.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.1e11 < z < 1.4499999999999999e75

    1. Initial program 94.6%

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

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

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

        \[\leadsto \left|\frac{\color{blue}{x + 4}}{y}\right| \]
      2. rem-square-sqrt43.2%

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

        \[\leadsto \left|\color{blue}{\left|\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}\right|}\right| \]
      4. rem-square-sqrt95.1%

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

        \[\leadsto \left|\color{blue}{\left|-\frac{x + 4}{y}\right|}\right| \]
      6. distribute-neg-frac95.1%

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

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

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

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

        \[\leadsto \left|\left|\frac{\color{blue}{-4 - x}}{y}\right|\right| \]
      11. rem-square-sqrt51.3%

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

        \[\leadsto \left|\color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}}\right| \]
      13. rem-square-sqrt95.1%

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

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

    if 1.4499999999999999e75 < z

    1. Initial program 87.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -210000000000:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{+75}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 85.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -215000000000:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\

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

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


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

    1. Initial program 98.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.15e11 < z < 3e75

    1. Initial program 94.6%

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

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

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

        \[\leadsto \left|\frac{\color{blue}{x + 4}}{y}\right| \]
      2. rem-square-sqrt43.2%

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

        \[\leadsto \left|\color{blue}{\left|\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}\right|}\right| \]
      4. rem-square-sqrt95.1%

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

        \[\leadsto \left|\color{blue}{\left|-\frac{x + 4}{y}\right|}\right| \]
      6. distribute-neg-frac95.1%

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

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

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

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

        \[\leadsto \left|\left|\frac{\color{blue}{-4 - x}}{y}\right|\right| \]
      11. rem-square-sqrt51.3%

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

        \[\leadsto \left|\color{blue}{\sqrt{\frac{-4 - x}{y}} \cdot \sqrt{\frac{-4 - x}{y}}}\right| \]
      13. rem-square-sqrt95.1%

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

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

    if 3e75 < z

    1. Initial program 87.8%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -215000000000:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;z \leq 3 \cdot 10^{+75}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 68.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -10.5 \lor \neg \left(x \leq 4\right):\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -10.5) (not (<= x 4.0))) (fabs (/ x y)) (fabs (/ 4.0 y))))
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -10.5) || !(x <= 4.0)) {
		tmp = fabs((x / y));
	} else {
		tmp = fabs((4.0 / y));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x <= (-10.5d0)) .or. (.not. (x <= 4.0d0))) then
        tmp = abs((x / y))
    else
        tmp = abs((4.0d0 / y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((x <= -10.5) || !(x <= 4.0)) {
		tmp = Math.abs((x / y));
	} else {
		tmp = Math.abs((4.0 / y));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (x <= -10.5) or not (x <= 4.0):
		tmp = math.fabs((x / y))
	else:
		tmp = math.fabs((4.0 / y))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((x <= -10.5) || !(x <= 4.0))
		tmp = abs(Float64(x / y));
	else
		tmp = abs(Float64(4.0 / y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -10.5) || ~((x <= 4.0)))
		tmp = abs((x / y));
	else
		tmp = abs((4.0 / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[x, -10.5], N[Not[LessEqual[x, 4.0]], $MachinePrecision]], N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -10.5 \lor \neg \left(x \leq 4\right):\\
\;\;\;\;\left|\frac{x}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -10.5 or 4 < x

    1. Initial program 91.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -10.5 < x < 4

    1. Initial program 95.7%

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

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

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

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

Alternative 11: 40.2% 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.8%

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

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

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

    \[\leadsto \left|\frac{4}{y}\right| \]
  6. Add Preprocessing

Reproduce

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