fabs fraction 1

Percentage Accurate: 91.5% → 99.9%
Time: 8.6s
Alternatives: 8
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 8 alternatives:

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

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

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

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


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

    1. Initial program 89.2%

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

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

    if 5.00000000000000031e-10 < y

    1. Initial program 98.1%

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

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

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

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

Alternative 2: 62.0% accurate, 0.8× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \left|\frac{x}{\frac{y_m}{z}}\right|\\ t_1 := \left|\frac{4}{y_m}\right|\\ \mathbf{if}\;z \leq -980000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.25 \cdot 10^{-206}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.7 \cdot 10^{-255}:\\ \;\;\;\;\left|\frac{x}{y_m}\right|\\ \mathbf{elif}\;z \leq -2.85 \cdot 10^{-299}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{-203}:\\ \;\;\;\;\left|x \cdot \frac{1}{y_m}\right|\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-9}:\\ \;\;\;\;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 z)))) (t_1 (fabs (/ 4.0 y_m))))
   (if (<= z -980000000.0)
     t_0
     (if (<= z -1.25e-206)
       t_1
       (if (<= z -3.7e-255)
         (fabs (/ x y_m))
         (if (<= z -2.85e-299)
           t_1
           (if (<= z 5.2e-203)
             (fabs (* x (/ 1.0 y_m)))
             (if (<= z 2.5e-9) t_1 t_0))))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = fabs((x / (y_m / z)));
	double t_1 = fabs((4.0 / y_m));
	double tmp;
	if (z <= -980000000.0) {
		tmp = t_0;
	} else if (z <= -1.25e-206) {
		tmp = t_1;
	} else if (z <= -3.7e-255) {
		tmp = fabs((x / y_m));
	} else if (z <= -2.85e-299) {
		tmp = t_1;
	} else if (z <= 5.2e-203) {
		tmp = fabs((x * (1.0 / y_m)));
	} else if (z <= 2.5e-9) {
		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 / z)))
    t_1 = abs((4.0d0 / y_m))
    if (z <= (-980000000.0d0)) then
        tmp = t_0
    else if (z <= (-1.25d-206)) then
        tmp = t_1
    else if (z <= (-3.7d-255)) then
        tmp = abs((x / y_m))
    else if (z <= (-2.85d-299)) then
        tmp = t_1
    else if (z <= 5.2d-203) then
        tmp = abs((x * (1.0d0 / y_m)))
    else if (z <= 2.5d-9) 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 / z)));
	double t_1 = Math.abs((4.0 / y_m));
	double tmp;
	if (z <= -980000000.0) {
		tmp = t_0;
	} else if (z <= -1.25e-206) {
		tmp = t_1;
	} else if (z <= -3.7e-255) {
		tmp = Math.abs((x / y_m));
	} else if (z <= -2.85e-299) {
		tmp = t_1;
	} else if (z <= 5.2e-203) {
		tmp = Math.abs((x * (1.0 / y_m)));
	} else if (z <= 2.5e-9) {
		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 / z)))
	t_1 = math.fabs((4.0 / y_m))
	tmp = 0
	if z <= -980000000.0:
		tmp = t_0
	elif z <= -1.25e-206:
		tmp = t_1
	elif z <= -3.7e-255:
		tmp = math.fabs((x / y_m))
	elif z <= -2.85e-299:
		tmp = t_1
	elif z <= 5.2e-203:
		tmp = math.fabs((x * (1.0 / y_m)))
	elif z <= 2.5e-9:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	t_0 = abs(Float64(x / Float64(y_m / z)))
	t_1 = abs(Float64(4.0 / y_m))
	tmp = 0.0
	if (z <= -980000000.0)
		tmp = t_0;
	elseif (z <= -1.25e-206)
		tmp = t_1;
	elseif (z <= -3.7e-255)
		tmp = abs(Float64(x / y_m));
	elseif (z <= -2.85e-299)
		tmp = t_1;
	elseif (z <= 5.2e-203)
		tmp = abs(Float64(x * Float64(1.0 / y_m)));
	elseif (z <= 2.5e-9)
		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 / z)));
	t_1 = abs((4.0 / y_m));
	tmp = 0.0;
	if (z <= -980000000.0)
		tmp = t_0;
	elseif (z <= -1.25e-206)
		tmp = t_1;
	elseif (z <= -3.7e-255)
		tmp = abs((x / y_m));
	elseif (z <= -2.85e-299)
		tmp = t_1;
	elseif (z <= 5.2e-203)
		tmp = abs((x * (1.0 / y_m)));
	elseif (z <= 2.5e-9)
		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 / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(4.0 / y$95$m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[z, -980000000.0], t$95$0, If[LessEqual[z, -1.25e-206], t$95$1, If[LessEqual[z, -3.7e-255], N[Abs[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, -2.85e-299], t$95$1, If[LessEqual[z, 5.2e-203], N[Abs[N[(x * N[(1.0 / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 2.5e-9], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := \left|\frac{x}{\frac{y_m}{z}}\right|\\
t_1 := \left|\frac{4}{y_m}\right|\\
\mathbf{if}\;z \leq -980000000:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -1.25 \cdot 10^{-206}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq -3.7 \cdot 10^{-255}:\\
\;\;\;\;\left|\frac{x}{y_m}\right|\\

\mathbf{elif}\;z \leq -2.85 \cdot 10^{-299}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 5.2 \cdot 10^{-203}:\\
\;\;\;\;\left|x \cdot \frac{1}{y_m}\right|\\

\mathbf{elif}\;z \leq 2.5 \cdot 10^{-9}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -9.8e8 or 2.5000000000000001e-9 < z

    1. Initial program 87.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.8e8 < z < -1.25e-206 or -3.7000000000000002e-255 < z < -2.84999999999999993e-299 or 5.19999999999999951e-203 < z < 2.5000000000000001e-9

    1. Initial program 97.7%

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

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

    if -1.25e-206 < z < -3.7000000000000002e-255

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if -2.84999999999999993e-299 < z < 5.19999999999999951e-203

    1. Initial program 82.8%

      \[\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. Add Preprocessing
    4. Taylor expanded in x around inf 67.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -980000000:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;z \leq -1.25 \cdot 10^{-206}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;z \leq -3.7 \cdot 10^{-255}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;z \leq -2.85 \cdot 10^{-299}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{-203}:\\ \;\;\;\;\left|x \cdot \frac{1}{y}\right|\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-9}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 61.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
t_0 := \left|\frac{4}{y_m}\right|\\
\mathbf{if}\;z \leq -120000000:\\
\;\;\;\;\left|\frac{z}{\frac{y_m}{x}}\right|\\

\mathbf{elif}\;z \leq -7.6 \cdot 10^{-208}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -1.7 \cdot 10^{-254}:\\
\;\;\;\;\left|\frac{x}{y_m}\right|\\

\mathbf{elif}\;z \leq -2.6 \cdot 10^{-299}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 2.8 \cdot 10^{-205}:\\
\;\;\;\;\left|x \cdot \frac{1}{y_m}\right|\\

\mathbf{elif}\;z \leq 2.5 \cdot 10^{-9}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if z < -1.2e8

    1. Initial program 96.8%

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{\color{blue}{-z}}{\frac{y}{x}}\right| \]
      4. add-sqr-sqrt82.9%

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

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

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

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

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

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

    if -1.2e8 < z < -7.60000000000000023e-208 or -1.69999999999999996e-254 < z < -2.5999999999999999e-299 or 2.79999999999999991e-205 < z < 2.5000000000000001e-9

    1. Initial program 97.7%

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

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

    if -7.60000000000000023e-208 < z < -1.69999999999999996e-254

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if -2.5999999999999999e-299 < z < 2.79999999999999991e-205

    1. Initial program 82.8%

      \[\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. Add Preprocessing
    4. Taylor expanded in x around inf 67.7%

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

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

    if 2.5000000000000001e-9 < z

    1. Initial program 78.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -120000000:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;z \leq -7.6 \cdot 10^{-208}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;z \leq -1.7 \cdot 10^{-254}:\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{-299}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-205}:\\ \;\;\;\;\left|x \cdot \frac{1}{y}\right|\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-9}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 99.8% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;x \leq 5 \cdot 10^{+32}:\\
\;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y_m}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|x \cdot \left(\frac{1}{y_m} - \frac{z}{y_m}\right)\right|\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -3.99999999999999966e29

    1. Initial program 83.2%

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

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

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

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

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

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

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

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

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

    if -3.99999999999999966e29 < x < 4.9999999999999997e32

    1. Initial program 96.5%

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

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

    if 4.9999999999999997e32 < x

    1. Initial program 85.8%

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

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

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

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

Alternative 5: 85.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -18000000000:\\
\;\;\;\;\left|\frac{z}{\frac{y_m}{x}}\right|\\

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

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


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

    1. Initial program 96.8%

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

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

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

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

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

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

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

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

        \[\leadsto \left|\frac{\color{blue}{-z}}{\frac{y}{x}}\right| \]
      4. add-sqr-sqrt82.9%

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

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

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

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

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

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

    if -1.8e10 < z < 4.7999999999999998e117

    1. Initial program 90.7%

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

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

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

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

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

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

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

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

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

    if 4.7999999999999998e117 < z

    1. Initial program 83.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -18000000000:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{+117}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 85.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -24000000000:\\
\;\;\;\;\left|\frac{z + -1}{\frac{y_m}{x}}\right|\\

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

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


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

    1. Initial program 96.8%

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

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

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

      \[\leadsto \left|\color{blue}{\frac{x \cdot \left(z - 1\right)}{y}}\right| \]
    6. Step-by-step derivation
      1. sub-neg76.6%

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

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

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

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

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

    if -2.4e10 < z < 4.19999999999999966e119

    1. Initial program 90.7%

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

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

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

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

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

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

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

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

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

    if 4.19999999999999966e119 < z

    1. Initial program 83.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -24000000000:\\ \;\;\;\;\left|\frac{z + -1}{\frac{y}{x}}\right|\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{+119}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 69.4% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \lor \neg \left(x \leq 4\right):\\
\;\;\;\;\left|\frac{x}{y_m}\right|\\

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


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

    1. Initial program 85.3%

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

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

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

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

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

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

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

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

    if -1.55000000000000004 < x < 4

    1. Initial program 96.3%

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

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

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

Alternative 8: 40.9% 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 91.0%

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

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

    \[\leadsto \left|\frac{4}{y}\right| \]
  5. Add Preprocessing

Reproduce

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