fabs fraction 1

Percentage Accurate: 91.6% → 99.4%
Time: 6.6s
Alternatives: 9
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 9 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.6% 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.4% accurate, 0.5× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 5 \cdot 10^{-85}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= y 5e-85)
   (fabs (/ (- (+ x 4.0) (* x z)) y))
   (fabs (fma x (/ z y) (/ (- -4.0 x) y)))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if (y <= 5e-85) {
		tmp = fabs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = fabs(fma(x, (z / y), ((-4.0 - x) / y)));
	}
	return tmp;
}
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if (y <= 5e-85)
		tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y));
	else
		tmp = abs(fma(x, Float64(z / y), Float64(Float64(-4.0 - x) / y)));
	end
	return tmp
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[y, 5e-85], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y), $MachinePrecision] + N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{-85}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\

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


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

    1. Initial program 90.5%

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

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

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

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

    if 5.0000000000000002e-85 < y

    1. Initial program 95.3%

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

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

Alternative 2: 99.5% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq -1.3 \cdot 10^{+107} \lor \neg \left(x \leq 3.4 \cdot 10^{+66}\right):\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\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 -1.3e+107) (not (<= x 3.4e+66)))
   (fabs (* (/ x y) (- 1.0 z)))
   (fabs (/ (- (+ x 4.0) (* x z)) y))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -1.3e+107) || !(x <= 3.4e+66)) {
		tmp = fabs(((x / y) * (1.0 - z)));
	} 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 <= (-1.3d+107)) .or. (.not. (x <= 3.4d+66))) then
        tmp = abs(((x / y) * (1.0d0 - z)))
    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 <= -1.3e+107) || !(x <= 3.4e+66)) {
		tmp = Math.abs(((x / y) * (1.0 - z)));
	} else {
		tmp = Math.abs((((x + 4.0) - (x * z)) / y));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if (x <= -1.3e+107) or not (x <= 3.4e+66):
		tmp = math.fabs(((x / y) * (1.0 - z)))
	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 <= -1.3e+107) || !(x <= 3.4e+66))
		tmp = abs(Float64(Float64(x / y) * Float64(1.0 - z)));
	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 <= -1.3e+107) || ~((x <= 3.4e+66)))
		tmp = abs(((x / y) * (1.0 - z)));
	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, -1.3e+107], N[Not[LessEqual[x, 3.4e+66]], $MachinePrecision]], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $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 -1.3 \cdot 10^{+107} \lor \neg \left(x \leq 3.4 \cdot 10^{+66}\right):\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\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 < -1.3000000000000001e107 or 3.4000000000000003e66 < x

    1. Initial program 86.3%

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

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

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

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

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

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

    if -1.3000000000000001e107 < x < 3.4000000000000003e66

    1. Initial program 95.0%

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

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

        \[\leadsto \left|\color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}}\right| \]
    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 -1.3 \cdot 10^{+107} \lor \neg \left(x \leq 3.4 \cdot 10^{+66}\right):\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \end{array} \]

Alternative 3: 99.8% accurate, 1.0× speedup?

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

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


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

    1. Initial program 90.8%

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

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

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

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

    if 1.60000000000000001e-49 < y

    1. Initial program 95.0%

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

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

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

Alternative 4: 87.3% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq -126000 \lor \neg \left(x \leq 4.7 \cdot 10^{-16}\right):\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\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 (<= x -126000.0) (not (<= x 4.7e-16)))
   (fabs (* (/ x y) (- 1.0 z)))
   (fabs (/ (- -4.0 x) y))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if ((x <= -126000.0) || !(x <= 4.7e-16)) {
		tmp = fabs(((x / y) * (1.0 - z)));
	} 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 ((x <= (-126000.0d0)) .or. (.not. (x <= 4.7d-16))) then
        tmp = abs(((x / y) * (1.0d0 - z)))
    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 ((x <= -126000.0) || !(x <= 4.7e-16)) {
		tmp = Math.abs(((x / y) * (1.0 - z)));
	} else {
		tmp = Math.abs(((-4.0 - x) / y));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if (x <= -126000.0) or not (x <= 4.7e-16):
		tmp = math.fabs(((x / y) * (1.0 - z)))
	else:
		tmp = math.fabs(((-4.0 - x) / y))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if ((x <= -126000.0) || !(x <= 4.7e-16))
		tmp = abs(Float64(Float64(x / y) * Float64(1.0 - z)));
	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 ((x <= -126000.0) || ~((x <= 4.7e-16)))
		tmp = abs(((x / y) * (1.0 - z)));
	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[x, -126000.0], N[Not[LessEqual[x, 4.7e-16]], $MachinePrecision]], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -126000 \lor \neg \left(x \leq 4.7 \cdot 10^{-16}\right):\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -126000 or 4.70000000000000044e-16 < x

    1. Initial program 90.1%

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

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

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

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

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

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

    if -126000 < x < 4.70000000000000044e-16

    1. Initial program 93.7%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 68.1% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -4.65 \cdot 10^{+148}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -4 \cdot 10^{-23}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \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))))
   (if (<= x -4.65e+148)
     t_0
     (if (<= x -4e-23)
       (fabs (* x (/ z y)))
       (if (<= x 4.0) (fabs (/ 4.0 y)) t_0)))))
