fabs fraction 1

Percentage Accurate: 92.2% → 99.9%
Time: 11.7s
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, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 100000:\\
\;\;\;\;\left|\frac{4 - x \cdot \left(z + -1\right)}{y\_m}\right|\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1e5

    1. Initial program 90.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x + 4}{y} - \frac{x}{y} \cdot z\right)\right) \]
      2. associate-*l/N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x + 4}{y} - \frac{x \cdot z}{y}\right)\right) \]
      3. div-subN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{\left(x + 4\right) - x \cdot z}{y}\right)\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(\left(x + 4\right) - x \cdot z\right), y\right)\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(\left(x + 4\right) + \left(\mathsf{neg}\left(x \cdot z\right)\right)\right), y\right)\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(\left(4 + x\right) + \left(\mathsf{neg}\left(x \cdot z\right)\right)\right), y\right)\right) \]
      7. remove-double-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(\left(4 + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) + \left(\mathsf{neg}\left(x \cdot z\right)\right)\right), y\right)\right) \]
      8. unsub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(\left(4 - \left(\mathsf{neg}\left(x\right)\right)\right) + \left(\mathsf{neg}\left(x \cdot z\right)\right)\right), y\right)\right) \]
      9. associate-+l-N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(4 - \left(\left(\mathsf{neg}\left(x\right)\right) - \left(\mathsf{neg}\left(x \cdot z\right)\right)\right)\right), y\right)\right) \]
      10. --lowering--.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \left(\left(\mathsf{neg}\left(x\right)\right) - \left(\mathsf{neg}\left(x \cdot z\right)\right)\right)\right), y\right)\right) \]
      11. neg-mul-1N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \left(-1 \cdot x - \left(\mathsf{neg}\left(x \cdot z\right)\right)\right)\right), y\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \left(x \cdot -1 - \left(\mathsf{neg}\left(x \cdot z\right)\right)\right)\right), y\right)\right) \]
      13. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \left(x \cdot -1 - x \cdot \left(\mathsf{neg}\left(z\right)\right)\right)\right), y\right)\right) \]
      14. distribute-lft-out--N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \left(x \cdot \left(-1 - \left(\mathsf{neg}\left(z\right)\right)\right)\right)\right), y\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \mathsf{*.f64}\left(x, \left(-1 - \left(\mathsf{neg}\left(z\right)\right)\right)\right)\right), y\right)\right) \]
      16. sub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \mathsf{*.f64}\left(x, \left(-1 + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(z\right)\right)\right)\right)\right)\right)\right), y\right)\right) \]
      17. remove-double-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \mathsf{*.f64}\left(x, \left(-1 + z\right)\right)\right), y\right)\right) \]
      18. +-commutativeN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \mathsf{*.f64}\left(x, \left(z + -1\right)\right)\right), y\right)\right) \]
      19. +-lowering-+.f6497.1%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(z, -1\right)\right)\right), y\right)\right) \]
    3. Simplified97.1%

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

    if 1e5 < y

    1. Initial program 97.2%

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

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(x, 4\right), y\right), \left(\frac{x \cdot z}{y}\right)\right)\right) \]
      2. associate-/l*N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(x, 4\right), y\right), \left(x \cdot \frac{z}{y}\right)\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(x, 4\right), y\right), \mathsf{*.f64}\left(x, \left(\frac{z}{y}\right)\right)\right)\right) \]
      4. /-lowering-/.f6499.8%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(x, 4\right), y\right), \mathsf{*.f64}\left(x, \mathsf{/.f64}\left(z, y\right)\right)\right)\right) \]
    4. Applied egg-rr99.8%

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

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

Alternative 2: 67.4% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \left|\frac{x}{y\_m}\right|\\
\mathbf{if}\;x \leq -1.55 \cdot 10^{+140}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -7.8 \cdot 10^{-112}:\\
\;\;\;\;\left|x \cdot \frac{z}{y\_m}\right|\\

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

