fabs fraction 1

Percentage Accurate: 91.4% → 99.8%
Time: 10.0s
Alternatives: 14
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 14 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.4% 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.8% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 92.0%

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

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

    if 4.99999999999999986e-29 < y

    1. Initial program 96.8%

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

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

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

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

Alternative 2: 68.3% accurate, 0.8× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \left|z \cdot \frac{x}{y_m}\right|\\ t_1 := \left|\frac{x}{y_m}\right|\\ \mathbf{if}\;x \leq -1.95 \cdot 10^{+139}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -0.047:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-44}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-50}:\\ \;\;\;\;\left|\frac{4}{y_m}\right|\\ \mathbf{elif}\;x \leq 4 \cdot 10^{+100} \lor \neg \left(x \leq 8.2 \cdot 10^{+236}\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 (* z (/ x y_m)))) (t_1 (fabs (/ x y_m))))
   (if (<= x -1.95e+139)
     t_0
     (if (<= x -0.047)
       t_1
       (if (<= x -2e-44)
         t_0
         (if (<= x 7.5e-50)
           (fabs (/ 4.0 y_m))
           (if (or (<= x 4e+100) (not (<= x 8.2e+236))) t_0 t_1)))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = fabs((z * (x / y_m)));
	double t_1 = fabs((x / y_m));
	double tmp;
	if (x <= -1.95e+139) {
		tmp = t_0;
	} else if (x <= -0.047) {
		tmp = t_1;
	} else if (x <= -2e-44) {
		tmp = t_0;
	} else if (x <= 7.5e-50) {
		tmp = fabs((4.0 / y_m));
	} else if ((x <= 4e+100) || !(x <= 8.2e+236)) {
		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((z * (x / y_m)))
    t_1 = abs((x / y_m))
    if (x <= (-1.95d+139)) then
        tmp = t_0
    else if (x <= (-0.047d0)) then
        tmp = t_1
    else if (x <= (-2d-44)) then
        tmp = t_0
    else if (x <= 7.5d-50) then
        tmp = abs((4.0d0 / y_m))
    else if ((x <= 4d+100) .or. (.not. (x <= 8.2d+236))) 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((z * (x / y_m)));
	double t_1 = Math.abs((x / y_m));
	double tmp;
	if (x <= -1.95e+139) {
		tmp = t_0;
	} else if (x <= -0.047) {
		tmp = t_1;
	} else if (x <= -2e-44) {
		tmp = t_0;
	} else if (x <= 7.5e-50) {
		tmp = Math.abs((4.0 / y_m));
	} else if ((x <= 4e+100) || !(x <= 8.2e+236)) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	t_0 = math.fabs((z * (x / y_m)))
	t_1 = math.fabs((x / y_m))
	tmp = 0
	if x <= -1.95e+139:
		tmp = t_0
	elif x <= -0.047:
		tmp = t_1
	elif x <= -2e-44:
		tmp = t_0
	elif x <= 7.5e-50:
		tmp = math.fabs((4.0 / y_m))
	elif (x <= 4e+100) or not (x <= 8.2e+236):
		tmp = t_0
	else:
		tmp = t_1
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	t_0 = abs(Float64(z * Float64(x / y_m)))
	t_1 = abs(Float64(x / y_m))
	tmp = 0.0
	if (x <= -1.95e+139)
		tmp = t_0;
	elseif (x <= -0.047)
		tmp = t_1;
	elseif (x <= -2e-44)
		tmp = t_0;
	elseif (x <= 7.5e-50)
		tmp = abs(Float64(4.0 / y_m));
	elseif ((x <= 4e+100) || !(x <= 8.2e+236))
		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((z * (x / y_m)));
	t_1 = abs((x / y_m));
	tmp = 0.0;
	if (x <= -1.95e+139)
		tmp = t_0;
	elseif (x <= -0.047)
		tmp = t_1;
	elseif (x <= -2e-44)
		tmp = t_0;
	elseif (x <= 7.5e-50)
		tmp = abs((4.0 / y_m));
	elseif ((x <= 4e+100) || ~((x <= 8.2e+236)))
		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[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.95e+139], t$95$0, If[LessEqual[x, -0.047], t$95$1, If[LessEqual[x, -2e-44], t$95$0, If[LessEqual[x, 7.5e-50], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 4e+100], N[Not[LessEqual[x, 8.2e+236]], $MachinePrecision]], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
y_m = \left|y\right|

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

\mathbf{elif}\;x \leq -0.047:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -2 \cdot 10^{-44}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 7.5 \cdot 10^{-50}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\

\mathbf{elif}\;x \leq 4 \cdot 10^{+100} \lor \neg \left(x \leq 8.2 \cdot 10^{+236}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.95000000000000003e139 or -0.047 < x < -1.99999999999999991e-44 or 7.5e-50 < x < 4.00000000000000006e100 or 8.2000000000000008e236 < x

    1. Initial program 85.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.95000000000000003e139 < x < -0.047 or 4.00000000000000006e100 < x < 8.2000000000000008e236

    1. Initial program 91.6%

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{4}{y} + \frac{x}{y}}\right| \]
    6. Taylor expanded in x around inf 67.0%

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

    if -1.99999999999999991e-44 < x < 7.5e-50

    1. Initial program 98.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.95 \cdot 10^{+139}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -0.047:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-44}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-50}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 4 \cdot 10^{+100} \lor \neg \left(x \leq 8.2 \cdot 10^{+236}\right):\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 67.8% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;x \leq -0.047:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -1.1 \cdot 10^{-43}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 2.9 \cdot 10^{-60}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\

\mathbf{elif}\;x \leq 8.5 \cdot 10^{+100}:\\
\;\;\;\;\left|\frac{x}{\frac{y_m}{z}}\right|\\

\mathbf{elif}\;x \leq 1.45 \cdot 10^{+238}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -3.0999999999999998e132 or -0.047 < x < -1.09999999999999999e-43 or 1.4500000000000001e238 < x

    1. Initial program 81.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{x \cdot z}{y}}\right)} - 1\right| \]
    7. Applied egg-rr19.4%

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

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

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

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z}\right| \]
    9. Simplified77.0%

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

    if -3.0999999999999998e132 < x < -0.047 or 8.50000000000000043e100 < x < 1.4500000000000001e238

    1. Initial program 91.6%

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{4}{y} + \frac{x}{y}}\right| \]
    6. Taylor expanded in x around inf 67.0%

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

    if -1.09999999999999999e-43 < x < 2.8999999999999999e-60

    1. Initial program 98.5%

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

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

    if 2.8999999999999999e-60 < x < 8.50000000000000043e100

    1. Initial program 95.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.1 \cdot 10^{+132}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -0.047:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.1 \cdot 10^{-43}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{-60}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{+100}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{+238}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 67.6% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;x \leq -0.047:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -1.45 \cdot 10^{-43}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 1.5 \cdot 10^{-53}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\