y = abs(y);
double code(double x, double y, double z) {
	double t_0 = fabs((x / y));
	double tmp;
	if (x <= -4.65e+148) {
		tmp = t_0;
	} else if (x <= -4e-23) {
		tmp = fabs((x * (z / y)));
	} else if (x <= 4.0) {
		tmp = fabs((4.0 / y));
	} 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) :: tmp
    t_0 = abs((x / y))
    if (x <= (-4.65d+148)) then
        tmp = t_0
    else if (x <= (-4d-23)) then
        tmp = abs((x * (z / y)))
    else if (x <= 4.0d0) then
        tmp = abs((4.0d0 / y))
    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 tmp;
	if (x <= -4.65e+148) {
		tmp = t_0;
	} else if (x <= -4e-23) {
		tmp = Math.abs((x * (z / y)));
	} else if (x <= 4.0) {
		tmp = Math.abs((4.0 / y));
	} else {
		tmp = t_0;
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	t_0 = math.fabs((x / y))
	tmp = 0
	if x <= -4.65e+148:
		tmp = t_0
	elif x <= -4e-23:
		tmp = math.fabs((x * (z / y)))
	elif x <= 4.0:
		tmp = math.fabs((4.0 / y))
	else:
		tmp = t_0
	return tmp
y = abs(y)
function code(x, y, z)
	t_0 = abs(Float64(x / y))
	tmp = 0.0
	if (x <= -4.65e+148)
		tmp = t_0;
	elseif (x <= -4e-23)
		tmp = abs(Float64(x * Float64(z / y)));
	elseif (x <= 4.0)
		tmp = abs(Float64(4.0 / y));
	else
		tmp = t_0;
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	t_0 = abs((x / y));
	tmp = 0.0;
	if (x <= -4.65e+148)
		tmp = t_0;
	elseif (x <= -4e-23)
		tmp = abs((x * (z / y)));
	elseif (x <= 4.0)
		tmp = abs((4.0 / y));
	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]}, If[LessEqual[x, -4.65e+148], t$95$0, If[LessEqual[x, -4e-23], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -4.65 \cdot 10^{+148}:\\
\;\;\;\;t_0\\

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

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

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


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

    1. Initial program 87.8%

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

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

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

    if -4.64999999999999992e148 < x < -3.99999999999999984e-23

    1. Initial program 97.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.99999999999999984e-23 < x < 4

    1. Initial program 94.1%

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

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

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

Alternative 6: 68.7% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -4.9 \cdot 10^{+147}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -2.45 \cdot 10^{-9}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \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))))
   (if (<= x -4.9e+147)
     t_0
     (if (<= x -2.45e-9)
       (fabs (/ z (/ y x)))
       (if (<= x 4.0) (fabs (/ 4.0 y)) t_0)))))
