fabs fraction 1

Percentage Accurate: 91.9% → 99.8%
Time: 7.6s
Alternatives: 10
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 91.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 86.2%

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

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

    if 2.00000000000000013e-37 < y

    1. Initial program 99.8%

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

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

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

Alternative 2: 67.4% accurate, 1.0× speedup?

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

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

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

\mathbf{elif}\;x \leq 9 \cdot 10^{+110} \lor \neg \left(x \leq 3.2 \cdot 10^{+229}\right) \land x \leq 1.1 \cdot 10^{+284}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -7.9999999999999998e-16 or 3.4000000000000001e-120 < x < 9.0000000000000005e110 or 3.1999999999999998e229 < x < 1.09999999999999997e284

    1. Initial program 86.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.9999999999999998e-16 < x < 3.4000000000000001e-120

    1. Initial program 97.6%

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

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

    if 9.0000000000000005e110 < x < 3.1999999999999998e229 or 1.09999999999999997e284 < x

    1. Initial program 78.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -8 \cdot 10^{-16}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{-120}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 9 \cdot 10^{+110} \lor \neg \left(x \leq 3.2 \cdot 10^{+229}\right) \land x \leq 1.1 \cdot 10^{+284}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 3: 67.3% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \left|z \cdot \frac{x}{y_m}\right|\\ \mathbf{if}\;x \leq -9.8 \cdot 10^{-14}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{-120}:\\ \;\;\;\;\left|\frac{4}{y_m}\right|\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+104}:\\ \;\;\;\;\left|\frac{x}{\frac{y_m}{z}}\right|\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{+227} \lor \neg \left(x \leq 1.16 \cdot 10^{+284}\right):\\ \;\;\;\;\left|\frac{x}{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 (* z (/ x y_m)))))
   (if (<= x -9.8e-14)
     t_0
     (if (<= x 3.4e-120)
       (fabs (/ 4.0 y_m))
       (if (<= x 1.5e+104)
         (fabs (/ x (/ y_m z)))
         (if (or (<= x 5.2e+227) (not (<= x 1.16e+284)))
           (fabs (/ x y_m))
           t_0))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = fabs((z * (x / y_m)));
	double tmp;
	if (x <= -9.8e-14) {
		tmp = t_0;
	} else if (x <= 3.4e-120) {
		tmp = fabs((4.0 / y_m));
	} else if (x <= 1.5e+104) {
		tmp = fabs((x / (y_m / z)));
	} else if ((x <= 5.2e+227) || !(x <= 1.16e+284)) {
		tmp = fabs((x / 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((z * (x / y_m)))
    if (x <= (-9.8d-14)) then
        tmp = t_0
    else if (x <= 3.4d-120) then
        tmp = abs((4.0d0 / y_m))
    else if (x <= 1.5d+104) then
        tmp = abs((x / (y_m / z)))
    else if ((x <= 5.2d+227) .or. (.not. (x <= 1.16d+284))) then
        tmp = abs((x / 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((z * (x / y_m)));
	double tmp;
	if (x <= -9.8e-14) {
		tmp = t_0;
	} else if (x <= 3.4e-120) {
		tmp = Math.abs((4.0 / y_m));
	} else if (x <= 1.5e+104) {
		tmp = Math.abs((x / (y_m / z)));
	} else if ((x <= 5.2e+227) || !(x <= 1.16e+284)) {
		tmp = Math.abs((x / y_m));
	} 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)))
	tmp = 0
	if x <= -9.8e-14:
		tmp = t_0
	elif x <= 3.4e-120:
		tmp = math.fabs((4.0 / y_m))
	elif x <= 1.5e+104:
		tmp = math.fabs((x / (y_m / z)))
	elif (x <= 5.2e+227) or not (x <= 1.16e+284):
		tmp = math.fabs((x / y_m))
	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)))
	tmp = 0.0
	if (x <= -9.8e-14)
		tmp = t_0;
	elseif (x <= 3.4e-120)
		tmp = abs(Float64(4.0 / y_m));
	elseif (x <= 1.5e+104)
		tmp = abs(Float64(x / Float64(y_m / z)));
	elseif ((x <= 5.2e+227) || !(x <= 1.16e+284))
		tmp = abs(Float64(x / 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((z * (x / y_m)));
	tmp = 0.0;
	if (x <= -9.8e-14)
		tmp = t_0;
	elseif (x <= 3.4e-120)
		tmp = abs((4.0 / y_m));
	elseif (x <= 1.5e+104)
		tmp = abs((x / (y_m / z)));
	elseif ((x <= 5.2e+227) || ~((x <= 1.16e+284)))
		tmp = abs((x / 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[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -9.8e-14], t$95$0, If[LessEqual[x, 3.4e-120], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 1.5e+104], N[Abs[N[(x / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 5.2e+227], N[Not[LessEqual[x, 1.16e+284]], $MachinePrecision]], N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
y_m = \left|y\right|

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

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

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

\mathbf{elif}\;x \leq 5.2 \cdot 10^{+227} \lor \neg \left(x \leq 1.16 \cdot 10^{+284}\right):\\
\;\;\;\;\left|\frac{x}{y_m}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -9.79999999999999989e-14 or 5.19999999999999964e227 < x < 1.1599999999999999e284

    1. Initial program 83.0%

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \left(-z\right)\right)} - 1}\right| \]
      3. *-commutative29.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.79999999999999989e-14 < x < 3.4000000000000001e-120

    1. Initial program 97.6%

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

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

    if 3.4000000000000001e-120 < x < 1.49999999999999984e104

    1. Initial program 94.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.49999999999999984e104 < x < 5.19999999999999964e227 or 1.1599999999999999e284 < x

    1. Initial program 78.0%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9.8 \cdot 10^{-14}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{-120}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+104}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{+227} \lor \neg \left(x \leq 1.16 \cdot 10^{+284}\right):\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]

Alternative 4: 99.7% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -4.6 \cdot 10^{+26} \lor \neg \left(x \leq 9.5 \cdot 10^{+51}\right):\\ \;\;\;\;\left|x \cdot \left(\frac{z}{y_m} + \frac{-1}{y_m}\right)\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
 (if (or (<= x -4.6e+26) (not (<= x 9.5e+51)))
   (fabs (* x (+ (/ z y_m) (/ -1.0 y_m))))
   (fabs (/ (- (+ 4.0 x) (* x z)) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if ((x <= -4.6e+26) || !(x <= 9.5e+51)) {
		tmp = fabs((x * ((z / y_m) + (-1.0 / y_m))));
	} 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) :: tmp
    if ((x <= (-4.6d+26)) .or. (.not. (x <= 9.5d+51))) then
        tmp = abs((x * ((z / y_m) + ((-1.0d0) / y_m))))
    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 tmp;
	if ((x <= -4.6e+26) || !(x <= 9.5e+51)) {
		tmp = Math.abs((x * ((z / y_m) + (-1.0 / y_m))));
	} else {
		tmp = Math.abs((((4.0 + x) - (x * z)) / y_m));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if (x <= -4.6e+26) or not (x <= 9.5e+51):
		tmp = math.fabs((x * ((z / y_m) + (-1.0 / y_m))))
	else:
		tmp = math.fabs((((4.0 + x) - (x * z)) / y_m))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if ((x <= -4.6e+26) || !(x <= 9.5e+51))
		tmp = abs(Float64(x * Float64(Float64(z / y_m) + Float64(-1.0 / y_m))));
	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)
	tmp = 0.0;
	if ((x <= -4.6e+26) || ~((x <= 9.5e+51)))
		tmp = abs((x * ((z / y_m) + (-1.0 / y_m))));
	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_] := If[Or[LessEqual[x, -4.6e+26], N[Not[LessEqual[x, 9.5e+51]], $MachinePrecision]], N[Abs[N[(x * N[(N[(z / y$95$m), $MachinePrecision] + N[(-1.0 / y$95$m), $MachinePrecision]), $MachinePrecision]), $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}
\mathbf{if}\;x \leq -4.6 \cdot 10^{+26} \lor \neg \left(x \leq 9.5 \cdot 10^{+51}\right):\\
\;\;\;\;\left|x \cdot \left(\frac{z}{y_m} + \frac{-1}{y_m}\right)\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 x < -4.6000000000000001e26 or 9.4999999999999999e51 < x

    1. Initial program 79.7%

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

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

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

    if -4.6000000000000001e26 < x < 9.4999999999999999e51

    1. Initial program 97.5%

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

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

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

Alternative 5: 98.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 86.1%

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

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

    if 1.50000000000000002e-43 < y

    1. Initial program 99.8%

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

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

Alternative 6: 99.9% accurate, 1.0× speedup?

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

    1. Initial program 86.2%

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

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

    if 6.80000000000000037e-37 < y

    1. Initial program 99.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 6.8 \cdot 10^{-37}:\\ \;\;\;\;\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} \]

Alternative 7: 85.6% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 97.3%

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \left(-z\right)\right)} - 1}\right| \]
      3. *-commutative34.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.79999999999999981e59 < z < 3.39999999999999977e127

    1. Initial program 89.0%

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

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

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

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

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

    if 3.39999999999999977e127 < z

    1. Initial program 80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.8 \cdot 10^{+59}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{+127}:\\ \;\;\;\;\left|\frac{x}{y} + \frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \end{array} \]

Alternative 8: 85.6% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 97.3%

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{e^{\mathsf{log1p}\left(\frac{x}{y} \cdot \left(-z\right)\right)} - 1}\right| \]
      3. *-commutative34.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.6000000000000002e59 < z < 3.59999999999999979e127

    1. Initial program 89.0%

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

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

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

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

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

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

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

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

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

    if 3.59999999999999979e127 < z

    1. Initial program 80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.6 \cdot 10^{+59}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{+127}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \end{array} \]

Alternative 9: 69.1% accurate, 1.0× speedup?

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

    1. Initial program 81.8%

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

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

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

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

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

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

    if -11 < x < 4

    1. Initial program 97.3%

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

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

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

Alternative 10: 40.4% accurate, 1.1× speedup?

\[\begin{array}{l} 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 89.6%

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

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

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

Reproduce

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