fabs fraction 1

Percentage Accurate: 91.9% → 99.0%
Time: 5.9s
Alternatives: 8
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 8 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.0% accurate, 1.0× speedup?

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

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


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

    1. Initial program 87.4%

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

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

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

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

    if 8.8000000000000005e-107 < y

    1. Initial program 97.3%

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

      \[\leadsto \color{blue}{\left|\frac{1}{y} \cdot \mathsf{fma}\left(x, z, -4 - x\right)\right|} \]
    3. Step-by-step derivation
      1. fma-udef94.2%

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

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

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

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

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

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

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

Alternative 2: 68.8% accurate, 0.9× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} t_0 := \left|z \cdot \frac{x}{y}\right|\\ t_1 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -6.8 \cdot 10^{+232}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{+132}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.05 \cdot 10^{-24}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-65}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 300000000000 \lor \neg \left(x \leq 2.2 \cdot 10^{+106}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (* z (/ x y)))) (t_1 (fabs (/ x y))))
   (if (<= x -6.8e+232)
     t_0
     (if (<= x -1.4e+132)
       t_1
       (if (<= x -2.05e-24)
         t_0
         (if (<= x 4e-65)
           (fabs (/ 4.0 y))
           (if (or (<= x 300000000000.0) (not (<= x 2.2e+106))) t_0 t_1)))))))
y = abs(y);
double code(double x, double y, double z) {
	double t_0 = fabs((z * (x / y)));
	double t_1 = fabs((x / y));
	double tmp;
	if (x <= -6.8e+232) {
		tmp = t_0;
	} else if (x <= -1.4e+132) {
		tmp = t_1;
	} else if (x <= -2.05e-24) {
		tmp = t_0;
	} else if (x <= 4e-65) {
		tmp = fabs((4.0 / y));
	} else if ((x <= 300000000000.0) || !(x <= 2.2e+106)) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = abs((z * (x / y)))
    t_1 = abs((x / y))
    if (x <= (-6.8d+232)) then
        tmp = t_0
    else if (x <= (-1.4d+132)) then
        tmp = t_1
    else if (x <= (-2.05d-24)) then
        tmp = t_0
    else if (x <= 4d-65) then
        tmp = abs((4.0d0 / y))
    else if ((x <= 300000000000.0d0) .or. (.not. (x <= 2.2d+106))) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double t_0 = Math.abs((z * (x / y)));
	double t_1 = Math.abs((x / y));
	double tmp;
	if (x <= -6.8e+232) {
		tmp = t_0;
	} else if (x <= -1.4e+132) {
		tmp = t_1;
	} else if (x <= -2.05e-24) {
		tmp = t_0;
	} else if (x <= 4e-65) {
		tmp = Math.abs((4.0 / y));
	} else if ((x <= 300000000000.0) || !(x <= 2.2e+106)) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	t_0 = math.fabs((z * (x / y)))
	t_1 = math.fabs((x / y))
	tmp = 0
	if x <= -6.8e+232:
		tmp = t_0
	elif x <= -1.4e+132:
		tmp = t_1
	elif x <= -2.05e-24:
		tmp = t_0
	elif x <= 4e-65:
		tmp = math.fabs((4.0 / y))
	elif (x <= 300000000000.0) or not (x <= 2.2e+106):
		tmp = t_0
	else:
		tmp = t_1
	return tmp
y = abs(y)
function code(x, y, z)
	t_0 = abs(Float64(z * Float64(x / y)))
	t_1 = abs(Float64(x / y))
	tmp = 0.0
	if (x <= -6.8e+232)
		tmp = t_0;
	elseif (x <= -1.4e+132)
		tmp = t_1;
	elseif (x <= -2.05e-24)
		tmp = t_0;
	elseif (x <= 4e-65)
		tmp = abs(Float64(4.0 / y));
	elseif ((x <= 300000000000.0) || !(x <= 2.2e+106))
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	t_0 = abs((z * (x / y)));
	t_1 = abs((x / y));
	tmp = 0.0;
	if (x <= -6.8e+232)
		tmp = t_0;
	elseif (x <= -1.4e+132)
		tmp = t_1;
	elseif (x <= -2.05e-24)
		tmp = t_0;
	elseif (x <= 4e-65)
		tmp = abs((4.0 / y));
	elseif ((x <= 300000000000.0) || ~((x <= 2.2e+106)))
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -6.8e+232], t$95$0, If[LessEqual[x, -1.4e+132], t$95$1, If[LessEqual[x, -2.05e-24], t$95$0, If[LessEqual[x, 4e-65], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 300000000000.0], N[Not[LessEqual[x, 2.2e+106]], $MachinePrecision]], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|z \cdot \frac{x}{y}\right|\\
t_1 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -6.8 \cdot 10^{+232}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -1.4 \cdot 10^{+132}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -2.05 \cdot 10^{-24}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 300000000000 \lor \neg \left(x \leq 2.2 \cdot 10^{+106}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -6.7999999999999996e232 or -1.4e132 < x < -2.05000000000000007e-24 or 3.99999999999999969e-65 < x < 3e11 or 2.19999999999999992e106 < x

    1. Initial program 88.8%

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

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

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

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

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

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

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

    if -6.7999999999999996e232 < x < -1.4e132 or 3e11 < x < 2.19999999999999992e106

    1. Initial program 83.7%

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

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

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

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

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

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

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

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

    if -2.05000000000000007e-24 < x < 3.99999999999999969e-65

    1. Initial program 94.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.8 \cdot 10^{+232}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{+132}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -2.05 \cdot 10^{-24}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-65}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 300000000000 \lor \neg \left(x \leq 2.2 \cdot 10^{+106}\right):\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 3: 68.4% accurate, 0.9× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} t_0 := \left|\frac{z}{\frac{y}{x}}\right|\\ t_1 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -3.05 \cdot 10^{+230}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{+132}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{-24}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-63}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{+15} \lor \neg \left(x \leq 6.8 \cdot 10^{+106}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (/ z (/ y x)))) (t_1 (fabs (/ x y))))
   (if (<= x -3.05e+230)
     (fabs (* z (/ x y)))
     (if (<= x -1.4e+132)
       t_1
       (if (<= x -3.2e-24)
         t_0
         (if (<= x 8.2e-63)
           (fabs (/ 4.0 y))
           (if (or (<= x 3.4e+15) (not (<= x 6.8e+106))) t_0 t_1)))))))
