fabs fraction 1

Percentage Accurate: 91.7% → 99.5%
Time: 9.1s
Alternatives: 11
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 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.7% 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.5% accurate, 0.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;y\_m \leq 10^{-87}:\\ \;\;\;\;\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 1e-87)
   (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 <= 1e-87) {
		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 <= 1e-87)
		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, 1e-87], 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 10^{-87}:\\
\;\;\;\;\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 < 1.00000000000000002e-87

    1. Initial program 90.7%

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

        \[\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 1.00000000000000002e-87 < y

    1. Initial program 93.1%

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

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

        \[\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. Final simplification98.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 10^{-87}:\\ \;\;\;\;\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 2: 69.5% accurate, 0.8× 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 -2.95 \cdot 10^{+60}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -2.2 \cdot 10^{+38}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq -1.55:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\left|\frac{4}{y\_m}\right|\\ \mathbf{elif}\;x \leq 7.8 \cdot 10^{+74} \lor \neg \left(x \leq 2.9 \cdot 10^{+113}\right):\\ \;\;\;\;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 -2.95e+60)
     t_0
     (if (<= x -2.2e+38)
       t_1
       (if (<= x -1.55)
         t_0
         (if (<= x 4.0)
           (fabs (/ 4.0 y_m))
           (if (or (<= x 7.8e+74) (not (<= x 2.9e+113))) 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 <= -2.95e+60) {
		tmp = t_0;
	} else if (x <= -2.2e+38) {
		tmp = t_1;
	} else if (x <= -1.55) {
		tmp = t_0;
	} else if (x <= 4.0) {
		tmp = fabs((4.0 / y_m));
	} else if ((x <= 7.8e+74) || !(x <= 2.9e+113)) {
		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 <= (-2.95d+60)) then
        tmp = t_0
    else if (x <= (-2.2d+38)) then
        tmp = t_1
    else if (x <= (-1.55d0)) then
        tmp = t_0
    else if (x <= 4.0d0) then
        tmp = abs((4.0d0 / y_m))
    else if ((x <= 7.8d+74) .or. (.not. (x <= 2.9d+113))) 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 <= -2.95e+60) {
		tmp = t_0;
	} else if (x <= -2.2e+38) {
		tmp = t_1;
	} else if (x <= -1.55) {
		tmp = t_0;
	} else if (x <= 4.0) {
		tmp = Math.abs((4.0 / y_m));
	} else if ((x <= 7.8e+74) || !(x <= 2.9e+113)) {
		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 <= -2.95e+60:
		tmp = t_0
	elif x <= -2.2e+38:
		tmp = t_1
	elif x <= -1.55:
		tmp = t_0
	elif x <= 4.0:
		tmp = math.fabs((4.0 / y_m))
	elif (x <= 7.8e+74) or not (x <= 2.9e+113):
		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 <= -2.95e+60)
		tmp = t_0;
	elseif (x <= -2.2e+38)
		tmp = t_1;
	elseif (x <= -1.55)
		tmp = t_0;
	elseif (x <= 4.0)
		tmp = abs(Float64(4.0 / y_m));
	elseif ((x <= 7.8e+74) || !(x <= 2.9e+113))
		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 <= -2.95e+60)
		tmp = t_0;
	elseif (x <= -2.2e+38)
		tmp = t_1;
	elseif (x <= -1.55)
		tmp = t_0;
	elseif (x <= 4.0)
		tmp = abs((4.0 / y_m));
	elseif ((x <= 7.8e+74) || ~((x <= 2.9e+113)))
		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, -2.95e+60], t$95$0, If[LessEqual[x, -2.2e+38], t$95$1, If[LessEqual[x, -1.55], t$95$0, If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 7.8e+74], N[Not[LessEqual[x, 2.9e+113]], $MachinePrecision]], 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 -2.95 \cdot 10^{+60}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;x \leq -1.55:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;x \leq 7.8 \cdot 10^{+74} \lor \neg \left(x \leq 2.9 \cdot 10^{+113}\right):\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.9500000000000001e60 or -2.20000000000000006e38 < x < -1.55000000000000004 or 4 < x < 7.80000000000000015e74 or 2.89999999999999984e113 < x

    1. Initial program 86.3%

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

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

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

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

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

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

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

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

    if -2.9500000000000001e60 < x < -2.20000000000000006e38 or 7.80000000000000015e74 < x < 2.89999999999999984e113

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{z}{\frac{y}{x}}}\right| \]
    11. Simplified93.0%

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

    if -1.55000000000000004 < x < 4

    1. Initial program 94.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.95 \cdot 10^{+60}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -2.2 \cdot 10^{+38}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \leq -1.55:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 7.8 \cdot 10^{+74} \lor \neg \left(x \leq 2.9 \cdot 10^{+113}\right):\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 85.3% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;z \leq -2.75 \cdot 10^{+70}:\\ \;\;\;\;\left|x \cdot \frac{z}{y\_m}\right|\\ \mathbf{elif}\;z \leq -1.42 \cdot 10^{+60}:\\ \;\;\;\;\left|\frac{4}{y\_m}\right|\\ \mathbf{elif}\;z \leq -30500000000:\\ \;\;\;\;\left|\frac{z}{\frac{y\_m}{x}}\right|\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{+135}:\\ \;\;\;\;\left|\frac{-4 - x}{y\_m}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y\_m}{z}}\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= z -2.75e+70)
   (fabs (* x (/ z y_m)))
   (if (<= z -1.42e+60)
     (fabs (/ 4.0 y_m))
     (if (<= z -30500000000.0)
       (fabs (/ z (/ y_m x)))
       (if (<= z 4.1e+135)
         (fabs (/ (- -4.0 x) y_m))
         (fabs (/ x (/ y_m z))))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (z <= -2.75e+70) {
		tmp = fabs((x * (z / y_m)));
	} else if (z <= -1.42e+60) {
		tmp = fabs((4.0 / y_m));
	} else if (z <= -30500000000.0) {
		tmp = fabs((z / (y_m / x)));
	} else if (z <= 4.1e+135) {
		tmp = fabs(((-4.0 - x) / y_m));
	} else {
		tmp = fabs((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 (z <= (-2.75d+70)) then
        tmp = abs((x * (z / y_m)))
    else if (z <= (-1.42d+60)) then
        tmp = abs((4.0d0 / y_m))
    else if (z <= (-30500000000.0d0)) then
        tmp = abs((z / (y_m / x)))
    else if (z <= 4.1d+135) then
        tmp = abs((((-4.0d0) - x) / y_m))
    else
        tmp = abs((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 (z <= -2.75e+70) {
		tmp = Math.abs((x * (z / y_m)));
	} else if (z <= -1.42e+60) {
		tmp = Math.abs((4.0 / y_m));
	} else if (z <= -30500000000.0) {
		tmp = Math.abs((z / (y_m / x)));
	} else if (z <= 4.1e+135) {
		tmp = Math.abs(((-4.0 - x) / y_m));
	} else {
		tmp = Math.abs((x / (y_m / z)));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if z <= -2.75e+70:
		tmp = math.fabs((x * (z / y_m)))
	elif z <= -1.42e+60:
		tmp = math.fabs((4.0 / y_m))
	elif z <= -30500000000.0:
		tmp = math.fabs((z / (y_m / x)))
	elif z <= 4.1e+135:
		tmp = math.fabs(((-4.0 - x) / y_m))
	else:
		tmp = math.fabs((x / (y_m / z)))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (z <= -2.75e+70)
		tmp = abs(Float64(x * Float64(z / y_m)));
	elseif (z <= -1.42e+60)
		tmp = abs(Float64(4.0 / y_m));
	elseif (z <= -30500000000.0)
		tmp = abs(Float64(z / Float64(y_m / x)));
	elseif (z <= 4.1e+135)
		tmp = abs(Float64(Float64(-4.0 - x) / y_m));
	else
		tmp = abs(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 (z <= -2.75e+70)
		tmp = abs((x * (z / y_m)));
	elseif (z <= -1.42e+60)
		tmp = abs((4.0 / y_m));
	elseif (z <= -30500000000.0)
		tmp = abs((z / (y_m / x)));
	elseif (z <= 4.1e+135)
		tmp = abs(((-4.0 - x) / y_m));
	else
		tmp = abs((x / (y_m / z)));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[z, -2.75e+70], N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, -1.42e+60], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, -30500000000.0], N[Abs[N[(z / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 4.1e+135], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
y_m = \left|y\right|

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if z < -2.74999999999999993e70

    1. Initial program 94.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.74999999999999993e70 < z < -1.42000000000000001e60

    1. Initial program 99.7%

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

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

    if -1.42000000000000001e60 < z < -3.05e10

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{z}{\frac{y}{x}}}\right| \]
    11. Simplified78.2%

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

    if -3.05e10 < z < 4.1e135

    1. Initial program 91.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.1e135 < z

    1. Initial program 83.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.75 \cdot 10^{+70}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;z \leq -1.42 \cdot 10^{+60}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;z \leq -30500000000:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{+135}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 85.2% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;z \leq -8.5 \cdot 10^{+70}:\\ \;\;\;\;\left|x \cdot \frac{z}{y\_m}\right|\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{+49}:\\ \;\;\;\;\left|\frac{4}{y\_m}\right|\\ \mathbf{elif}\;z \leq -27:\\ \;\;\;\;\left|\left(1 - z\right) \cdot \frac{x}{y\_m}\right|\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{+135}:\\ \;\;\;\;\left|\frac{-4 - x}{y\_m}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y\_m}{z}}\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= z -8.5e+70)
   (fabs (* x (/ z y_m)))
   (if (<= z -3.2e+49)
     (fabs (/ 4.0 y_m))
     (if (<= z -27.0)
       (fabs (* (- 1.0 z) (/ x y_m)))
       (if (<= z 4.1e+135)
         (fabs (/ (- -4.0 x) y_m))
         (fabs (/ x (/ y_m z))))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (z <= -8.5e+70) {
		tmp = fabs((x * (z / y_m)));
	} else if (z <= -3.2e+49) {
		tmp = fabs((4.0 / y_m));
	} else if (z <= -27.0) {
		tmp = fabs(((1.0 - z) * (x / y_m)));
	} else if (z <= 4.1e+135) {
		tmp = fabs(((-4.0 - x) / y_m));
	} else {
		tmp = fabs((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 (z <= (-8.5d+70)) then
        tmp = abs((x * (z / y_m)))
    else if (z <= (-3.2d+49)) then
        tmp = abs((4.0d0 / y_m))
    else if (z <= (-27.0d0)) then
        tmp = abs(((1.0d0 - z) * (x / y_m)))
    else if (z <= 4.1d+135) then
        tmp = abs((((-4.0d0) - x) / y_m))
    else
        tmp = abs((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 (z <= -8.5e+70) {
		tmp = Math.abs((x * (z / y_m)));
	} else if (z <= -3.2e+49) {
		tmp = Math.abs((4.0 / y_m));
	} else if (z <= -27.0) {
		tmp = Math.abs(((1.0 - z) * (x / y_m)));
	} else if (z <= 4.1e+135) {
		tmp = Math.abs(((-4.0 - x) / y_m));
	} else {
		tmp = Math.abs((x / (y_m / z)));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if z <= -8.5e+70:
		tmp = math.fabs((x * (z / y_m)))
	elif z <= -3.2e+49:
		tmp = math.fabs((4.0 / y_m))
	elif z <= -27.0:
		tmp = math.fabs(((1.0 - z) * (x / y_m)))
	elif z <= 4.1e+135:
		tmp = math.fabs(((-4.0 - x) / y_m))
	else:
		tmp = math.fabs((x / (y_m / z)))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (z <= -8.5e+70)
		tmp = abs(Float64(x * Float64(z / y_m)));
	elseif (z <= -3.2e+49)
		tmp = abs(Float64(4.0 / y_m));
	elseif (z <= -27.0)
		tmp = abs(Float64(Float64(1.0 - z) * Float64(x / y_m)));
	elseif (z <= 4.1e+135)
		tmp = abs(Float64(Float64(-4.0 - x) / y_m));
	else
		tmp = abs(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 (z <= -8.5e+70)
		tmp = abs((x * (z / y_m)));
	elseif (z <= -3.2e+49)
		tmp = abs((4.0 / y_m));
	elseif (z <= -27.0)
		tmp = abs(((1.0 - z) * (x / y_m)));
	elseif (z <= 4.1e+135)
		tmp = abs(((-4.0 - x) / y_m));
	else
		tmp = abs((x / (y_m / z)));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[z, -8.5e+70], N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, -3.2e+49], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, -27.0], N[Abs[N[(N[(1.0 - z), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 4.1e+135], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
y_m = \left|y\right|

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if z < -8.4999999999999996e70

    1. Initial program 94.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.4999999999999996e70 < z < -3.20000000000000014e49

    1. Initial program 99.7%

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

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

    if -3.20000000000000014e49 < z < -27

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -27 < z < 4.1e135

    1. Initial program 91.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 0 96.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.1e135 < z

    1. Initial program 83.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 85.2% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;z \leq -1.05 \cdot 10^{+72}:\\ \;\;\;\;\left|x \cdot \frac{z}{y\_m}\right|\\ \mathbf{elif}\;z \leq -4 \cdot 10^{+60}:\\ \;\;\;\;\left|\frac{4}{y\_m}\right|\\ \mathbf{elif}\;z \leq -39:\\ \;\;\;\;\left|\frac{1 - z}{\frac{y\_m}{x}}\right|\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{+135}:\\ \;\;\;\;\left|\frac{-4 - x}{y\_m}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y\_m}{z}}\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= z -1.05e+72)
   (fabs (* x (/ z y_m)))
   (if (<= z -4e+60)
     (fabs (/ 4.0 y_m))
     (if (<= z -39.0)
       (fabs (/ (- 1.0 z) (/ y_m x)))
       (if (<= z 4.1e+135)
         (fabs (/ (- -4.0 x) y_m))
         (fabs (/ x (/ y_m z))))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (z <= -1.05e+72) {
		tmp = fabs((x * (z / y_m)));
	} else if (z <= -4e+60) {
		tmp = fabs((4.0 / y_m));
	} else if (z <= -39.0) {
		tmp = fabs(((1.0 - z) / (y_m / x)));
	} else if (z <= 4.1e+135) {
		tmp = fabs(((-4.0 - x) / y_m));
	} else {
		tmp = fabs((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 (z <= (-1.05d+72)) then
        tmp = abs((x * (z / y_m)))
    else if (z <= (-4d+60)) then
        tmp = abs((4.0d0 / y_m))
    else if (z <= (-39.0d0)) then
        tmp = abs(((1.0d0 - z) / (y_m / x)))
    else if (z <= 4.1d+135) then
        tmp = abs((((-4.0d0) - x) / y_m))
    else
        tmp = abs((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 (z <= -1.05e+72) {
		tmp = Math.abs((x * (z / y_m)));
	} else if (z <= -4e+60) {
		tmp = Math.abs((4.0 / y_m));
	} else if (z <= -39.0) {
		tmp = Math.abs(((1.0 - z) / (y_m / x)));
	} else if (z <= 4.1e+135) {
		tmp = Math.abs(((-4.0 - x) / y_m));
	} else {
		tmp = Math.abs((x / (y_m / z)));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if z <= -1.05e+72:
		tmp = math.fabs((x * (z / y_m)))
	elif z <= -4e+60:
		tmp = math.fabs((4.0 / y_m))
	elif z <= -39.0:
		tmp = math.fabs(((1.0 - z) / (y_m / x)))
	elif z <= 4.1e+135:
		tmp = math.fabs(((-4.0 - x) / y_m))
	else:
		tmp = math.fabs((x / (y_m / z)))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (z <= -1.05e+72)
		tmp = abs(Float64(x * Float64(z / y_m)));
	elseif (z <= -4e+60)
		tmp = abs(Float64(4.0 / y_m));
	elseif (z <= -39.0)
		tmp = abs(Float64(Float64(1.0 - z) / Float64(y_m / x)));
	elseif (z <= 4.1e+135)
		tmp = abs(Float64(Float64(-4.0 - x) / y_m));
	else
		tmp = abs(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 (z <= -1.05e+72)
		tmp = abs((x * (z / y_m)));
	elseif (z <= -4e+60)
		tmp = abs((4.0 / y_m));
	elseif (z <= -39.0)
		tmp = abs(((1.0 - z) / (y_m / x)));
	elseif (z <= 4.1e+135)
		tmp = abs(((-4.0 - x) / y_m));
	else
		tmp = abs((x / (y_m / z)));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[z, -1.05e+72], N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, -4e+60], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, -39.0], N[Abs[N[(N[(1.0 - z), $MachinePrecision] / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 4.1e+135], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
y_m = \left|y\right|

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

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

\mathbf{elif}\;z \leq -39:\\
\;\;\;\;\left|\frac{1 - z}{\frac{y\_m}{x}}\right|\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if z < -1.0500000000000001e72

    1. Initial program 94.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.0500000000000001e72 < z < -3.9999999999999998e60

    1. Initial program 99.7%

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

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

    if -3.9999999999999998e60 < z < -39

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -39 < z < 4.1e135

    1. Initial program 91.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 0 96.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.1e135 < z

    1. Initial program 83.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.05 \cdot 10^{+72}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;z \leq -4 \cdot 10^{+60}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;z \leq -39:\\ \;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{+135}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 69.3% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \left|\frac{x}{y\_m}\right|\\ \mathbf{if}\;x \leq -1.5 \cdot 10^{+58}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -1.1 \cdot 10^{+36}:\\ \;\;\;\;\left|x \cdot \frac{z}{y\_m}\right|\\ \mathbf{elif}\;x \leq -1.55 \lor \neg \left(x \leq 4\right):\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y\_m}\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (let* ((t_0 (fabs (/ x y_m))))
   (if (<= x -1.5e+58)
     t_0
     (if (<= x -1.1e+36)
       (fabs (* x (/ z y_m)))
       (if (or (<= x -1.55) (not (<= x 4.0))) t_0 (fabs (/ 4.0 y_m)))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = fabs((x / y_m));
	double tmp;
	if (x <= -1.5e+58) {
		tmp = t_0;
	} else if (x <= -1.1e+36) {
		tmp = fabs((x * (z / y_m)));
	} else if ((x <= -1.55) || !(x <= 4.0)) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = abs((x / y_m))
    if (x <= (-1.5d+58)) then
        tmp = t_0
    else if (x <= (-1.1d+36)) then
        tmp = abs((x * (z / y_m)))
    else if ((x <= (-1.55d0)) .or. (.not. (x <= 4.0d0))) then
        tmp = t_0
    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 t_0 = Math.abs((x / y_m));
	double tmp;
	if (x <= -1.5e+58) {
		tmp = t_0;
	} else if (x <= -1.1e+36) {
		tmp = Math.abs((x * (z / y_m)));
	} else if ((x <= -1.55) || !(x <= 4.0)) {
		tmp = t_0;
	} else {
		tmp = Math.abs((4.0 / y_m));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	t_0 = math.fabs((x / y_m))
	tmp = 0
	if x <= -1.5e+58:
		tmp = t_0
	elif x <= -1.1e+36:
		tmp = math.fabs((x * (z / y_m)))
	elif (x <= -1.55) or not (x <= 4.0):
		tmp = t_0
	else:
		tmp = math.fabs((4.0 / y_m))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	t_0 = abs(Float64(x / y_m))
	tmp = 0.0
	if (x <= -1.5e+58)
		tmp = t_0;
	elseif (x <= -1.1e+36)
		tmp = abs(Float64(x * Float64(z / y_m)));
	elseif ((x <= -1.55) || !(x <= 4.0))
		tmp = t_0;
	else
		tmp = abs(Float64(4.0 / y_m));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	t_0 = abs((x / y_m));
	tmp = 0.0;
	if (x <= -1.5e+58)
		tmp = t_0;
	elseif (x <= -1.1e+36)
		tmp = abs((x * (z / y_m)));
	elseif ((x <= -1.55) || ~((x <= 4.0)))
		tmp = t_0;
	else
		tmp = abs((4.0 / y_m));
	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]}, If[LessEqual[x, -1.5e+58], t$95$0, If[LessEqual[x, -1.1e+36], N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, -1.55], N[Not[LessEqual[x, 4.0]], $MachinePrecision]], t$95$0, N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
y_m = \left|y\right|

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

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

\mathbf{elif}\;x \leq -1.55 \lor \neg \left(x \leq 4\right):\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 87.2%

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

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

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

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

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

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

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

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

    if -1.5000000000000001e58 < x < -1.1e36

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.55000000000000004 < x < 4

    1. Initial program 94.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{+58}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.1 \cdot 10^{+36}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;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 7: 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|\\ \mathbf{if}\;x \leq -6.5 \cdot 10^{+56}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -3.4 \cdot 10^{+28}:\\ \;\;\;\;\left|\frac{x}{\frac{y\_m}{z}}\right|\\ \mathbf{elif}\;x \leq -1.55 \lor \neg \left(x \leq 4\right):\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y\_m}\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (let* ((t_0 (fabs (/ x y_m))))
   (if (<= x -6.5e+56)
     t_0
     (if (<= x -3.4e+28)
       (fabs (/ x (/ y_m z)))
       (if (or (<= x -1.55) (not (<= x 4.0))) t_0 (fabs (/ 4.0 y_m)))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = fabs((x / y_m));
	double tmp;
	if (x <= -6.5e+56) {
		tmp = t_0;
	} else if (x <= -3.4e+28) {
		tmp = fabs((x / (y_m / z)));
	} else if ((x <= -1.55) || !(x <= 4.0)) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = abs((x / y_m))
    if (x <= (-6.5d+56)) then
        tmp = t_0
    else if (x <= (-3.4d+28)) then
        tmp = abs((x / (y_m / z)))
    else if ((x <= (-1.55d0)) .or. (.not. (x <= 4.0d0))) then
        tmp = t_0
    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 t_0 = Math.abs((x / y_m));
	double tmp;
	if (x <= -6.5e+56) {
		tmp = t_0;
	} else if (x <= -3.4e+28) {
		tmp = Math.abs((x / (y_m / z)));
	} else if ((x <= -1.55) || !(x <= 4.0)) {
		tmp = t_0;
	} else {
		tmp = Math.abs((4.0 / y_m));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	t_0 = math.fabs((x / y_m))
	tmp = 0
	if x <= -6.5e+56:
		tmp = t_0
	elif x <= -3.4e+28:
		tmp = math.fabs((x / (y_m / z)))
	elif (x <= -1.55) or not (x <= 4.0):
		tmp = t_0
	else:
		tmp = math.fabs((4.0 / y_m))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	t_0 = abs(Float64(x / y_m))
	tmp = 0.0
	if (x <= -6.5e+56)
		tmp = t_0;
	elseif (x <= -3.4e+28)
		tmp = abs(Float64(x / Float64(y_m / z)));
	elseif ((x <= -1.55) || !(x <= 4.0))
		tmp = t_0;
	else
		tmp = abs(Float64(4.0 / y_m));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	t_0 = abs((x / y_m));
	tmp = 0.0;
	if (x <= -6.5e+56)
		tmp = t_0;
	elseif (x <= -3.4e+28)
		tmp = abs((x / (y_m / z)));
	elseif ((x <= -1.55) || ~((x <= 4.0)))
		tmp = t_0;
	else
		tmp = abs((4.0 / y_m));
	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]}, If[LessEqual[x, -6.5e+56], t$95$0, If[LessEqual[x, -3.4e+28], N[Abs[N[(x / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, -1.55], N[Not[LessEqual[x, 4.0]], $MachinePrecision]], t$95$0, N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
y_m = \left|y\right|

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

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

\mathbf{elif}\;x \leq -1.55 \lor \neg \left(x \leq 4\right):\\
\;\;\;\;t\_0\\

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


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

    1. Initial program 87.0%

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

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

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

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

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

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

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

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

    if -6.5000000000000001e56 < x < -3.4e28

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.55000000000000004 < x < 4

    1. Initial program 94.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{+56}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -3.4 \cdot 10^{+28}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;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 8: 98.6% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 87.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.5 < x < 3.89999999999999991

    1. Initial program 94.9%

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

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

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

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

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

        \[\leadsto \left|\frac{z \cdot \color{blue}{\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 99.0%

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

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

Alternative 9: 97.9% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq 1.15 \cdot 10^{+14}:\\ \;\;\;\;\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 1.15e+14)
   (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 <= 1.15e+14) {
		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 <= 1.15d+14) 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 <= 1.15e+14) {
		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 <= 1.15e+14:
		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 <= 1.15e+14)
		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 <= 1.15e+14)
		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, 1.15e+14], 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 1.15 \cdot 10^{+14}:\\
\;\;\;\;\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 < 1.15e14

    1. Initial program 93.2%

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

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

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

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

    if 1.15e14 < x

    1. Initial program 85.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.55000000000000004 < x < 4

    1. Initial program 94.9%

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

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

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

Alternative 11: 40.5% 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 91.5%

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

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

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

Reproduce

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