fabs fraction 1

Percentage Accurate: 91.9% → 99.6%
Time: 6.8s
Alternatives: 10
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 91.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.6% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 90.5%

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

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

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

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

    if 4.5000000000000001e-77 < y

    1. Initial program 96.6%

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

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. 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|} \]
    4. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 69.2% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \left|\frac{x}{y\_m}\right|\\ t_1 := \left|z \cdot \frac{x}{y\_m}\right|\\ \mathbf{if}\;x \leq -1.65 \cdot 10^{+109}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -1.15 \cdot 10^{+18}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-49}:\\ \;\;\;\;\left|\frac{4}{y\_m}\right|\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{+16} \lor \neg \left(x \leq 1.72 \cdot 10^{+64}\right):\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (let* ((t_0 (fabs (/ x y_m))) (t_1 (fabs (* z (/ x y_m)))))
   (if (<= x -1.65e+109)
     t_0
     (if (<= x -1.15e+18)
       t_1
       (if (<= x 2.7e-49)
         (fabs (/ 4.0 y_m))
         (if (or (<= x 3.4e+16) (not (<= x 1.72e+64))) t_1 t_0))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = fabs((x / y_m));
	double t_1 = fabs((z * (x / y_m)));
	double tmp;
	if (x <= -1.65e+109) {
		tmp = t_0;
	} else if (x <= -1.15e+18) {
		tmp = t_1;
	} else if (x <= 2.7e-49) {
		tmp = fabs((4.0 / y_m));
	} else if ((x <= 3.4e+16) || !(x <= 1.72e+64)) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = abs((x / y_m))
    t_1 = abs((z * (x / y_m)))
    if (x <= (-1.65d+109)) then
        tmp = t_0
    else if (x <= (-1.15d+18)) then
        tmp = t_1
    else if (x <= 2.7d-49) then
        tmp = abs((4.0d0 / y_m))
    else if ((x <= 3.4d+16) .or. (.not. (x <= 1.72d+64))) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double t_0 = Math.abs((x / y_m));
	double t_1 = Math.abs((z * (x / y_m)));
	double tmp;
	if (x <= -1.65e+109) {
		tmp = t_0;
	} else if (x <= -1.15e+18) {
		tmp = t_1;
	} else if (x <= 2.7e-49) {
		tmp = Math.abs((4.0 / y_m));
	} else if ((x <= 3.4e+16) || !(x <= 1.72e+64)) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	t_0 = math.fabs((x / y_m))
	t_1 = math.fabs((z * (x / y_m)))
	tmp = 0
	if x <= -1.65e+109:
		tmp = t_0
	elif x <= -1.15e+18:
		tmp = t_1
	elif x <= 2.7e-49:
		tmp = math.fabs((4.0 / y_m))
	elif (x <= 3.4e+16) or not (x <= 1.72e+64):
		tmp = t_1
	else:
		tmp = t_0
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	t_0 = abs(Float64(x / y_m))
	t_1 = abs(Float64(z * Float64(x / y_m)))
	tmp = 0.0
	if (x <= -1.65e+109)
		tmp = t_0;
	elseif (x <= -1.15e+18)
		tmp = t_1;
	elseif (x <= 2.7e-49)
		tmp = abs(Float64(4.0 / y_m));
	elseif ((x <= 3.4e+16) || !(x <= 1.72e+64))
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	t_0 = abs((x / y_m));
	t_1 = abs((z * (x / y_m)));
	tmp = 0.0;
	if (x <= -1.65e+109)
		tmp = t_0;
	elseif (x <= -1.15e+18)
		tmp = t_1;
	elseif (x <= 2.7e-49)
		tmp = abs((4.0 / y_m));
	elseif ((x <= 3.4e+16) || ~((x <= 1.72e+64)))
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.65e+109], t$95$0, If[LessEqual[x, -1.15e+18], t$95$1, If[LessEqual[x, 2.7e-49], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 3.4e+16], N[Not[LessEqual[x, 1.72e+64]], $MachinePrecision]], t$95$1, t$95$0]]]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := \left|\frac{x}{y\_m}\right|\\
t_1 := \left|z \cdot \frac{x}{y\_m}\right|\\
\mathbf{if}\;x \leq -1.65 \cdot 10^{+109}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -1.15 \cdot 10^{+18}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 2.7 \cdot 10^{-49}:\\
\;\;\;\;\left|\frac{4}{y\_m}\right|\\