\mathbf{elif}\;x \leq 6 \cdot 10^{+99}:\\
\;\;\;\;\left|\frac{x}{\frac{y\_m}{z}}\right|\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -1.55e140 or 6.00000000000000029e99 < x

    1. Initial program 80.4%

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

      \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(x \cdot \left(\frac{1}{y} - \frac{z}{y}\right)\right)}\right) \]
    4. Step-by-step derivation
      1. div-subN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(x \cdot \frac{1 - z}{y}\right)\right) \]
      2. associate-/l*N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x \cdot \left(1 - z\right)}{y}\right)\right) \]
      3. sub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x \cdot \left(1 + \left(\mathsf{neg}\left(z\right)\right)\right)}{y}\right)\right) \]
      4. mul-1-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x \cdot \left(1 + -1 \cdot z\right)}{y}\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \left(1 + -1 \cdot z\right)\right), y\right)\right) \]
      6. mul-1-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \left(1 + \left(\mathsf{neg}\left(z\right)\right)\right)\right), y\right)\right) \]
      7. sub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \left(1 - z\right)\right), y\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(1 - z\right)\right), y\right)\right) \]
      9. --lowering--.f6489.8%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, z\right)\right), y\right)\right) \]
    5. Simplified89.8%

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

      \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(\frac{x}{y}\right)}\right) \]
    7. Step-by-step derivation
      1. /-lowering-/.f6473.4%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(x, y\right)\right) \]
    8. Simplified73.4%

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

    if -1.55e140 < x < -7.8000000000000002e-112

    1. Initial program 99.7%

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

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(\color{blue}{\left(\frac{x}{y}\right)}, \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, y\right), z\right)\right)\right) \]
    4. Step-by-step derivation
      1. /-lowering-/.f6487.8%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(x, y\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, y\right), z\right)\right)\right) \]
    5. Simplified87.8%

      \[\leadsto \left|\color{blue}{\frac{x}{y}} - \frac{x}{y} \cdot z\right| \]
    6. Step-by-step derivation
      1. fabs-subN/A

        \[\leadsto \left|\frac{x}{y} \cdot z - \frac{x}{y}\right| \]
      2. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x}{y} \cdot z - \frac{x}{y}\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(z \cdot \frac{x}{y} - \frac{x}{y}\right)\right) \]
      4. clear-numN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(z \cdot \frac{1}{\frac{y}{x}} - \frac{x}{y}\right)\right) \]
      5. div-invN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{z}{\frac{y}{x}} - \frac{x}{y}\right)\right) \]
      6. clear-numN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{z}{\frac{y}{x}} - \frac{1}{\frac{y}{x}}\right)\right) \]
      7. sub-divN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{z - 1}{\frac{y}{x}}\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(z - 1\right), \left(\frac{y}{x}\right)\right)\right) \]
      9. --lowering--.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(z, 1\right), \left(\frac{y}{x}\right)\right)\right) \]
      10. /-lowering-/.f6487.7%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(z, 1\right), \mathsf{/.f64}\left(y, x\right)\right)\right) \]
    7. Applied egg-rr87.7%

      \[\leadsto \color{blue}{\left|\frac{z - 1}{\frac{y}{x}}\right|} \]
    8. Taylor expanded in z around inf

      \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(\frac{x \cdot z}{y}\right)}\right) \]
    9. Step-by-step derivation
      1. associate-/l*N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(x \cdot \frac{z}{y}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(x, \left(\frac{z}{y}\right)\right)\right) \]
      3. /-lowering-/.f6468.5%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(x, \mathsf{/.f64}\left(z, y\right)\right)\right) \]
    10. Simplified68.5%

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

    if -7.8000000000000002e-112 < x < 1.9999999999999999e-47

    1. Initial program 97.3%

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

      \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(\frac{4}{y}\right)}\right) \]
    4. Step-by-step derivation
      1. /-lowering-/.f6484.5%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(4, y\right)\right) \]
    5. Simplified84.5%

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

    if 1.9999999999999999e-47 < x < 6.00000000000000029e99

    1. Initial program 96.5%

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

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(\color{blue}{\left(\frac{x}{y}\right)}, \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, y\right), z\right)\right)\right) \]
    4. Step-by-step derivation
      1. /-lowering-/.f6493.4%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(x, y\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, y\right), z\right)\right)\right) \]
    5. Simplified93.4%

      \[\leadsto \left|\color{blue}{\frac{x}{y}} - \frac{x}{y} \cdot z\right| \]
    6. Step-by-step derivation
      1. fabs-subN/A

        \[\leadsto \left|\frac{x}{y} \cdot z - \frac{x}{y}\right| \]
      2. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x}{y} \cdot z - \frac{x}{y}\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(z \cdot \frac{x}{y} - \frac{x}{y}\right)\right) \]
      4. clear-numN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(z \cdot \frac{1}{\frac{y}{x}} - \frac{x}{y}\right)\right) \]
      5. div-invN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{z}{\frac{y}{x}} - \frac{x}{y}\right)\right) \]
      6. clear-numN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{z}{\frac{y}{x}} - \frac{1}{\frac{y}{x}}\right)\right) \]
      7. sub-divN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{z - 1}{\frac{y}{x}}\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(z - 1\right), \left(\frac{y}{x}\right)\right)\right) \]
      9. --lowering--.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(z, 1\right), \left(\frac{y}{x}\right)\right)\right) \]
      10. /-lowering-/.f6496.7%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(z, 1\right), \mathsf{/.f64}\left(y, x\right)\right)\right) \]
    7. Applied egg-rr96.7%

      \[\leadsto \color{blue}{\left|\frac{z - 1}{\frac{y}{x}}\right|} \]
    8. Taylor expanded in z around inf

      \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(\frac{x \cdot z}{y}\right)}\right) \]
    9. Step-by-step derivation
      1. associate-/l*N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(x \cdot \frac{z}{y}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(x, \left(\frac{z}{y}\right)\right)\right) \]
      3. /-lowering-/.f6478.7%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(x, \mathsf{/.f64}\left(z, y\right)\right)\right) \]
    10. Simplified78.7%

      \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}}\right| \]
    11. Step-by-step derivation
      1. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(x \cdot \frac{z}{y}\right)\right) \]
      2. clear-numN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(x \cdot \frac{1}{\frac{y}{z}}\right)\right) \]
      3. un-div-invN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x}{\frac{y}{z}}\right)\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(x, \left(\frac{y}{z}\right)\right)\right) \]
      5. /-lowering-/.f6478.7%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(x, \mathsf{/.f64}\left(y, z\right)\right)\right) \]
    12. Applied egg-rr78.7%

      \[\leadsto \color{blue}{\left|\frac{x}{\frac{y}{z}}\right|} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 3: 67.4% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \left|\frac{x}{y\_m}\right|\\
t_1 := \left|x \cdot \frac{z}{y\_m}\right|\\
\mathbf{if}\;x \leq -6.6 \cdot 10^{+140}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -7.8 \cdot 10^{-112}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;x \leq 2.25 \cdot 10^{+98}:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -6.6000000000000003e140 or 2.2500000000000001e98 < x

    1. Initial program 80.4%

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

      \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(x \cdot \left(\frac{1}{y} - \frac{z}{y}\right)\right)}\right) \]
    4. Step-by-step derivation
      1. div-subN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(x \cdot \frac{1 - z}{y}\right)\right) \]
      2. associate-/l*N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x \cdot \left(1 - z\right)}{y}\right)\right) \]
      3. sub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x \cdot \left(1 + \left(\mathsf{neg}\left(z\right)\right)\right)}{y}\right)\right) \]
      4. mul-1-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x \cdot \left(1 + -1 \cdot z\right)}{y}\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \left(1 + -1 \cdot z\right)\right), y\right)\right) \]
      6. mul-1-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \left(1 + \left(\mathsf{neg}\left(z\right)\right)\right)\right), y\right)\right) \]
      7. sub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \left(1 - z\right)\right), y\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(1 - z\right)\right), y\right)\right) \]
      9. --lowering--.f6489.8%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, z\right)\right), y\right)\right) \]
    5. Simplified89.8%

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

      \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(\frac{x}{y}\right)}\right) \]
    7. Step-by-step derivation
      1. /-lowering-/.f6473.4%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(x, y\right)\right) \]
    8. Simplified73.4%

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

    if -6.6000000000000003e140 < x < -7.8000000000000002e-112 or 2.49999999999999996e-46 < x < 2.2500000000000001e98

    1. Initial program 98.5%

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

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(\color{blue}{\left(\frac{x}{y}\right)}, \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, y\right), z\right)\right)\right) \]
    4. Step-by-step derivation
      1. /-lowering-/.f6489.9%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(x, y\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, y\right), z\right)\right)\right) \]
    5. Simplified89.9%

      \[\leadsto \left|\color{blue}{\frac{x}{y}} - \frac{x}{y} \cdot z\right| \]
    6. Step-by-step derivation
      1. fabs-subN/A

        \[\leadsto \left|\frac{x}{y} \cdot z - \frac{x}{y}\right| \]
      2. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x}{y} \cdot z - \frac{x}{y}\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(z \cdot \frac{x}{y} - \frac{x}{y}\right)\right) \]
      4. clear-numN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(z \cdot \frac{1}{\frac{y}{x}} - \frac{x}{y}\right)\right) \]
      5. div-invN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{z}{\frac{y}{x}} - \frac{x}{y}\right)\right) \]
      6. clear-numN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{z}{\frac{y}{x}} - \frac{1}{\frac{y}{x}}\right)\right) \]
      7. sub-divN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{z - 1}{\frac{y}{x}}\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(z - 1\right), \left(\frac{y}{x}\right)\right)\right) \]
      9. --lowering--.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(z, 1\right), \left(\frac{y}{x}\right)\right)\right) \]
      10. /-lowering-/.f6491.2%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(z, 1\right), \mathsf{/.f64}\left(y, x\right)\right)\right) \]
    7. Applied egg-rr91.2%

      \[\leadsto \color{blue}{\left|\frac{z - 1}{\frac{y}{x}}\right|} \]
    8. Taylor expanded in z around inf

      \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(\frac{x \cdot z}{y}\right)}\right) \]
    9. Step-by-step derivation
      1. associate-/l*N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(x \cdot \frac{z}{y}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(x, \left(\frac{z}{y}\right)\right)\right) \]
      3. /-lowering-/.f6472.4%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(x, \mathsf{/.f64}\left(z, y\right)\right)\right) \]
    10. Simplified72.4%

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

    if -7.8000000000000002e-112 < x < 2.49999999999999996e-46

    1. Initial program 97.3%

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

      \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(\frac{4}{y}\right)}\right) \]
    4. Step-by-step derivation
      1. /-lowering-/.f6484.5%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(4, y\right)\right) \]
    5. Simplified84.5%

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

