fabs fraction 1

Percentage Accurate: 92.2% → 99.9%
Time: 7.9s
Alternatives: 10
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 92.2% 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.9% accurate, 0.5× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 1.5 \cdot 10^{-27}:\\ \;\;\;\;\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 1.5e-27)
   (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 <= 1.5e-27) {
		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 <= 1.5e-27)
		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, 1.5e-27], 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 1.5 \cdot 10^{-27}:\\
\;\;\;\;\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 < 1.5000000000000001e-27

    1. Initial program 88.0%

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

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

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

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

    if 1.5000000000000001e-27 < y

    1. Initial program 98.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.5 \cdot 10^{-27}:\\ \;\;\;\;\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: 98.1% accurate, 0.9× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} t_0 := \frac{x + 4}{y} - z \cdot \frac{x}{y}\\ \mathbf{if}\;t_0 \leq 4 \cdot 10^{+306}:\\ \;\;\;\;\left|t_0\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
 (let* ((t_0 (- (/ (+ x 4.0) y) (* z (/ x y)))))
   (if (<= t_0 4e+306) (fabs t_0) (fabs (/ (- (+ x 4.0) (* x z)) y)))))
y = abs(y);
double code(double x, double y, double z) {
	double t_0 = ((x + 4.0) / y) - (z * (x / y));
	double tmp;
	if (t_0 <= 4e+306) {
		tmp = fabs(t_0);
	} 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) :: t_0
    real(8) :: tmp
    t_0 = ((x + 4.0d0) / y) - (z * (x / y))
    if (t_0 <= 4d+306) then
        tmp = abs(t_0)
    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 t_0 = ((x + 4.0) / y) - (z * (x / y));
	double tmp;
	if (t_0 <= 4e+306) {
		tmp = Math.abs(t_0);
	} else {
		tmp = Math.abs((((x + 4.0) - (x * z)) / y));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	t_0 = ((x + 4.0) / y) - (z * (x / y))
	tmp = 0
	if t_0 <= 4e+306:
		tmp = math.fabs(t_0)
	else:
		tmp = math.fabs((((x + 4.0) - (x * z)) / y))
	return tmp
y = abs(y)
function code(x, y, z)
	t_0 = Float64(Float64(Float64(x + 4.0) / y) - Float64(z * Float64(x / y)))
	tmp = 0.0
	if (t_0 <= 4e+306)
		tmp = abs(t_0);
	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)
	t_0 = ((x + 4.0) / y) - (z * (x / y));
	tmp = 0.0;
	if (t_0 <= 4e+306)
		tmp = abs(t_0);
	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_] := Block[{t$95$0 = N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 4e+306], N[Abs[t$95$0], $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}
t_0 := \frac{x + 4}{y} - z \cdot \frac{x}{y}\\
\mathbf{if}\;t_0 \leq 4 \cdot 10^{+306}:\\
\;\;\;\;\left|t_0\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 (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z)) < 4.00000000000000007e306

    1. Initial program 99.7%

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

    if 4.00000000000000007e306 < (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))

    1. Initial program 48.8%

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

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

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

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

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

Alternative 3: 64.7% accurate, 1.0× speedup?

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

\mathbf{elif}\;x \leq -2.1 \cdot 10^{+172}:\\
\;\;\;\;\left|\frac{x}{y}\right|\\

\mathbf{elif}\;x \leq -8 \cdot 10^{-78} \lor \neg \left(x \leq 0.00033\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.50000000000000017e245 or -2.1000000000000001e172 < x < -7.99999999999999999e-78 or 3.3e-4 < x

    1. Initial program 86.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.50000000000000017e245 < x < -2.1000000000000001e172

    1. Initial program 71.4%

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

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

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

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

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

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

    if -7.99999999999999999e-78 < x < 3.3e-4

    1. Initial program 99.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{+245}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq -2.1 \cdot 10^{+172}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;x \leq -8 \cdot 10^{-78} \lor \neg \left(x \leq 0.00033\right):\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array} \]

Alternative 4: 95.5% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1 or 0.070000000000000007 < z

    1. Initial program 92.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1 < z < 0.070000000000000007

    1. Initial program 90.0%

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

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

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

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

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

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

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

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

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

Alternative 5: 99.9% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;y \leq 2 \cdot 10^{-10}:\\ \;\;\;\;\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 2e-10)
   (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 <= 2e-10) {
		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 <= 2d-10) 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 <= 2e-10) {
		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 <= 2e-10:
		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 <= 2e-10)
		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 <= 2e-10)
		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, 2e-10], 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 2 \cdot 10^{-10}:\\
\;\;\;\;\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 < 2.00000000000000007e-10

    1. Initial program 87.7%

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

        \[\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 2.00000000000000007e-10 < y

    1. Initial program 99.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 2 \cdot 10^{-10}:\\ \;\;\;\;\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 6: 94.1% accurate, 1.0× speedup?

\[\begin{array}{l} y = |y|\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 2.2 \cdot 10^{+224}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{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 (<= x 2.2e+224) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs (* x (/ z y)))))
y = abs(y);
double code(double x, double y, double z) {
	double tmp;
	if (x <= 2.2e+224) {
		tmp = fabs((((x + 4.0) - (x * z)) / 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 (x <= 2.2d+224) then
        tmp = abs((((x + 4.0d0) - (x * z)) / 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 (x <= 2.2e+224) {
		tmp = Math.abs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = Math.abs((x * (z / y)));
	}
	return tmp;
}
y = abs(y)
def code(x, y, z):
	tmp = 0
	if x <= 2.2e+224:
		tmp = math.fabs((((x + 4.0) - (x * z)) / y))
	else:
		tmp = math.fabs((x * (z / y)))
	return tmp
y = abs(y)
function code(x, y, z)
	tmp = 0.0
	if (x <= 2.2e+224)
		tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / 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 (x <= 2.2e+224)
		tmp = abs((((x + 4.0) - (x * z)) / 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[x, 2.2e+224], 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]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.2 \cdot 10^{+224}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 2.2e224

    1. Initial program 91.3%

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

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

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

    if 2.2e224 < x

    1. Initial program 88.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{x}{\frac{y}{z}}}\right)} - 1\right| \]
      12. div-inv42.8%

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

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

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

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

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

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

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

Alternative 7: 68.3% accurate, 1.0× speedup?

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

    1. Initial program 84.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|e^{\mathsf{log1p}\left(\color{blue}{\frac{x}{\frac{y}{z}}}\right)} - 1\right| \]
      12. div-inv27.2%

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

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

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

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

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

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

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

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

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

    if -9e-78 < x < 7.19999999999999967e-6

    1. Initial program 99.7%

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

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

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

Alternative 8: 86.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.55e9 < z < 3.89999999999999994e56

    1. Initial program 90.3%

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

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

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

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

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

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

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

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

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

    if 3.89999999999999994e56 < z

    1. Initial program 82.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 68.3% accurate, 1.0× speedup?

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

    1. Initial program 82.1%

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

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

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

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

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

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

    if -1.52 < x < 4

    1. Initial program 99.7%

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

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

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

Alternative 10: 39.2% 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 91.2%

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

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

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

Reproduce

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