y = abs(y);
double code(double x, double y, double z) {
	double t_0 = fabs((z / (y / x)));
	double t_1 = fabs((x / y));
	double tmp;
	if (x <= -3.05e+230) {
		tmp = fabs((z * (x / y)));
	} else if (x <= -1.4e+132) {
		tmp = t_1;
	} else if (x <= -3.2e-24) {
		tmp = t_0;
	} else if (x <= 8.2e-63) {
		tmp = fabs((4.0 / y));
	} else if ((x <= 3.4e+15) || !(x <= 6.8e+106)) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = abs((z / (y / x)))
    t_1 = abs((x / y))
    if (x <= (-3.05d+230)) then
        tmp = abs((z * (x / y)))
    else if (x <= (-1.4d+132)) then
        tmp = t_1
    else if (x <= (-3.2d-24)) then
        tmp = t_0
    else if (x <= 8.2d-63) then
        tmp = abs((4.0d0 / y))
    else if ((x <= 3.4d+15) .or. (.not. (x <= 6.8d+106))) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double t_0 = Math.abs((z / (y / x)));
	double t_1 = Math.abs((x / y));
	double tmp;
	if (x <= -3.05e+230) {
		tmp = Math.abs((z * (x / y)));
	} else if (x <= -1.4e+132) {
		tmp = t_1;
	} else if (x <= -3.2e-24) {
		tmp = t_0;
	} else if (x <= 8.2e-63) {
		tmp = Math.abs((4.0 / y));
	} else if ((x <= 3.4e+15) || !(x <= 6.8e+106)) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	t_0 = math.fabs((z / (y / x)))
	t_1 = math.fabs((x / y))
	tmp = 0
	if x <= -3.05e+230:
		tmp = math.fabs((z * (x / y)))
	elif x <= -1.4e+132:
		tmp = t_1
	elif x <= -3.2e-24:
		tmp = t_0
	elif x <= 8.2e-63:
		tmp = math.fabs((4.0 / y))
	elif (x <= 3.4e+15) or not (x <= 6.8e+106):
		tmp = t_0
	else:
		tmp = t_1
	return tmp
y = abs(y)
function code(x, y, z)
	t_0 = abs(Float64(z / Float64(y / x)))
	t_1 = abs(Float64(x / y))
	tmp = 0.0
	if (x <= -3.05e+230)
		tmp = abs(Float64(z * Float64(x / y)));
	elseif (x <= -1.4e+132)
		tmp = t_1;
	elseif (x <= -3.2e-24)
		tmp = t_0;
	elseif (x <= 8.2e-63)
		tmp = abs(Float64(4.0 / y));
	elseif ((x <= 3.4e+15) || !(x <= 6.8e+106))
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	t_0 = abs((z / (y / x)));
	t_1 = abs((x / y));
	tmp = 0.0;
	if (x <= -3.05e+230)
		tmp = abs((z * (x / y)));
	elseif (x <= -1.4e+132)
		tmp = t_1;
	elseif (x <= -3.2e-24)
		tmp = t_0;
	elseif (x <= 8.2e-63)
		tmp = abs((4.0 / y));
	elseif ((x <= 3.4e+15) || ~((x <= 6.8e+106)))
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -3.05e+230], N[Abs[N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, -1.4e+132], t$95$1, If[LessEqual[x, -3.2e-24], t$95$0, If[LessEqual[x, 8.2e-63], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[x, 3.4e+15], N[Not[LessEqual[x, 6.8e+106]], $MachinePrecision]], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|\frac{z}{\frac{y}{x}}\right|\\
t_1 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -3.05 \cdot 10^{+230}:\\
\;\;\;\;\left|z \cdot \frac{x}{y}\right|\\

\mathbf{elif}\;x \leq -1.4 \cdot 10^{+132}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -3.2 \cdot 10^{-24}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 3.4 \cdot 10^{+15} \lor \neg \left(x \leq 6.8 \cdot 10^{+106}\right):\\
\;\;\;\;t_0\\

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


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

    1. Initial program 85.7%

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

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

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

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

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

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

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

    if -3.04999999999999995e230 < x < -1.4e132 or 3.4e15 < x < 6.79999999999999989e106

    1. Initial program 83.7%

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

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

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

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

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

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

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

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

    if -1.4e132 < x < -3.20000000000000012e-24 or 8.1999999999999995e-63 < x < 3.4e15 or 6.79999999999999989e106 < x

    1. Initial program 89.6%

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

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

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

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

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

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

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

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

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

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

    if -3.20000000000000012e-24 < x < 8.1999999999999995e-63

    1. Initial program 94.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.05 \cdot 10^{+230}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{+132}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{-24}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-63}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{+15} \lor \neg \left(x \leq 6.8 \cdot 10^{+106}\right):\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 4: 69.0% accurate, 0.9× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ t_1 := \left|x \cdot \frac{z}{y}\right|\\ \mathbf{if}\;x \leq -1.4 \cdot 10^{+265}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -2.1 \cdot 10^{+233}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.3 \cdot 10^{+131}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -7.6 \cdot 10^{-25}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-63}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 510000000000:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (fabs (/ x y))) (t_1 (fabs (* x (/ z y)))))
   (if (<= x -1.4e+265)
     t_0
     (if (<= x -2.1e+233)
       t_1
       (if (<= x -1.3e+131)
         t_0
         (if (<= x -7.6e-25)
           t_1
           (if (<= x 6e-63)
             (fabs (/ 4.0 y))
             (if (<= x 510000000000.0) t_1 t_0))))))))