\mathbf{elif}\;x \leq 4.5 \cdot 10^{+101}:\\
\;\;\;\;\left|\frac{x}{\frac{y_m}{z}}\right|\\

\mathbf{elif}\;x \leq 1.9 \cdot 10^{+234}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < -6.6000000000000006e132

    1. Initial program 76.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.6000000000000006e132 < x < -0.047 or 4.5000000000000002e101 < x < 1.9e234

    1. Initial program 91.6%

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{4}{y} + \frac{x}{y}}\right| \]
    6. Taylor expanded in x around inf 67.0%

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

    if -0.047 < x < -1.4500000000000001e-43 or 1.9e234 < x

    1. Initial program 89.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.4500000000000001e-43 < x < 1.5000000000000001e-53

    1. Initial program 98.5%

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

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

    if 1.5000000000000001e-53 < x < 4.5000000000000002e101

    1. Initial program 95.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.6 \cdot 10^{+132}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \leq -0.047:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.45 \cdot 10^{-43}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-53}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{+101}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{+234}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 67.5% accurate, 0.8× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \left|z \cdot \frac{x}{y_m}\right|\\ t_1 := \left|\frac{x}{y_m}\right|\\ \mathbf{if}\;x \leq -2.9 \cdot 10^{+140}:\\ \;\;\;\;\left|\frac{z}{\frac{y_m}{x}}\right|\\ \mathbf{elif}\;x \leq -0.047:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.25 \cdot 10^{-43}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-50}:\\ \;\;\;\;\left|\frac{4}{y_m}\right|\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{+101}:\\ \;\;\;\;\left|\frac{x \cdot z}{y_m}\right|\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{+234}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (let* ((t_0 (fabs (* z (/ x y_m)))) (t_1 (fabs (/ x y_m))))
   (if (<= x -2.9e+140)
     (fabs (/ z (/ y_m x)))
     (if (<= x -0.047)
       t_1
       (if (<= x -1.25e-43)
         t_0
         (if (<= x 7e-50)
           (fabs (/ 4.0 y_m))
           (if (<= x 5.6e+101)
             (fabs (/ (* x z) y_m))
             (if (<= x 4.2e+234) t_1 t_0))))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = fabs((z * (x / y_m)));
	double t_1 = fabs((x / y_m));
	double tmp;
	if (x <= -2.9e+140) {
		tmp = fabs((z / (y_m / x)));
	} else if (x <= -0.047) {
		tmp = t_1;
	} else if (x <= -1.25e-43) {
		tmp = t_0;
	} else if (x <= 7e-50) {
		tmp = fabs((4.0 / y_m));
	} else if (x <= 5.6e+101) {
		tmp = fabs(((x * z) / y_m));
	} else if (x <= 4.2e+234) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y_m
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = abs((z * (x / y_m)))
    t_1 = abs((x / y_m))
    if (x <= (-2.9d+140)) then
        tmp = abs((z / (y_m / x)))
    else if (x <= (-0.047d0)) then
        tmp = t_1
    else if (x <= (-1.25d-43)) then
        tmp = t_0
    else if (x <= 7d-50) then
        tmp = abs((4.0d0 / y_m))
    else if (x <= 5.6d+101) then
        tmp = abs(((x * z) / y_m))
    else if (x <= 4.2d+234) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	double t_0 = Math.abs((z * (x / y_m)));
	double t_1 = Math.abs((x / y_m));
	double tmp;
	if (x <= -2.9e+140) {
		tmp = Math.abs((z / (y_m / x)));
	} else if (x <= -0.047) {
		tmp = t_1;
	} else if (x <= -1.25e-43) {
		tmp = t_0;
	} else if (x <= 7e-50) {
		tmp = Math.abs((4.0 / y_m));
	} else if (x <= 5.6e+101) {
		tmp = Math.abs(((x * z) / y_m));
	} else if (x <= 4.2e+234) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	t_0 = math.fabs((z * (x / y_m)))
	t_1 = math.fabs((x / y_m))
	tmp = 0
	if x <= -2.9e+140:
		tmp = math.fabs((z / (y_m / x)))
	elif x <= -0.047:
		tmp = t_1
	elif x <= -1.25e-43:
		tmp = t_0
	elif x <= 7e-50:
		tmp = math.fabs((4.0 / y_m))
	elif x <= 5.6e+101:
		tmp = math.fabs(((x * z) / y_m))
	elif x <= 4.2e+234:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	t_0 = abs(Float64(z * Float64(x / y_m)))
	t_1 = abs(Float64(x / y_m))
	tmp = 0.0
	if (x <= -2.9e+140)
		tmp = abs(Float64(z / Float64(y_m / x)));
	elseif (x <= -0.047)
		tmp = t_1;
	elseif (x <= -1.25e-43)
		tmp = t_0;
	elseif (x <= 7e-50)
		tmp = abs(Float64(4.0 / y_m));
	elseif (x <= 5.6e+101)
		tmp = abs(Float64(Float64(x * z) / y_m));
	elseif (x <= 4.2e+234)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	t_0 = abs((z * (x / y_m)));
	t_1 = abs((x / y_m));
	tmp = 0.0;
	if (x <= -2.9e+140)
		tmp = abs((z / (y_m / x)));
	elseif (x <= -0.047)
		tmp = t_1;
	elseif (x <= -1.25e-43)
		tmp = t_0;
	elseif (x <= 7e-50)
		tmp = abs((4.0 / y_m));
	elseif (x <= 5.6e+101)
		tmp = abs(((x * z) / y_m));
	elseif (x <= 4.2e+234)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[Abs[N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -2.9e+140], N[Abs[N[(z / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, -0.047], t$95$1, If[LessEqual[x, -1.25e-43], t$95$0, If[LessEqual[x, 7e-50], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 5.6e+101], N[Abs[N[(N[(x * z), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.2e+234], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
y_m = \left|y\right|

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

\mathbf{elif}\;x \leq -0.047:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -1.25 \cdot 10^{-43}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 7 \cdot 10^{-50}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\

\mathbf{elif}\;x \leq 5.6 \cdot 10^{+101}:\\
\;\;\;\;\left|\frac{x \cdot z}{y_m}\right|\\

\mathbf{elif}\;x \leq 4.2 \cdot 10^{+234}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < -2.8999999999999999e140

    1. Initial program 76.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.8999999999999999e140 < x < -0.047 or 5.59999999999999962e101 < x < 4.2e234

    1. Initial program 91.6%

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{4}{y} + \frac{x}{y}}\right| \]
    6. Taylor expanded in x around inf 67.0%

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

    if -0.047 < x < -1.25000000000000005e-43 or 4.2e234 < x

    1. Initial program 89.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.25000000000000005e-43 < x < 6.99999999999999993e-50

    1. Initial program 98.5%

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

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

    if 6.99999999999999993e-50 < x < 5.59999999999999962e101

    1. Initial program 95.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.9 \cdot 10^{+140}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \leq -0.047:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.25 \cdot 10^{-43}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-50}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{+101}:\\ \;\;\;\;\left|\frac{x \cdot z}{y}\right|\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{+234}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 85.5% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \left|x \cdot \frac{1 - z}{y_m}\right|\\
\mathbf{if}\;x \leq -8.3 \cdot 10^{+15}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -9.6 \cdot 10^{-31}:\\
\;\;\;\;\left|\frac{-4 - x}{y_m}\right|\\

\mathbf{elif}\;x \leq -1.3 \cdot 10^{-43}:\\
\;\;\;\;\left|z \cdot \frac{x}{y_m}\right|\\

\mathbf{elif}\;x \leq 4 \cdot 10^{-54}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -8.3e15 or 4.0000000000000001e-54 < x

    1. Initial program 86.4%

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

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

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

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

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

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

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

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

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

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

    if -8.3e15 < x < -9.6000000000000001e-31

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

    if -9.6000000000000001e-31 < x < -1.3e-43

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z}\right| \]
    9. Simplified100.0%

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

    if -1.3e-43 < x < 4.0000000000000001e-54

    1. Initial program 98.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -8.3 \cdot 10^{+15}:\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \mathbf{elif}\;x \leq -9.6 \cdot 10^{-31}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{elif}\;x \leq -1.3 \cdot 10^{-43}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-54}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 85.2% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.3 \cdot 10^{+15}:\\
\;\;\;\;\left|\frac{x}{y_m} \cdot \left(z + 1\right)\right|\\

\mathbf{elif}\;x \leq -7.7 \cdot 10^{-31}:\\
\;\;\;\;\left|\frac{-4 - x}{y_m}\right|\\

\mathbf{elif}\;x \leq -4.1 \cdot 10^{-44}:\\
\;\;\;\;\left|z \cdot \frac{x}{y_m}\right|\\

\mathbf{elif}\;x \leq 4.1 \cdot 10^{-50}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < -8.3e15

    1. Initial program 82.1%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{x}{y} + \frac{x \cdot z}{y}}\right| \]
    6. Step-by-step derivation
      1. *-rgt-identity83.1%

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

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

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

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

    if -8.3e15 < x < -7.70000000000000012e-31

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

    if -7.70000000000000012e-31 < x < -4.09999999999999992e-44

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z}\right| \]
    9. Simplified100.0%

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

    if -4.09999999999999992e-44 < x < 4.09999999999999985e-50

    1. Initial program 98.5%

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

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

    if 4.09999999999999985e-50 < x

    1. Initial program 90.0%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -8.3 \cdot 10^{+15}:\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(z + 1\right)\right|\\ \mathbf{elif}\;x \leq -7.7 \cdot 10^{-31}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{elif}\;x \leq -4.1 \cdot 10^{-44}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 4.1 \cdot 10^{-50}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 85.2% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.3 \cdot 10^{+15}:\\
\;\;\;\;\left|\frac{x}{y_m} \cdot \left(z + 1\right)\right|\\

\mathbf{elif}\;x \leq -8.2 \cdot 10^{-31}:\\
\;\;\;\;\left|\frac{x}{y_m} + \frac{4}{y_m}\right|\\

\mathbf{elif}\;x \leq -5.4 \cdot 10^{-45}:\\
\;\;\;\;\left|z \cdot \frac{x}{y_m}\right|\\

\mathbf{elif}\;x \leq 8.5 \cdot 10^{-52}:\\
\;\;\;\;\left|\frac{4}{y_m}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < -8.3e15

    1. Initial program 82.1%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{x}{y} + \frac{x \cdot z}{y}}\right| \]
    6. Step-by-step derivation
      1. *-rgt-identity83.1%

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

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

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

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

    if -8.3e15 < x < -8.1999999999999993e-31

    1. Initial program 99.8%

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

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

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

        \[\leadsto \left|\frac{\color{blue}{4}}{y} + \frac{x}{y}\right| \]
    5. Simplified90.0%

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

    if -8.1999999999999993e-31 < x < -5.3999999999999997e-45

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z}\right| \]
    9. Simplified100.0%

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

    if -5.3999999999999997e-45 < x < 8.50000000000000006e-52

    1. Initial program 98.5%

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

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

    if 8.50000000000000006e-52 < x

    1. Initial program 90.0%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -8.3 \cdot 10^{+15}:\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(z + 1\right)\right|\\ \mathbf{elif}\;x \leq -8.2 \cdot 10^{-31}:\\ \;\;\;\;\left|\frac{x}{y} + \frac{4}{y}\right|\\ \mathbf{elif}\;x \leq -5.4 \cdot 10^{-45}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-52}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 97.6% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \frac{4 + x}{y_m}\\ t_1 := z \cdot \frac{x}{y_m}\\ \mathbf{if}\;t_0 - t_1 \leq -5 \cdot 10^{+106}:\\ \;\;\;\;\left|t_1 - t_0\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y_m}\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (let* ((t_0 (/ (+ 4.0 x) y_m)) (t_1 (* z (/ x y_m))))
   (if (<= (- t_0 t_1) -5e+106)
     (fabs (- t_1 t_0))
     (fabs (/ (- (+ 4.0 x) (* x z)) y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = (4.0 + x) / y_m;
	double t_1 = z * (x / y_m);
	double tmp;
	if ((t_0 - t_1) <= -5e+106) {
		tmp = fabs((t_1 - t_0));
	} else {
		tmp = fabs((((4.0 + x) - (x * z)) / 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) :: t_1
    real(8) :: tmp
    t_0 = (4.0d0 + x) / y_m
    t_1 = z * (x / y_m)
    if ((t_0 - t_1) <= (-5d+106)) then
        tmp = abs((t_1 - t_0))
    else
        tmp = abs((((4.0d0 + x) - (x * z)) / 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 = (4.0 + x) / y_m;
	double t_1 = z * (x / y_m);
	double tmp;
	if ((t_0 - t_1) <= -5e+106) {
		tmp = Math.abs((t_1 - t_0));
	} else {
		tmp = Math.abs((((4.0 + x) - (x * z)) / y_m));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	t_0 = (4.0 + x) / y_m
	t_1 = z * (x / y_m)
	tmp = 0
	if (t_0 - t_1) <= -5e+106:
		tmp = math.fabs((t_1 - t_0))
	else:
		tmp = math.fabs((((4.0 + x) - (x * z)) / y_m))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	t_0 = Float64(Float64(4.0 + x) / y_m)
	t_1 = Float64(z * Float64(x / y_m))
	tmp = 0.0
	if (Float64(t_0 - t_1) <= -5e+106)
		tmp = abs(Float64(t_1 - t_0));
	else
		tmp = abs(Float64(Float64(Float64(4.0 + x) - Float64(x * z)) / y_m));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	t_0 = (4.0 + x) / y_m;
	t_1 = z * (x / y_m);
	tmp = 0.0;
	if ((t_0 - t_1) <= -5e+106)
		tmp = abs((t_1 - t_0));
	else
		tmp = abs((((4.0 + x) - (x * z)) / y_m));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := Block[{t$95$0 = N[(N[(4.0 + x), $MachinePrecision] / y$95$m), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - t$95$1), $MachinePrecision], -5e+106], N[Abs[N[(t$95$1 - t$95$0), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := \frac{4 + x}{y_m}\\
t_1 := z \cdot \frac{x}{y_m}\\
\mathbf{if}\;t_0 - t_1 \leq -5 \cdot 10^{+106}:\\
\;\;\;\;\left|t_1 - t_0\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z)) < -4.9999999999999998e106

    1. Initial program 99.9%

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

    if -4.9999999999999998e106 < (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))

    1. Initial program 91.4%

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

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

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

Alternative 10: 99.0% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+163}:\\
\;\;\;\;\left|\frac{x}{y_m} \cdot \left(z + 1\right)\right|\\

\mathbf{elif}\;x \leq 6 \cdot 10^{+17}:\\
\;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y_m}\right|\\

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


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

    1. Initial program 74.8%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{x}{y} + \frac{x \cdot z}{y}}\right| \]
    6. Step-by-step derivation
      1. *-rgt-identity69.3%

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

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

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

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

    if -9.9999999999999994e162 < x < 6e17

    1. Initial program 97.2%

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

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

    if 6e17 < x

    1. Initial program 89.5%

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

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

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

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

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

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

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

Alternative 11: 99.8% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 92.0%

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

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

    if 5.9999999999999998e-30 < y

    1. Initial program 96.8%

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

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

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

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

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

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

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

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

Alternative 12: 84.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.45 \cdot 10^{+101}:\\
\;\;\;\;\left|\frac{z}{\frac{y_m}{x}}\right|\\

\mathbf{elif}\;z \leq 2.25 \cdot 10^{+92}:\\
\;\;\;\;\left|\frac{-4 - x}{y_m}\right|\\

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


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

    1. Initial program 96.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.44999999999999994e101 < z < 2.25e92

    1. Initial program 94.4%

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

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

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

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

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

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

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

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

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

    if 2.25e92 < z

    1. Initial program 84.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{x \cdot z}{y}}\right)} - 1\right| \]
    7. Applied egg-rr19.5%

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

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

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

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

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

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

Alternative 13: 68.4% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -1.5 \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.5) (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.5) || !(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.5d0)) .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.5) || !(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.5) 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.5) || !(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.5) || ~((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.5], 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.5 \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.5 or 4 < x

    1. Initial program 86.9%

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{4}{y} + \frac{x}{y}}\right| \]
    6. Taylor expanded in x around inf 59.2%

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

    if -1.5 < x < 4

    1. Initial program 97.9%

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

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

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

Alternative 14: 39.3% accurate, 1.1× speedup?

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

\\
\left|\frac{4}{y_m}\right|
\end{array}
Derivation
  1. Initial program 93.3%

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

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

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

Reproduce

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