y = abs(y);
double code(double x, double y, double z) {
	double t_0 = fabs((x / y));
	double tmp;
	if (x <= -4.9e+147) {
		tmp = t_0;
	} else if (x <= -2.45e-9) {
		tmp = fabs((z / (y / x)));
	} else if (x <= 4.0) {
		tmp = fabs((4.0 / y));
	} 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) :: tmp
    t_0 = abs((x / y))
    if (x <= (-4.9d+147)) then
        tmp = t_0
    else if (x <= (-2.45d-9)) then
        tmp = abs((z / (y / x)))
    else if (x <= 4.0d0) then
        tmp = abs((4.0d0 / y))
    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 tmp;
	if (x <= -4.9e+147) {
		tmp = t_0;
	} else if (x <= -2.45e-9) {
		tmp = Math.abs((z / (y / x)));
	} else if (x <= 4.0) {
		tmp = Math.abs((4.0 / y));
	} else {
		tmp = t_0;
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	t_0 = math.fabs((x / y))
	tmp = 0
	if x <= -4.9e+147:
		tmp = t_0
	elif x <= -2.45e-9:
		tmp = math.fabs((z / (y / x)))
	elif x <= 4.0:
		tmp = math.fabs((4.0 / y))
	else:
		tmp = t_0
	return tmp
y = abs(y)
function code(x, y, z)
	t_0 = abs(Float64(x / y))
	tmp = 0.0
	if (x <= -4.9e+147)
		tmp = t_0;
	elseif (x <= -2.45e-9)
		tmp = abs(Float64(z / Float64(y / x)));
	elseif (x <= 4.0)
		tmp = abs(Float64(4.0 / y));
	else
		tmp = t_0;
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	t_0 = abs((x / y));
	tmp = 0.0;
	if (x <= -4.9e+147)
		tmp = t_0;
	elseif (x <= -2.45e-9)
		tmp = abs((z / (y / x)));
	elseif (x <= 4.0)
		tmp = abs((4.0 / y));
	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]}, If[LessEqual[x, -4.9e+147], t$95$0, If[LessEqual[x, -2.45e-9], N[Abs[N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_0 := \left|\frac{x}{y}\right|\\
\mathbf{if}\;x \leq -4.9 \cdot 10^{+147}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -2.45 \cdot 10^{-9}:\\
\;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\

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

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


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

    1. Initial program 87.8%

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

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

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

    if -4.8999999999999998e147 < x < -2.45000000000000002e-9

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|z \cdot \color{blue}{\frac{1}{\frac{y}{x}}}\right| \]
      10. un-div-inv66.9%

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

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

    if -2.45000000000000002e-9 < x < 4

    1. Initial program 93.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.9 \cdot 10^{+147}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -2.45 \cdot 10^{-9}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \end{array} \]

Alternative 7: 84.6% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;z \leq -6.4 \cdot 10^{+15}:\\ \;\;\;\;\left|\frac{x \cdot z}{y}\right|\\ \mathbf{elif}\;z \leq 1.52 \cdot 10^{+63}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \end{array} \end{array} \]
NOTE: y should be positive before calling this function
(FPCore (x y z)
 :precision binary64
 (if (<= z -6.4e+15)
   (fabs (/ (* x z) y))
   (if (<= z 1.52e+63) (fabs (/ (- -4.0 x) y)) (fabs (* x (/ z y))))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if (z <= -6.4e+15) {
		tmp = fabs(((x * z) / y));
	} else if (z <= 1.52e+63) {
		tmp = fabs(((-4.0 - x) / y));
	} else {
		tmp = fabs((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 (z <= (-6.4d+15)) then
        tmp = abs(((x * z) / y))
    else if (z <= 1.52d+63) then
        tmp = abs((((-4.0d0) - x) / y))
    else
        tmp = abs((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 (z <= -6.4e+15) {
		tmp = Math.abs(((x * z) / y));
	} else if (z <= 1.52e+63) {
		tmp = Math.abs(((-4.0 - x) / y));
	} else {
		tmp = Math.abs((x * (z / y)));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if z <= -6.4e+15:
		tmp = math.fabs(((x * z) / y))
	elif z <= 1.52e+63:
		tmp = math.fabs(((-4.0 - x) / y))
	else:
		tmp = math.fabs((x * (z / y)))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if (z <= -6.4e+15)
		tmp = abs(Float64(Float64(x * z) / y));
	elseif (z <= 1.52e+63)
		tmp = abs(Float64(Float64(-4.0 - x) / y));
	else
		tmp = abs(Float64(x * Float64(z / y)));
	end
	return tmp
end
y = abs(y)
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -6.4e+15)
		tmp = abs(((x * z) / y));
	elseif (z <= 1.52e+63)
		tmp = abs(((-4.0 - x) / y));
	else
		tmp = abs((x * (z / y)));
	end
	tmp_2 = tmp;
end
NOTE: y should be positive before calling this function
code[x_, y_, z_] := If[LessEqual[z, -6.4e+15], N[Abs[N[(N[(x * z), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 1.52e+63], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.4 \cdot 10^{+15}:\\
\;\;\;\;\left|\frac{x \cdot z}{y}\right|\\

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

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


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

    1. Initial program 91.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.4e15 < z < 1.51999999999999993e63

    1. Initial program 95.9%

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

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

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

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

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

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

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

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

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

    if 1.51999999999999993e63 < z

    1. Initial program 80.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{x \cdot \left(z \cdot \frac{1}{y}\right)}\right)} - 1\right| \]
      15. div-inv26.4%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6.4 \cdot 10^{+15}:\\ \;\;\;\;\left|\frac{x \cdot z}{y}\right|\\ \mathbf{elif}\;z \leq 1.52 \cdot 10^{+63}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \end{array} \]

Alternative 8: 68.1% accurate, 1.0× speedup?

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

    1. Initial program 90.1%

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

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

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

    if -10.199999999999999 < x < 4

    1. Initial program 93.7%

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

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

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

Alternative 9: 39.8% 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 92.0%

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

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

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

Reproduce

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