Alternative 4: 98.8% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \left|\left(1 - z\right) \cdot \frac{x}{y\_m}\right|\\
\mathbf{if}\;x \leq -27.5:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 46000000:\\
\;\;\;\;\left|\frac{4 - x \cdot z}{y\_m}\right|\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -27.5 or 4.6e7 < x

    1. Initial program 86.3%

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

      \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(x \cdot \left(\frac{1}{y} - \frac{z}{y}\right)\right)}\right) \]
    4. Step-by-step derivation
      1. div-subN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(x \cdot \frac{1 - z}{y}\right)\right) \]
      2. associate-/l*N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x \cdot \left(1 - z\right)}{y}\right)\right) \]
      3. sub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x \cdot \left(1 + \left(\mathsf{neg}\left(z\right)\right)\right)}{y}\right)\right) \]
      4. mul-1-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x \cdot \left(1 + -1 \cdot z\right)}{y}\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \left(1 + -1 \cdot z\right)\right), y\right)\right) \]
      6. mul-1-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \left(1 + \left(\mathsf{neg}\left(z\right)\right)\right)\right), y\right)\right) \]
      7. sub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \left(1 - z\right)\right), y\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(1 - z\right)\right), y\right)\right) \]
      9. --lowering--.f6490.1%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, z\right)\right), y\right)\right) \]
    5. Simplified90.1%

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

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{\left(1 - z\right) \cdot x}{y}\right)\right) \]
      2. associate-/l*N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(1 - z\right) \cdot \frac{x}{y}\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(\left(1 - z\right), \left(\frac{x}{y}\right)\right)\right) \]
      4. --lowering--.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, z\right), \left(\frac{x}{y}\right)\right)\right) \]
      5. /-lowering-/.f6499.7%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, z\right), \mathsf{/.f64}\left(x, y\right)\right)\right) \]
    7. Applied egg-rr99.7%

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

    if -27.5 < x < 4.6e7

    1. Initial program 98.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x + 4}{y} - \frac{x}{y} \cdot z\right)\right) \]
      2. associate-*l/N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x + 4}{y} - \frac{x \cdot z}{y}\right)\right) \]
      3. div-subN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{\left(x + 4\right) - x \cdot z}{y}\right)\right) \]
      4. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(\left(x + 4\right) - x \cdot z\right), y\right)\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(\left(x + 4\right) + \left(\mathsf{neg}\left(x \cdot z\right)\right)\right), y\right)\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(\left(4 + x\right) + \left(\mathsf{neg}\left(x \cdot z\right)\right)\right), y\right)\right) \]
      7. remove-double-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(\left(4 + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) + \left(\mathsf{neg}\left(x \cdot z\right)\right)\right), y\right)\right) \]
      8. unsub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(\left(4 - \left(\mathsf{neg}\left(x\right)\right)\right) + \left(\mathsf{neg}\left(x \cdot z\right)\right)\right), y\right)\right) \]
      9. associate-+l-N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(4 - \left(\left(\mathsf{neg}\left(x\right)\right) - \left(\mathsf{neg}\left(x \cdot z\right)\right)\right)\right), y\right)\right) \]
      10. --lowering--.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \left(\left(\mathsf{neg}\left(x\right)\right) - \left(\mathsf{neg}\left(x \cdot z\right)\right)\right)\right), y\right)\right) \]
      11. neg-mul-1N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \left(-1 \cdot x - \left(\mathsf{neg}\left(x \cdot z\right)\right)\right)\right), y\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \left(x \cdot -1 - \left(\mathsf{neg}\left(x \cdot z\right)\right)\right)\right), y\right)\right) \]
      13. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \left(x \cdot -1 - x \cdot \left(\mathsf{neg}\left(z\right)\right)\right)\right), y\right)\right) \]
      14. distribute-lft-out--N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \left(x \cdot \left(-1 - \left(\mathsf{neg}\left(z\right)\right)\right)\right)\right), y\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \mathsf{*.f64}\left(x, \left(-1 - \left(\mathsf{neg}\left(z\right)\right)\right)\right)\right), y\right)\right) \]
      16. sub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \mathsf{*.f64}\left(x, \left(-1 + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(z\right)\right)\right)\right)\right)\right)\right), y\right)\right) \]
      17. remove-double-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \mathsf{*.f64}\left(x, \left(-1 + z\right)\right)\right), y\right)\right) \]
      18. +-commutativeN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \mathsf{*.f64}\left(x, \left(z + -1\right)\right)\right), y\right)\right) \]
      19. +-lowering-+.f6499.9%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(z, -1\right)\right)\right), y\right)\right) \]
    3. Simplified99.9%

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

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \color{blue}{\left(x \cdot z\right)}\right), y\right)\right) \]
    6. Step-by-step derivation
      1. *-lowering-*.f6499.9%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \mathsf{*.f64}\left(x, z\right)\right), y\right)\right) \]
    7. Simplified99.9%

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