y = abs(y);
double code(double x, double y, double z) {
	double t_0 = fabs((x / y));
	double t_1 = fabs((x * (z / y)));
	double tmp;
	if (x <= -1.4e+265) {
		tmp = t_0;
	} else if (x <= -2.1e+233) {
		tmp = t_1;
	} else if (x <= -1.3e+131) {
		tmp = t_0;
	} else if (x <= -7.6e-25) {
		tmp = t_1;
	} else if (x <= 6e-63) {
		tmp = fabs((4.0 / y));
	} else if (x <= 510000000000.0) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = abs((x / y))
    t_1 = abs((x * (z / y)))
    if (x <= (-1.4d+265)) then
        tmp = t_0
    else if (x <= (-2.1d+233)) then
        tmp = t_1
    else if (x <= (-1.3d+131)) then
        tmp = t_0
    else if (x <= (-7.6d-25)) then
        tmp = t_1
    else if (x <= 6d-63) then
        tmp = abs((4.0d0 / y))
    else if (x <= 510000000000.0d0) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	double t_0 = Math.abs((x / y));
	double t_1 = Math.abs((x * (z / y)));
	double tmp;
	if (x <= -1.4e+265) {
		tmp = t_0;
	} else if (x <= -2.1e+233) {
		tmp = t_1;
	} else if (x <= -1.3e+131) {
		tmp = t_0;
	} else if (x <= -7.6e-25) {
		tmp = t_1;
	} else if (x <= 6e-63) {
		tmp = Math.abs((4.0 / y));
	} else if (x <= 510000000000.0) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	t_0 = math.fabs((x / y))
	t_1 = math.fabs((x * (z / y)))
	tmp = 0
	if x <= -1.4e+265:
		tmp = t_0
	elif x <= -2.1e+233:
		tmp = t_1
	elif x <= -1.3e+131:
		tmp = t_0
	elif x <= -7.6e-25:
		tmp = t_1
	elif x <= 6e-63:
		tmp = math.fabs((4.0 / y))
	elif x <= 510000000000.0:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
y = abs(y)
function code(x, y, z)
	t_0 = abs(Float64(x / y))
	t_1 = abs(Float64(x * Float64(z / y)))
	tmp = 0.0
	if (x <= -1.4e+265)
		tmp = t_0;
	elseif (x <= -2.1e+233)
		tmp = t_1;
	elseif (x <= -1.3e+131)
		tmp = t_0;
	elseif (x <= -7.6e-25)
		tmp = t_1;
	elseif (x <= 6e-63)
		tmp = abs(Float64(4.0 / y));
	elseif (x <= 510000000000.0)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	t_0 = abs((x / y));
	t_1 = abs((x * (z / y)));
	tmp = 0.0;
	if (x <= -1.4e+265)
		tmp = t_0;
	elseif (x <= -2.1e+233)
		tmp = t_1;
	elseif (x <= -1.3e+131)
		tmp = t_0;
	elseif (x <= -7.6e-25)
		tmp = t_1;
	elseif (x <= 6e-63)
		tmp = abs((4.0 / y));
	elseif (x <= 510000000000.0)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[Abs[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.4e+265], t$95$0, If[LessEqual[x, -2.1e+233], t$95$1, If[LessEqual[x, -1.3e+131], t$95$0, If[LessEqual[x, -7.6e-25], t$95$1, If[LessEqual[x, 6e-63], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 510000000000.0], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
t_1 := \left|x \cdot \frac{z}{y}\right|\\
\mathbf{if}\;x \leq -1.4 \cdot 10^{+265}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -2.1 \cdot 10^{+233}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -1.3 \cdot 10^{+131}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -7.6 \cdot 10^{-25}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x \leq 510000000000:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.39999999999999995e265 or -2.09999999999999997e233 < x < -1.3e131 or 5.1e11 < x

    1. Initial program 79.2%

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

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

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

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

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

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

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

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

    if -1.39999999999999995e265 < x < -2.09999999999999997e233 or -1.3e131 < x < -7.5999999999999996e-25 or 5.99999999999999959e-63 < x < 5.1e11

    1. Initial program 99.8%

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

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

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

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

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

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

    if -7.5999999999999996e-25 < x < 5.99999999999999959e-63

    1. Initial program 94.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.4 \cdot 10^{+265}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -2.1 \cdot 10^{+233}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq -1.3 \cdot 10^{+131}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -7.6 \cdot 10^{-25}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-63}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 510000000000:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 5: 99.7% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.05e15 or 4.8000000000000003e66 < x

    1. Initial program 84.6%

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

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

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

        \[\leadsto \left|\color{blue}{\frac{z - 1}{\frac{y}{x}}}\right| \]
      2. sub-neg99.8%

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

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

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

    if -2.05e15 < x < 4.8000000000000003e66

    1. Initial program 94.9%

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

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

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

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

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

Alternative 6: 85.4% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -6.00000000000000046e107 or 9.99999999999999944e118 < z

    1. Initial program 83.1%

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

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

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

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

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

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

    if -6.00000000000000046e107 < z < 9.99999999999999944e118

    1. Initial program 93.9%

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

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

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

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

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

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

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

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

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

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

Alternative 7: 69.8% accurate, 1.0× speedup?

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

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


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

    1. Initial program 85.4%

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

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

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

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

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

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

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

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

    if -1.55000000000000004 < x < 4

    1. Initial program 95.1%

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

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

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

Alternative 8: 41.1% accurate, 1.1× speedup?

\[\begin{array}{l} y = |y|\\ \\ \left|\frac{4}{y}\right| \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z) :precision binary64 (fabs (/ 4.0 y)))
y = abs(y);
double code(double x, double y, double z) {
	return fabs((4.0 / y));
}
NOTE: y should be positive before calling this function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = abs((4.0d0 / y))
end function
y = Math.abs(y);
public static double code(double x, double y, double z) {
	return Math.abs((4.0 / y));
}
y = abs(y)
def code(x, y, z):
	return math.fabs((4.0 / y))
y = abs(y)
function code(x, y, z)
	return abs(Float64(4.0 / y))
end
y = abs(y)
function tmp = code(x, y, z)
	tmp = abs((4.0 / y));
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
y = |y|\\
\\
\left|\frac{4}{y}\right|
\end{array}
Derivation
  1. Initial program 90.7%

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

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

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

Reproduce

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