\mathbf{elif}\;x \leq 3.4 \cdot 10^{+16} \lor \neg \left(x \leq 1.72 \cdot 10^{+64}\right):\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.6499999999999999e109 or 3.4e16 < x < 1.72e64

    1. Initial program 88.6%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Simplified95.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 95.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\left(1 + \color{blue}{\left(-z\right)}\right) \cdot \frac{x}{y}\right| \]
      13. 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 80.9%

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

    if -1.6499999999999999e109 < x < -1.15e18 or 2.7e-49 < x < 3.4e16 or 1.72e64 < x

    1. Initial program 92.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Simplified92.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 z around inf 56.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.15e18 < x < 2.7e-49

    1. Initial program 93.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.65 \cdot 10^{+109}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.15 \cdot 10^{+18}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-49}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{+16} \lor \neg \left(x \leq 1.72 \cdot 10^{+64}\right):\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 68.8% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \left|\frac{x}{y\_m}\right|\\ t_1 := \left|\frac{z}{\frac{y\_m}{x}}\right|\\ \mathbf{if}\;x \leq -1.35 \cdot 10^{+110}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -1.15 \cdot 10^{+18}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-51}:\\ \;\;\;\;\left|\frac{4}{y\_m}\right|\\ \mathbf{elif}\;x \leq 18000000000000:\\ \;\;\;\;\left|x \cdot \frac{z}{y\_m}\right|\\ \mathbf{elif}\;x \leq 2.05 \cdot 10^{+68}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (let* ((t_0 (fabs (/ x y_m))) (t_1 (fabs (/ z (/ y_m x)))))
   (if (<= x -1.35e+110)
     t_0
     (if (<= x -1.15e+18)
       t_1
       (if (<= x 5.2e-51)
         (fabs (/ 4.0 y_m))
         (if (<= x 18000000000000.0)
           (fabs (* x (/ z y_m)))
           (if (<= x 2.05e+68) t_0 t_1)))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = fabs((x / y_m));
	double t_1 = fabs((z / (y_m / x)));
	double tmp;
	if (x <= -1.35e+110) {
		tmp = t_0;
	} else if (x <= -1.15e+18) {
		tmp = t_1;
	} else if (x <= 5.2e-51) {
		tmp = fabs((4.0 / y_m));
	} else if (x <= 18000000000000.0) {
		tmp = fabs((x * (z / y_m)));
	} else if (x <= 2.05e+68) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = abs((x / y_m))
    t_1 = abs((z / (y_m / x)))
    if (x <= (-1.35d+110)) then
        tmp = t_0
    else if (x <= (-1.15d+18)) then
        tmp = t_1
    else if (x <= 5.2d-51) then
        tmp = abs((4.0d0 / y_m))
    else if (x <= 18000000000000.0d0) then
        tmp = abs((x * (z / y_m)))
    else if (x <= 2.05d+68) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double t_0 = Math.abs((x / y_m));
	double t_1 = Math.abs((z / (y_m / x)));
	double tmp;
	if (x <= -1.35e+110) {
		tmp = t_0;
	} else if (x <= -1.15e+18) {
		tmp = t_1;
	} else if (x <= 5.2e-51) {
		tmp = Math.abs((4.0 / y_m));
	} else if (x <= 18000000000000.0) {
		tmp = Math.abs((x * (z / y_m)));
	} else if (x <= 2.05e+68) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	t_0 = math.fabs((x / y_m))
	t_1 = math.fabs((z / (y_m / x)))
	tmp = 0
	if x <= -1.35e+110:
		tmp = t_0
	elif x <= -1.15e+18:
		tmp = t_1
	elif x <= 5.2e-51:
		tmp = math.fabs((4.0 / y_m))
	elif x <= 18000000000000.0:
		tmp = math.fabs((x * (z / y_m)))
	elif x <= 2.05e+68:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	t_0 = abs(Float64(x / y_m))
	t_1 = abs(Float64(z / Float64(y_m / x)))
	tmp = 0.0
	if (x <= -1.35e+110)
		tmp = t_0;
	elseif (x <= -1.15e+18)
		tmp = t_1;
	elseif (x <= 5.2e-51)
		tmp = abs(Float64(4.0 / y_m));
	elseif (x <= 18000000000000.0)
		tmp = abs(Float64(x * Float64(z / y_m)));
	elseif (x <= 2.05e+68)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	t_0 = abs((x / y_m));
	t_1 = abs((z / (y_m / x)));
	tmp = 0.0;
	if (x <= -1.35e+110)
		tmp = t_0;
	elseif (x <= -1.15e+18)
		tmp = t_1;
	elseif (x <= 5.2e-51)
		tmp = abs((4.0 / y_m));
	elseif (x <= 18000000000000.0)
		tmp = abs((x * (z / y_m)));
	elseif (x <= 2.05e+68)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(z / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.35e+110], t$95$0, If[LessEqual[x, -1.15e+18], t$95$1, If[LessEqual[x, 5.2e-51], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 18000000000000.0], N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 2.05e+68], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := \left|\frac{x}{y\_m}\right|\\
t_1 := \left|\frac{z}{\frac{y\_m}{x}}\right|\\
\mathbf{if}\;x \leq -1.35 \cdot 10^{+110}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -1.15 \cdot 10^{+18}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 5.2 \cdot 10^{-51}:\\
\;\;\;\;\left|\frac{4}{y\_m}\right|\\

\mathbf{elif}\;x \leq 18000000000000:\\
\;\;\;\;\left|x \cdot \frac{z}{y\_m}\right|\\

\mathbf{elif}\;x \leq 2.05 \cdot 10^{+68}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -1.35000000000000005e110 or 1.8e13 < x < 2.05e68

    1. Initial program 87.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.35000000000000005e110 < x < -1.15e18 or 2.05e68 < x

    1. Initial program 92.7%

      \[\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 z around inf 54.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.15e18 < x < 5.2e-51

    1. Initial program 93.8%

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

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

    if 5.2e-51 < x < 1.8e13

    1. Initial program 98.2%

      \[\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 inf 68.4%

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{x \cdot \left(-z\right)}{y}}\right| \]
    7. Step-by-step derivation
      1. distribute-rgt-neg-out68.4%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.35 \cdot 10^{+110}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.15 \cdot 10^{+18}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-51}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 18000000000000:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 2.05 \cdot 10^{+68}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 69.2% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \left|\frac{x}{y\_m}\right|\\ t_1 := \left|z \cdot \frac{x}{y\_m}\right|\\ \mathbf{if}\;x \leq -1.55 \cdot 10^{+109}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -1.15 \cdot 10^{+18}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-49}:\\ \;\;\;\;\left|\frac{4}{y\_m}\right|\\ \mathbf{elif}\;x \leq 24000000000000:\\ \;\;\;\;\left|x \cdot \frac{z}{y\_m}\right|\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{+64}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (let* ((t_0 (fabs (/ x y_m))) (t_1 (fabs (* z (/ x y_m)))))
   (if (<= x -1.55e+109)
     t_0
     (if (<= x -1.15e+18)
       t_1
       (if (<= x 2.3e-49)
         (fabs (/ 4.0 y_m))
         (if (<= x 24000000000000.0)
           (fabs (* x (/ z y_m)))
           (if (<= x 1.6e+64) t_0 t_1)))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = fabs((x / y_m));
	double t_1 = fabs((z * (x / y_m)));
	double tmp;
	if (x <= -1.55e+109) {
		tmp = t_0;
	} else if (x <= -1.15e+18) {
		tmp = t_1;
	} else if (x <= 2.3e-49) {
		tmp = fabs((4.0 / y_m));
	} else if (x <= 24000000000000.0) {
		tmp = fabs((x * (z / y_m)));
	} else if (x <= 1.6e+64) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = abs((x / y_m))
    t_1 = abs((z * (x / y_m)))
    if (x <= (-1.55d+109)) then
        tmp = t_0
    else if (x <= (-1.15d+18)) then
        tmp = t_1
    else if (x <= 2.3d-49) then
        tmp = abs((4.0d0 / y_m))
    else if (x <= 24000000000000.0d0) then
        tmp = abs((x * (z / y_m)))
    else if (x <= 1.6d+64) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double t_0 = Math.abs((x / y_m));
	double t_1 = Math.abs((z * (x / y_m)));
	double tmp;
	if (x <= -1.55e+109) {
		tmp = t_0;
	} else if (x <= -1.15e+18) {
		tmp = t_1;
	} else if (x <= 2.3e-49) {
		tmp = Math.abs((4.0 / y_m));
	} else if (x <= 24000000000000.0) {
		tmp = Math.abs((x * (z / y_m)));
	} else if (x <= 1.6e+64) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	t_0 = math.fabs((x / y_m))
	t_1 = math.fabs((z * (x / y_m)))
	tmp = 0
	if x <= -1.55e+109:
		tmp = t_0
	elif x <= -1.15e+18:
		tmp = t_1
	elif x <= 2.3e-49:
		tmp = math.fabs((4.0 / y_m))
	elif x <= 24000000000000.0:
		tmp = math.fabs((x * (z / y_m)))
	elif x <= 1.6e+64:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	t_0 = abs(Float64(x / y_m))
	t_1 = abs(Float64(z * Float64(x / y_m)))
	tmp = 0.0
	if (x <= -1.55e+109)
		tmp = t_0;
	elseif (x <= -1.15e+18)
		tmp = t_1;
	elseif (x <= 2.3e-49)
		tmp = abs(Float64(4.0 / y_m));
	elseif (x <= 24000000000000.0)
		tmp = abs(Float64(x * Float64(z / y_m)));
	elseif (x <= 1.6e+64)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	t_0 = abs((x / y_m));
	t_1 = abs((z * (x / y_m)));
	tmp = 0.0;
	if (x <= -1.55e+109)
		tmp = t_0;
	elseif (x <= -1.15e+18)
		tmp = t_1;
	elseif (x <= 2.3e-49)
		tmp = abs((4.0 / y_m));
	elseif (x <= 24000000000000.0)
		tmp = abs((x * (z / y_m)));
	elseif (x <= 1.6e+64)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.55e+109], t$95$0, If[LessEqual[x, -1.15e+18], t$95$1, If[LessEqual[x, 2.3e-49], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 24000000000000.0], N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.6e+64], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := \left|\frac{x}{y\_m}\right|\\
t_1 := \left|z \cdot \frac{x}{y\_m}\right|\\
\mathbf{if}\;x \leq -1.55 \cdot 10^{+109}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -1.15 \cdot 10^{+18}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 2.3 \cdot 10^{-49}:\\
\;\;\;\;\left|\frac{4}{y\_m}\right|\\

\mathbf{elif}\;x \leq 24000000000000:\\
\;\;\;\;\left|x \cdot \frac{z}{y\_m}\right|\\

\mathbf{elif}\;x \leq 1.6 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -1.54999999999999996e109 or 2.4e13 < x < 1.60000000000000009e64

    1. Initial program 87.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.54999999999999996e109 < x < -1.15e18 or 1.60000000000000009e64 < x

    1. Initial program 92.7%

      \[\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 z around inf 54.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.15e18 < x < 2.2999999999999999e-49

    1. Initial program 93.8%

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

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

    if 2.2999999999999999e-49 < x < 2.4e13

    1. Initial program 98.2%

      \[\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 inf 68.4%

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{x \cdot \left(-z\right)}{y}}\right| \]
    7. Step-by-step derivation
      1. distribute-rgt-neg-out68.4%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{+109}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.15 \cdot 10^{+18}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-49}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 24000000000000:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{+64}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 99.9% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 91.1%

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

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

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

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

    if 1.29999999999999991e-10 < y

    1. Initial program 96.2%

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

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

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

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

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

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x}{\frac{y}{z}}}\right| \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 84.4% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;z \leq -5.3 \cdot 10^{+104}:\\ \;\;\;\;\left|\frac{x \cdot z}{y\_m}\right|\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{+34}:\\ \;\;\;\;\left|\frac{-4 - x}{y\_m}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y\_m}\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= z -5.3e+104)
   (fabs (/ (* x z) y_m))
   (if (<= z 1.45e+34) (fabs (/ (- -4.0 x) y_m)) (fabs (* z (/ x y_m))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (z <= -5.3e+104) {
		tmp = fabs(((x * z) / y_m));
	} else if (z <= 1.45e+34) {
		tmp = fabs(((-4.0 - x) / y_m));
	} else {
		tmp = fabs((z * (x / y_m)));
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-5.3d+104)) then
        tmp = abs(((x * z) / y_m))
    else if (z <= 1.45d+34) then
        tmp = abs((((-4.0d0) - x) / y_m))
    else
        tmp = abs((z * (x / y_m)))
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if (z <= -5.3e+104) {
		tmp = Math.abs(((x * z) / y_m));
	} else if (z <= 1.45e+34) {
		tmp = Math.abs(((-4.0 - x) / y_m));
	} else {
		tmp = Math.abs((z * (x / y_m)));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if z <= -5.3e+104:
		tmp = math.fabs(((x * z) / y_m))
	elif z <= 1.45e+34:
		tmp = math.fabs(((-4.0 - x) / y_m))
	else:
		tmp = math.fabs((z * (x / y_m)))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (z <= -5.3e+104)
		tmp = abs(Float64(Float64(x * z) / y_m));
	elseif (z <= 1.45e+34)
		tmp = abs(Float64(Float64(-4.0 - x) / y_m));
	else
		tmp = abs(Float64(z * Float64(x / y_m)));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (z <= -5.3e+104)
		tmp = abs(((x * z) / y_m));
	elseif (z <= 1.45e+34)
		tmp = abs(((-4.0 - x) / y_m));
	else
		tmp = abs((z * (x / y_m)));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[z, -5.3e+104], N[Abs[N[(N[(x * z), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 1.45e+34], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|

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

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

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


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

    1. Initial program 86.7%

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

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

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

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

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

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

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

    if -5.2999999999999999e104 < z < 1.4500000000000001e34

    1. Initial program 95.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.4500000000000001e34 < z

    1. Initial program 87.6%

      \[\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 z around inf 80.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 85.9% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 89.8%

      \[\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 z around inf 72.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.70000000000000002e27 < z < 6.79999999999999992e38

    1. Initial program 95.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.79999999999999992e38 < z

    1. Initial program 87.6%

      \[\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 z around inf 80.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 97.9% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq 2.7 \cdot 10^{+16}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y\_m}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\left(1 - z\right) \cdot \frac{x}{y\_m}\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x 2.7e+16)
   (fabs (/ (- (+ x 4.0) (* x z)) y_m))
   (fabs (* (- 1.0 z) (/ x y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= 2.7e+16) {
		tmp = fabs((((x + 4.0) - (x * z)) / y_m));
	} else {
		tmp = fabs(((1.0 - z) * (x / y_m)));
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 2.7d+16) then
        tmp = abs((((x + 4.0d0) - (x * z)) / y_m))
    else
        tmp = abs(((1.0d0 - z) * (x / y_m)))
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double tmp;
	if (x <= 2.7e+16) {
		tmp = Math.abs((((x + 4.0) - (x * z)) / y_m));
	} else {
		tmp = Math.abs(((1.0 - z) * (x / y_m)));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= 2.7e+16:
		tmp = math.fabs((((x + 4.0) - (x * z)) / y_m))
	else:
		tmp = math.fabs(((1.0 - z) * (x / y_m)))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= 2.7e+16)
		tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y_m));
	else
		tmp = abs(Float64(Float64(1.0 - z) * Float64(x / y_m)));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= 2.7e+16)
		tmp = abs((((x + 4.0) - (x * z)) / y_m));
	else
		tmp = abs(((1.0 - z) * (x / y_m)));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, 2.7e+16], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(1.0 - z), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

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

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


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

    1. Initial program 92.9%

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

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

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

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

    if 2.7e16 < x

    1. Initial program 91.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\left(1 + \color{blue}{\left(-z\right)}\right) \cdot \frac{x}{y}\right| \]
      13. 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| \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 69.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 91.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Simplified92.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 inf 91.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.55000000000000004 < x < 4

    1. Initial program 94.0%

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

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

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

Alternative 10: 40.3% accurate, 1.1× speedup?

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

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

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Simplified96.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 0 39.6%

    \[\leadsto \left|\color{blue}{\frac{4}{y}}\right| \]
  5. Add Preprocessing

Reproduce

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