Alternative 5: 85.4% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \left|\left(1 - z\right) \cdot \frac{x}{y\_m}\right|\\
\mathbf{if}\;x \leq -7.8 \cdot 10^{-112}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.45 \cdot 10^{-46}:\\
\;\;\;\;\left|\frac{4 + x}{y\_m}\right|\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -7.8000000000000002e-112 or 1.45000000000000002e-46 < x

    1. Initial program 89.2%

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

      \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(x \cdot \left(\frac{1}{y} - \frac{z}{y}\right)\right)}\right) \]
    4. Step-by-step derivation
      1. div-subN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(x \cdot \frac{1 - z}{y}\right)\right) \]
      2. associate-/l*N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x \cdot \left(1 - z\right)}{y}\right)\right) \]
      3. sub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x \cdot \left(1 + \left(\mathsf{neg}\left(z\right)\right)\right)}{y}\right)\right) \]
      4. mul-1-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x \cdot \left(1 + -1 \cdot z\right)}{y}\right)\right) \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \left(1 + -1 \cdot z\right)\right), y\right)\right) \]
      6. mul-1-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \left(1 + \left(\mathsf{neg}\left(z\right)\right)\right)\right), y\right)\right) \]
      7. sub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \left(1 - z\right)\right), y\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(1 - z\right)\right), y\right)\right) \]
      9. --lowering--.f6488.2%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, z\right)\right), y\right)\right) \]
    5. Simplified88.2%

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

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{\left(1 - z\right) \cdot x}{y}\right)\right) \]
      2. associate-/l*N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\left(1 - z\right) \cdot \frac{x}{y}\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(\left(1 - z\right), \left(\frac{x}{y}\right)\right)\right) \]
      4. --lowering--.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, z\right), \left(\frac{x}{y}\right)\right)\right) \]
      5. /-lowering-/.f6495.7%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, z\right), \mathsf{/.f64}\left(x, y\right)\right)\right) \]
    7. Applied egg-rr95.7%

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

    if -7.8000000000000002e-112 < x < 1.45000000000000002e-46

    1. Initial program 97.3%

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

      \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(4 \cdot \frac{1}{y} + \frac{x}{y}\right)}\right) \]
    4. Step-by-step derivation
      1. remove-double-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(4 \cdot \frac{1}{y} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{x}{y}\right)\right)\right)\right)\right)\right) \]
      2. mul-1-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(4 \cdot \frac{1}{y} + \left(\mathsf{neg}\left(-1 \cdot \frac{x}{y}\right)\right)\right)\right) \]
      3. sub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(4 \cdot \frac{1}{y} - -1 \cdot \frac{x}{y}\right)\right) \]
      4. associate-*r/N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{4 \cdot 1}{y} - -1 \cdot \frac{x}{y}\right)\right) \]
      5. metadata-evalN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{4}{y} - -1 \cdot \frac{x}{y}\right)\right) \]
      6. associate-*r/N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{4}{y} - \frac{-1 \cdot x}{y}\right)\right) \]
      7. div-subN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{4 - -1 \cdot x}{y}\right)\right) \]
      8. sub-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{4 + \left(\mathsf{neg}\left(-1 \cdot x\right)\right)}{y}\right)\right) \]
      9. mul-1-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{4 + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)}{y}\right)\right) \]
      10. remove-double-negN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{4 + x}{y}\right)\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(4 + x\right), y\right)\right) \]
      12. +-lowering-+.f6484.5%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(4, x\right), y\right)\right) \]
    5. Simplified84.5%

      \[\leadsto \left|\color{blue}{\frac{4 + x}{y}}\right| \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 85.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \left|\frac{z}{\frac{y\_m}{x}}\right|\\
\mathbf{if}\;z \leq -8.2 \cdot 10^{+76}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 4.7 \cdot 10^{+27}:\\
\;\;\;\;\left|\frac{4 + x}{y\_m}\right|\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8.1999999999999997e76 or 4.69999999999999976e27 < z

    1. Initial program 92.0%

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

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(\color{blue}{\left(\frac{x}{y}\right)}, \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, y\right), z\right)\right)\right) \]
    4. Step-by-step derivation
      1. /-lowering-/.f6475.0%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(x, y\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, y\right), z\right)\right)\right) \]
    5. Simplified75.0%

      \[\leadsto \left|\color{blue}{\frac{x}{y}} - \frac{x}{y} \cdot z\right| \]
    6. Step-by-step derivation
      1. fabs-subN/A

        \[\leadsto \left|\frac{x}{y} \cdot z - \frac{x}{y}\right| \]
      2. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x}{y} \cdot z - \frac{x}{y}\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(z \cdot \frac{x}{y} - \frac{x}{y}\right)\right) \]
      4. clear-numN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(z \cdot \frac{1}{\frac{y}{x}} - \frac{x}{y}\right)\right) \]
      5. div-invN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{z}{\frac{y}{x}} - \frac{x}{y}\right)\right) \]
      6. clear-numN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{z}{\frac{y}{x}} - \frac{1}{\frac{y}{x}}\right)\right) \]
      7. sub-divN/A

        \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{z - 1}{\frac{y}{x}}\right)\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(z - 1\right), \left(\frac{y}{x}\right)\right)\right) \]
      9. --lowering--.f64N/A

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(z, 1\right), \left(\frac{y}{x}\right)\right)\right) \]
      10. /-lowering-/.f6480.5%

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(z, 1\right), \mathsf{/.f64}\left(y, x\right)\right)\right) \]
    7. Applied egg-rr80.5%

      \[\leadsto \color{blue}{\left|\frac{z - 1}{\frac{y}{x}}\right|} \]
    8. Taylor expanded in z around inf

      \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\color{blue}{z}, \mathsf{/.f64}\left(y, x\right)\right)\right) \]
    9. Step-by-step derivation
      1. Simplified80.5%

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

      if -8.1999999999999997e76 < z < 4.69999999999999976e27

      1. Initial program 92.5%

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

        \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(4 \cdot \frac{1}{y} + \frac{x}{y}\right)}\right) \]
      4. Step-by-step derivation
        1. remove-double-negN/A

          \[\leadsto \mathsf{fabs.f64}\left(\left(4 \cdot \frac{1}{y} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{x}{y}\right)\right)\right)\right)\right)\right) \]
        2. mul-1-negN/A

          \[\leadsto \mathsf{fabs.f64}\left(\left(4 \cdot \frac{1}{y} + \left(\mathsf{neg}\left(-1 \cdot \frac{x}{y}\right)\right)\right)\right) \]
        3. sub-negN/A

          \[\leadsto \mathsf{fabs.f64}\left(\left(4 \cdot \frac{1}{y} - -1 \cdot \frac{x}{y}\right)\right) \]
        4. associate-*r/N/A

          \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{4 \cdot 1}{y} - -1 \cdot \frac{x}{y}\right)\right) \]
        5. metadata-evalN/A

          \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{4}{y} - -1 \cdot \frac{x}{y}\right)\right) \]
        6. associate-*r/N/A

          \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{4}{y} - \frac{-1 \cdot x}{y}\right)\right) \]
        7. div-subN/A

          \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{4 - -1 \cdot x}{y}\right)\right) \]
        8. sub-negN/A

          \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{4 + \left(\mathsf{neg}\left(-1 \cdot x\right)\right)}{y}\right)\right) \]
        9. mul-1-negN/A

          \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{4 + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)}{y}\right)\right) \]
        10. remove-double-negN/A

          \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{4 + x}{y}\right)\right) \]
        11. /-lowering-/.f64N/A

          \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(4 + x\right), y\right)\right) \]
        12. +-lowering-+.f6495.2%

          \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(4, x\right), y\right)\right) \]
      5. Simplified95.2%

        \[\leadsto \left|\color{blue}{\frac{4 + x}{y}}\right| \]
    10. Recombined 2 regimes into one program.
    11. Add Preprocessing

    Alternative 7: 66.8% accurate, 1.0× speedup?

    \[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \left|\frac{z}{\frac{y\_m}{x}}\right|\\ \mathbf{if}\;x \leq -7.8 \cdot 10^{-112}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-46}:\\ \;\;\;\;\left|\frac{4}{y\_m}\right|\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    y_m = (fabs.f64 y)
    (FPCore (x y_m z)
     :precision binary64
     (let* ((t_0 (fabs (/ z (/ y_m x)))))
       (if (<= x -7.8e-112) t_0 (if (<= x 1.2e-46) (fabs (/ 4.0 y_m)) t_0))))
    y_m = fabs(y);
    double code(double x, double y_m, double z) {
    	double t_0 = fabs((z / (y_m / x)));
    	double tmp;
    	if (x <= -7.8e-112) {
    		tmp = t_0;
    	} else if (x <= 1.2e-46) {
    		tmp = fabs((4.0 / y_m));
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    y_m = abs(y)
    real(8) function code(x, y_m, z)
        real(8), intent (in) :: x
        real(8), intent (in) :: y_m
        real(8), intent (in) :: z
        real(8) :: t_0
        real(8) :: tmp
        t_0 = abs((z / (y_m / x)))
        if (x <= (-7.8d-112)) then
            tmp = t_0
        else if (x <= 1.2d-46) then
            tmp = abs((4.0d0 / y_m))
        else
            tmp = t_0
        end if
        code = tmp
    end function
    
    y_m = Math.abs(y);
    public static double code(double x, double y_m, double z) {
    	double t_0 = Math.abs((z / (y_m / x)));
    	double tmp;
    	if (x <= -7.8e-112) {
    		tmp = t_0;
    	} else if (x <= 1.2e-46) {
    		tmp = Math.abs((4.0 / y_m));
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    y_m = math.fabs(y)
    def code(x, y_m, z):
    	t_0 = math.fabs((z / (y_m / x)))
    	tmp = 0
    	if x <= -7.8e-112:
    		tmp = t_0
    	elif x <= 1.2e-46:
    		tmp = math.fabs((4.0 / y_m))
    	else:
    		tmp = t_0
    	return tmp
    
    y_m = abs(y)
    function code(x, y_m, z)
    	t_0 = abs(Float64(z / Float64(y_m / x)))
    	tmp = 0.0
    	if (x <= -7.8e-112)
    		tmp = t_0;
    	elseif (x <= 1.2e-46)
    		tmp = abs(Float64(4.0 / y_m));
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    y_m = abs(y);
    function tmp_2 = code(x, y_m, z)
    	t_0 = abs((z / (y_m / x)));
    	tmp = 0.0;
    	if (x <= -7.8e-112)
    		tmp = t_0;
    	elseif (x <= 1.2e-46)
    		tmp = abs((4.0 / y_m));
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    y_m = N[Abs[y], $MachinePrecision]
    code[x_, y$95$m_, z_] := Block[{t$95$0 = N[Abs[N[(z / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -7.8e-112], t$95$0, If[LessEqual[x, 1.2e-46], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], t$95$0]]]
    
    \begin{array}{l}
    y_m = \left|y\right|
    
    \\
    \begin{array}{l}
    t_0 := \left|\frac{z}{\frac{y\_m}{x}}\right|\\
    \mathbf{if}\;x \leq -7.8 \cdot 10^{-112}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;x \leq 1.2 \cdot 10^{-46}:\\
    \;\;\;\;\left|\frac{4}{y\_m}\right|\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < -7.8000000000000002e-112 or 1.20000000000000007e-46 < x

      1. Initial program 89.2%

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

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(\color{blue}{\left(\frac{x}{y}\right)}, \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, y\right), z\right)\right)\right) \]
      4. Step-by-step derivation
        1. /-lowering-/.f6485.1%

          \[\leadsto \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(x, y\right), \mathsf{*.f64}\left(\mathsf{/.f64}\left(x, y\right), z\right)\right)\right) \]
      5. Simplified85.1%

        \[\leadsto \left|\color{blue}{\frac{x}{y}} - \frac{x}{y} \cdot z\right| \]
      6. Step-by-step derivation
        1. fabs-subN/A

          \[\leadsto \left|\frac{x}{y} \cdot z - \frac{x}{y}\right| \]
        2. fabs-lowering-fabs.f64N/A

          \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x}{y} \cdot z - \frac{x}{y}\right)\right) \]
        3. *-commutativeN/A

          \[\leadsto \mathsf{fabs.f64}\left(\left(z \cdot \frac{x}{y} - \frac{x}{y}\right)\right) \]
        4. clear-numN/A

          \[\leadsto \mathsf{fabs.f64}\left(\left(z \cdot \frac{1}{\frac{y}{x}} - \frac{x}{y}\right)\right) \]
        5. div-invN/A

          \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{z}{\frac{y}{x}} - \frac{x}{y}\right)\right) \]
        6. clear-numN/A

          \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{z}{\frac{y}{x}} - \frac{1}{\frac{y}{x}}\right)\right) \]
        7. sub-divN/A

          \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{z - 1}{\frac{y}{x}}\right)\right) \]
        8. /-lowering-/.f64N/A

          \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(z - 1\right), \left(\frac{y}{x}\right)\right)\right) \]
        9. --lowering--.f64N/A

          \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(z, 1\right), \left(\frac{y}{x}\right)\right)\right) \]
        10. /-lowering-/.f6495.6%

          \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(z, 1\right), \mathsf{/.f64}\left(y, x\right)\right)\right) \]
      7. Applied egg-rr95.6%

        \[\leadsto \color{blue}{\left|\frac{z - 1}{\frac{y}{x}}\right|} \]
      8. Taylor expanded in z around inf

        \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\color{blue}{z}, \mathsf{/.f64}\left(y, x\right)\right)\right) \]
      9. Step-by-step derivation
        1. Simplified70.0%

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

        if -7.8000000000000002e-112 < x < 1.20000000000000007e-46

        1. Initial program 97.3%

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

          \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(\frac{4}{y}\right)}\right) \]
        4. Step-by-step derivation
          1. /-lowering-/.f6484.5%

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(4, y\right)\right) \]
        5. Simplified84.5%

          \[\leadsto \left|\color{blue}{\frac{4}{y}}\right| \]
      10. Recombined 2 regimes into one program.
      11. Add Preprocessing

      Alternative 8: 98.3% accurate, 1.0× speedup?

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

        1. Initial program 85.2%

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

          \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(x \cdot \left(\frac{1}{y} - \frac{z}{y}\right)\right)}\right) \]
        4. Step-by-step derivation
          1. div-subN/A

            \[\leadsto \mathsf{fabs.f64}\left(\left(x \cdot \frac{1 - z}{y}\right)\right) \]
          2. associate-/l*N/A

            \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x \cdot \left(1 - z\right)}{y}\right)\right) \]
          3. sub-negN/A

            \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x \cdot \left(1 + \left(\mathsf{neg}\left(z\right)\right)\right)}{y}\right)\right) \]
          4. mul-1-negN/A

            \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x \cdot \left(1 + -1 \cdot z\right)}{y}\right)\right) \]
          5. /-lowering-/.f64N/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \left(1 + -1 \cdot z\right)\right), y\right)\right) \]
          6. mul-1-negN/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \left(1 + \left(\mathsf{neg}\left(z\right)\right)\right)\right), y\right)\right) \]
          7. sub-negN/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \left(1 - z\right)\right), y\right)\right) \]
          8. *-lowering-*.f64N/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(1 - z\right)\right), y\right)\right) \]
          9. --lowering--.f6487.6%

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, z\right)\right), y\right)\right) \]
        5. Simplified87.6%

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

            \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{\left(1 - z\right) \cdot x}{y}\right)\right) \]
          2. associate-/l*N/A

            \[\leadsto \mathsf{fabs.f64}\left(\left(\left(1 - z\right) \cdot \frac{x}{y}\right)\right) \]
          3. *-lowering-*.f64N/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(\left(1 - z\right), \left(\frac{x}{y}\right)\right)\right) \]
          4. --lowering--.f64N/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, z\right), \left(\frac{x}{y}\right)\right)\right) \]
          5. /-lowering-/.f6499.9%

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(1, z\right), \mathsf{/.f64}\left(x, y\right)\right)\right) \]
        7. Applied egg-rr99.9%

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

        if -2e20 < x

        1. Initial program 94.8%

          \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
        2. Step-by-step derivation
          1. fabs-lowering-fabs.f64N/A

            \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x + 4}{y} - \frac{x}{y} \cdot z\right)\right) \]
          2. associate-*l/N/A

            \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x + 4}{y} - \frac{x \cdot z}{y}\right)\right) \]
          3. div-subN/A

            \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{\left(x + 4\right) - x \cdot z}{y}\right)\right) \]
          4. /-lowering-/.f64N/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(\left(x + 4\right) - x \cdot z\right), y\right)\right) \]
          5. sub-negN/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(\left(x + 4\right) + \left(\mathsf{neg}\left(x \cdot z\right)\right)\right), y\right)\right) \]
          6. +-commutativeN/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(\left(4 + x\right) + \left(\mathsf{neg}\left(x \cdot z\right)\right)\right), y\right)\right) \]
          7. remove-double-negN/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(\left(4 + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) + \left(\mathsf{neg}\left(x \cdot z\right)\right)\right), y\right)\right) \]
          8. unsub-negN/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(\left(4 - \left(\mathsf{neg}\left(x\right)\right)\right) + \left(\mathsf{neg}\left(x \cdot z\right)\right)\right), y\right)\right) \]
          9. associate-+l-N/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(4 - \left(\left(\mathsf{neg}\left(x\right)\right) - \left(\mathsf{neg}\left(x \cdot z\right)\right)\right)\right), y\right)\right) \]
          10. --lowering--.f64N/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \left(\left(\mathsf{neg}\left(x\right)\right) - \left(\mathsf{neg}\left(x \cdot z\right)\right)\right)\right), y\right)\right) \]
          11. neg-mul-1N/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \left(-1 \cdot x - \left(\mathsf{neg}\left(x \cdot z\right)\right)\right)\right), y\right)\right) \]
          12. *-commutativeN/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \left(x \cdot -1 - \left(\mathsf{neg}\left(x \cdot z\right)\right)\right)\right), y\right)\right) \]
          13. distribute-rgt-neg-inN/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \left(x \cdot -1 - x \cdot \left(\mathsf{neg}\left(z\right)\right)\right)\right), y\right)\right) \]
          14. distribute-lft-out--N/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \left(x \cdot \left(-1 - \left(\mathsf{neg}\left(z\right)\right)\right)\right)\right), y\right)\right) \]
          15. *-lowering-*.f64N/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \mathsf{*.f64}\left(x, \left(-1 - \left(\mathsf{neg}\left(z\right)\right)\right)\right)\right), y\right)\right) \]
          16. sub-negN/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \mathsf{*.f64}\left(x, \left(-1 + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(z\right)\right)\right)\right)\right)\right)\right), y\right)\right) \]
          17. remove-double-negN/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \mathsf{*.f64}\left(x, \left(-1 + z\right)\right)\right), y\right)\right) \]
          18. +-commutativeN/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \mathsf{*.f64}\left(x, \left(z + -1\right)\right)\right), y\right)\right) \]
          19. +-lowering-+.f6498.0%

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(4, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(z, -1\right)\right)\right), y\right)\right) \]
        3. Simplified98.0%

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

      Alternative 9: 69.7% accurate, 1.0× speedup?

      \[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \left|\frac{x}{y\_m}\right|\\ \mathbf{if}\;x \leq -1.55:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\left|\frac{4}{y\_m}\right|\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      y_m = (fabs.f64 y)
      (FPCore (x y_m z)
       :precision binary64
       (let* ((t_0 (fabs (/ x y_m))))
         (if (<= x -1.55) t_0 (if (<= x 4.0) (fabs (/ 4.0 y_m)) t_0))))
      y_m = fabs(y);
      double code(double x, double y_m, double z) {
      	double t_0 = fabs((x / y_m));
      	double tmp;
      	if (x <= -1.55) {
      		tmp = t_0;
      	} else if (x <= 4.0) {
      		tmp = fabs((4.0 / y_m));
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      y_m = abs(y)
      real(8) function code(x, y_m, z)
          real(8), intent (in) :: x
          real(8), intent (in) :: y_m
          real(8), intent (in) :: z
          real(8) :: t_0
          real(8) :: tmp
          t_0 = abs((x / y_m))
          if (x <= (-1.55d0)) then
              tmp = t_0
          else if (x <= 4.0d0) then
              tmp = abs((4.0d0 / y_m))
          else
              tmp = t_0
          end if
          code = tmp
      end function
      
      y_m = Math.abs(y);
      public static double code(double x, double y_m, double z) {
      	double t_0 = Math.abs((x / y_m));
      	double tmp;
      	if (x <= -1.55) {
      		tmp = t_0;
      	} else if (x <= 4.0) {
      		tmp = Math.abs((4.0 / y_m));
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      y_m = math.fabs(y)
      def code(x, y_m, z):
      	t_0 = math.fabs((x / y_m))
      	tmp = 0
      	if x <= -1.55:
      		tmp = t_0
      	elif x <= 4.0:
      		tmp = math.fabs((4.0 / y_m))
      	else:
      		tmp = t_0
      	return tmp
      
      y_m = abs(y)
      function code(x, y_m, z)
      	t_0 = abs(Float64(x / y_m))
      	tmp = 0.0
      	if (x <= -1.55)
      		tmp = t_0;
      	elseif (x <= 4.0)
      		tmp = abs(Float64(4.0 / y_m));
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      y_m = abs(y);
      function tmp_2 = code(x, y_m, z)
      	t_0 = abs((x / y_m));
      	tmp = 0.0;
      	if (x <= -1.55)
      		tmp = t_0;
      	elseif (x <= 4.0)
      		tmp = abs((4.0 / y_m));
      	else
      		tmp = t_0;
      	end
      	tmp_2 = tmp;
      end
      
      y_m = N[Abs[y], $MachinePrecision]
      code[x_, y$95$m_, z_] := Block[{t$95$0 = N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, -1.55], t$95$0, If[LessEqual[x, 4.0], N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision], t$95$0]]]
      
      \begin{array}{l}
      y_m = \left|y\right|
      
      \\
      \begin{array}{l}
      t_0 := \left|\frac{x}{y\_m}\right|\\
      \mathbf{if}\;x \leq -1.55:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;x \leq 4:\\
      \;\;\;\;\left|\frac{4}{y\_m}\right|\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < -1.55000000000000004 or 4 < x

        1. Initial program 86.5%

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

          \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(x \cdot \left(\frac{1}{y} - \frac{z}{y}\right)\right)}\right) \]
        4. Step-by-step derivation
          1. div-subN/A

            \[\leadsto \mathsf{fabs.f64}\left(\left(x \cdot \frac{1 - z}{y}\right)\right) \]
          2. associate-/l*N/A

            \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x \cdot \left(1 - z\right)}{y}\right)\right) \]
          3. sub-negN/A

            \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x \cdot \left(1 + \left(\mathsf{neg}\left(z\right)\right)\right)}{y}\right)\right) \]
          4. mul-1-negN/A

            \[\leadsto \mathsf{fabs.f64}\left(\left(\frac{x \cdot \left(1 + -1 \cdot z\right)}{y}\right)\right) \]
          5. /-lowering-/.f64N/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \left(1 + -1 \cdot z\right)\right), y\right)\right) \]
          6. mul-1-negN/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \left(1 + \left(\mathsf{neg}\left(z\right)\right)\right)\right), y\right)\right) \]
          7. sub-negN/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\left(x \cdot \left(1 - z\right)\right), y\right)\right) \]
          8. *-lowering-*.f64N/A

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \left(1 - z\right)\right), y\right)\right) \]
          9. --lowering--.f6490.3%

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(x, \mathsf{\_.f64}\left(1, z\right)\right), y\right)\right) \]
        5. Simplified90.3%

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

          \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(\frac{x}{y}\right)}\right) \]
        7. Step-by-step derivation
          1. /-lowering-/.f6461.1%

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(x, y\right)\right) \]
        8. Simplified61.1%

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

        if -1.55000000000000004 < x < 4

        1. Initial program 97.9%

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

          \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(\frac{4}{y}\right)}\right) \]
        4. Step-by-step derivation
          1. /-lowering-/.f6469.5%

            \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(4, y\right)\right) \]
        5. Simplified69.5%

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

      Alternative 10: 40.6% accurate, 1.1× speedup?

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

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

        \[\leadsto \mathsf{fabs.f64}\left(\color{blue}{\left(\frac{4}{y}\right)}\right) \]
      4. Step-by-step derivation
        1. /-lowering-/.f6437.4%

          \[\leadsto \mathsf{fabs.f64}\left(\mathsf{/.f64}\left(4, y\right)\right) \]
      5. Simplified37.4%

        \[\leadsto \left|\color{blue}{\frac{4}{y}}\right| \]
      6. Add Preprocessing

      Reproduce

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