fabs fraction 1

Percentage Accurate: 92.3% → 99.3%
Time: 11.1s
Alternatives: 17
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 17 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.3% 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.3% accurate, 0.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;y\_m \leq 4 \cdot 10^{-94}:\\ \;\;\;\;\left|\frac{x \cdot z - \left(x + 4\right)}{y\_m}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\mathsf{fma}\left(x, \frac{z}{y\_m}, \frac{-4 - x}{y\_m}\right)\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= y_m 4e-94)
   (fabs (/ (- (* x z) (+ x 4.0)) y_m))
   (fabs (fma x (/ z y_m) (/ (- -4.0 x) y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (y_m <= 4e-94) {
		tmp = fabs((((x * z) - (x + 4.0)) / y_m));
	} else {
		tmp = fabs(fma(x, (z / y_m), ((-4.0 - x) / y_m)));
	}
	return tmp;
}
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (y_m <= 4e-94)
		tmp = abs(Float64(Float64(Float64(x * z) - Float64(x + 4.0)) / y_m));
	else
		tmp = abs(fma(x, Float64(z / y_m), Float64(Float64(-4.0 - x) / y_m)));
	end
	return tmp
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[y$95$m, 4e-94], N[Abs[N[(N[(N[(x * z), $MachinePrecision] - N[(x + 4.0), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(x * N[(z / y$95$m), $MachinePrecision] + N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

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

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


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

    1. Initial program 89.9%

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

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

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

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

    if 3.9999999999999998e-94 < y

    1. Initial program 96.2%

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

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac99.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative99.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in99.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg99.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval99.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified99.9%

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

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

Alternative 2: 91.8% accurate, 0.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -1.7 \cdot 10^{-37} \lor \neg \left(x \leq 1.2 \cdot 10^{-26}\right):\\ \;\;\;\;\left|\frac{x}{y\_m} \cdot \left(1 - z\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{4 - x \cdot z}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (or (<= x -1.7e-37) (not (<= x 1.2e-26)))
   (fabs (* (/ x y_m) (- 1.0 z)))
   (/ (- 4.0 (* x z)) y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if ((x <= -1.7e-37) || !(x <= 1.2e-26)) {
		tmp = fabs(((x / y_m) * (1.0 - z)));
	} else {
		tmp = (4.0 - (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 ((x <= (-1.7d-37)) .or. (.not. (x <= 1.2d-26))) then
        tmp = abs(((x / y_m) * (1.0d0 - z)))
    else
        tmp = (4.0d0 - (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 ((x <= -1.7e-37) || !(x <= 1.2e-26)) {
		tmp = Math.abs(((x / y_m) * (1.0 - z)));
	} else {
		tmp = (4.0 - (x * z)) / y_m;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if (x <= -1.7e-37) or not (x <= 1.2e-26):
		tmp = math.fabs(((x / y_m) * (1.0 - z)))
	else:
		tmp = (4.0 - (x * z)) / y_m
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if ((x <= -1.7e-37) || !(x <= 1.2e-26))
		tmp = abs(Float64(Float64(x / y_m) * Float64(1.0 - z)));
	else
		tmp = Float64(Float64(4.0 - Float64(x * z)) / y_m);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if ((x <= -1.7e-37) || ~((x <= 1.2e-26)))
		tmp = abs(((x / y_m) * (1.0 - z)));
	else
		tmp = (4.0 - (x * z)) / y_m;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[Or[LessEqual[x, -1.7e-37], N[Not[LessEqual[x, 1.2e-26]], $MachinePrecision]], N[Abs[N[(N[(x / y$95$m), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(4.0 - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{-37} \lor \neg \left(x \leq 1.2 \cdot 10^{-26}\right):\\
\;\;\;\;\left|\frac{x}{y\_m} \cdot \left(1 - z\right)\right|\\

\mathbf{else}:\\
\;\;\;\;\frac{4 - x \cdot z}{y\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.70000000000000009e-37 or 1.2e-26 < x

    1. Initial program 88.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|x \cdot \frac{\color{blue}{1 + \left(-z\right)}}{y}\right| \]
      12. neg-mul-196.9%

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

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

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

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

        \[\leadsto \left|\left(1 + \color{blue}{\left(-z\right)}\right) \cdot \frac{x}{y}\right| \]
      17. unsub-neg97.0%

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

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

    if -1.70000000000000009e-37 < x < 1.2e-26

    1. Initial program 95.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt46.3%

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

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      3. add-sqr-sqrt47.6%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      4. sub-neg47.6%

        \[\leadsto \color{blue}{\frac{x + 4}{y} + \left(-\frac{x}{y} \cdot z\right)} \]
      5. +-commutative47.6%

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

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

        \[\leadsto \left(-\color{blue}{x \cdot \frac{z}{y}}\right) + \frac{x + 4}{y} \]
      8. frac-2neg45.8%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \color{blue}{\frac{-\left(x + 4\right)}{-y}} \]
      9. +-commutative45.8%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{-\color{blue}{\left(4 + x\right)}}{-y} \]
      10. distribute-neg-in45.8%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{-y} \]
      11. metadata-eval45.8%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{-4} + \left(-x\right)}{-y} \]
      12. sub-neg45.8%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{-4 - x}}{-y} \]
      13. distribute-frac-neg245.8%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \color{blue}{\left(-\frac{-4 - x}{y}\right)} \]
      14. distribute-neg-in45.8%

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine45.8%

        \[\leadsto -\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      16. neg-sub045.8%

        \[\leadsto \color{blue}{0 - \mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      17. fma-undefine45.8%

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

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

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

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

      \[\leadsto 0 - \frac{x \cdot z - \color{blue}{4}}{y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification76.5%

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

Alternative 3: 99.7% accurate, 1.0× speedup?

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

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


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

    1. Initial program 90.3%

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

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

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

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

    if 1e-52 < y

    1. Initial program 95.8%

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

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

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

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

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

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

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

Alternative 4: 85.3% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;z \leq -16 \lor \neg \left(z \leq 950\right):\\ \;\;\;\;\left|z \cdot \frac{x}{y\_m}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{-4 - x}{y\_m}\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (or (<= z -16.0) (not (<= z 950.0)))
   (fabs (* z (/ x y_m)))
   (fabs (/ (- -4.0 x) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if ((z <= -16.0) || !(z <= 950.0)) {
		tmp = fabs((z * (x / y_m)));
	} else {
		tmp = fabs(((-4.0 - x) / 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 ((z <= (-16.0d0)) .or. (.not. (z <= 950.0d0))) then
        tmp = abs((z * (x / y_m)))
    else
        tmp = abs((((-4.0d0) - x) / 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 ((z <= -16.0) || !(z <= 950.0)) {
		tmp = Math.abs((z * (x / y_m)));
	} else {
		tmp = Math.abs(((-4.0 - x) / y_m));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if (z <= -16.0) or not (z <= 950.0):
		tmp = math.fabs((z * (x / y_m)))
	else:
		tmp = math.fabs(((-4.0 - x) / y_m))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if ((z <= -16.0) || !(z <= 950.0))
		tmp = abs(Float64(z * Float64(x / y_m)));
	else
		tmp = abs(Float64(Float64(-4.0 - x) / y_m));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if ((z <= -16.0) || ~((z <= 950.0)))
		tmp = abs((z * (x / y_m)));
	else
		tmp = abs(((-4.0 - x) / y_m));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[Or[LessEqual[z, -16.0], N[Not[LessEqual[z, 950.0]], $MachinePrecision]], N[Abs[N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;z \leq -16 \lor \neg \left(z \leq 950\right):\\
\;\;\;\;\left|z \cdot \frac{x}{y\_m}\right|\\

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


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

    1. Initial program 90.7%

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

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

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

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

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

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

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

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

    if -16 < z < 950

    1. Initial program 92.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub92.7%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac100.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative100.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in100.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg100.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval100.0%

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

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

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

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

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

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

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

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

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

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

Alternative 5: 84.2% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;z \leq -16:\\ \;\;\;\;\left|\frac{x \cdot z}{y\_m}\right|\\ \mathbf{elif}\;z \leq 950:\\ \;\;\;\;\left|\frac{-4 - x}{y\_m}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y\_m}\right|\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= z -16.0)
   (fabs (/ (* x z) y_m))
   (if (<= z 950.0) (fabs (/ (- -4.0 x) y_m)) (fabs (* z (/ x y_m))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (z <= -16.0) {
		tmp = fabs(((x * z) / y_m));
	} else if (z <= 950.0) {
		tmp = fabs(((-4.0 - x) / y_m));
	} else {
		tmp = fabs((z * (x / 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 (z <= (-16.0d0)) then
        tmp = abs(((x * z) / y_m))
    else if (z <= 950.0d0) then
        tmp = abs((((-4.0d0) - x) / y_m))
    else
        tmp = abs((z * (x / 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 (z <= -16.0) {
		tmp = Math.abs(((x * z) / y_m));
	} else if (z <= 950.0) {
		tmp = Math.abs(((-4.0 - x) / y_m));
	} else {
		tmp = Math.abs((z * (x / y_m)));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if z <= -16.0:
		tmp = math.fabs(((x * z) / y_m))
	elif z <= 950.0:
		tmp = math.fabs(((-4.0 - x) / y_m))
	else:
		tmp = math.fabs((z * (x / y_m)))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (z <= -16.0)
		tmp = abs(Float64(Float64(x * z) / y_m));
	elseif (z <= 950.0)
		tmp = abs(Float64(Float64(-4.0 - x) / y_m));
	else
		tmp = abs(Float64(z * Float64(x / y_m)));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (z <= -16.0)
		tmp = abs(((x * z) / y_m));
	elseif (z <= 950.0)
		tmp = abs(((-4.0 - x) / y_m));
	else
		tmp = abs((z * (x / y_m)));
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[z, -16.0], N[Abs[N[(N[(x * z), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 950.0], N[Abs[N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], N[Abs[N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;z \leq -16:\\
\;\;\;\;\left|\frac{x \cdot z}{y\_m}\right|\\

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

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


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

    1. Initial program 91.7%

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

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

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

        \[\leadsto \left|\color{blue}{\frac{-1 \cdot \left(x \cdot z\right)}{y}}\right| \]
      2. neg-mul-167.2%

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

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

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

    if -16 < z < 950

    1. Initial program 92.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub92.7%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac100.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative100.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in100.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg100.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval100.0%

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

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

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

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

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

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

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

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

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

    if 950 < z

    1. Initial program 89.8%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -16:\\ \;\;\;\;\left|\frac{x \cdot z}{y}\right|\\ \mathbf{elif}\;z \leq 950:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 97.9% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 93.8%

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

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

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

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

    if 1e12 < x

    1. Initial program 86.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 72.9% accurate, 5.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -1.7 \cdot 10^{-37}:\\ \;\;\;\;x \cdot \frac{z + -1}{y\_m}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-18} \lor \neg \left(x \leq 6.8 \cdot 10^{+157}\right):\\ \;\;\;\;\frac{x + 4}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(1 - z\right)}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x -1.7e-37)
   (* x (/ (+ z -1.0) y_m))
   (if (or (<= x 1.4e-18) (not (<= x 6.8e+157)))
     (/ (+ x 4.0) y_m)
     (/ (* x (- 1.0 z)) y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -1.7e-37) {
		tmp = x * ((z + -1.0) / y_m);
	} else if ((x <= 1.4e-18) || !(x <= 6.8e+157)) {
		tmp = (x + 4.0) / y_m;
	} else {
		tmp = (x * (1.0 - 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 <= (-1.7d-37)) then
        tmp = x * ((z + (-1.0d0)) / y_m)
    else if ((x <= 1.4d-18) .or. (.not. (x <= 6.8d+157))) then
        tmp = (x + 4.0d0) / y_m
    else
        tmp = (x * (1.0d0 - 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 <= -1.7e-37) {
		tmp = x * ((z + -1.0) / y_m);
	} else if ((x <= 1.4e-18) || !(x <= 6.8e+157)) {
		tmp = (x + 4.0) / y_m;
	} else {
		tmp = (x * (1.0 - z)) / y_m;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= -1.7e-37:
		tmp = x * ((z + -1.0) / y_m)
	elif (x <= 1.4e-18) or not (x <= 6.8e+157):
		tmp = (x + 4.0) / y_m
	else:
		tmp = (x * (1.0 - z)) / y_m
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= -1.7e-37)
		tmp = Float64(x * Float64(Float64(z + -1.0) / y_m));
	elseif ((x <= 1.4e-18) || !(x <= 6.8e+157))
		tmp = Float64(Float64(x + 4.0) / y_m);
	else
		tmp = Float64(Float64(x * Float64(1.0 - z)) / y_m);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= -1.7e-37)
		tmp = x * ((z + -1.0) / y_m);
	elseif ((x <= 1.4e-18) || ~((x <= 6.8e+157)))
		tmp = (x + 4.0) / y_m;
	else
		tmp = (x * (1.0 - z)) / y_m;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, -1.7e-37], N[(x * N[(N[(z + -1.0), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, 1.4e-18], N[Not[LessEqual[x, 6.8e+157]], $MachinePrecision]], N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{-37}:\\
\;\;\;\;x \cdot \frac{z + -1}{y\_m}\\

\mathbf{elif}\;x \leq 1.4 \cdot 10^{-18} \lor \neg \left(x \leq 6.8 \cdot 10^{+157}\right):\\
\;\;\;\;\frac{x + 4}{y\_m}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.70000000000000009e-37

    1. Initial program 89.2%

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      3. cancel-sign-sub-inv89.0%

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

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

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

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

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

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

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

        \[\leadsto \left|x \cdot \frac{z}{y} + \color{blue}{\frac{-4 - x}{y}}\right| \]
      11. fma-undefine96.8%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}\right| \]
      12. add-sqr-sqrt56.6%

        \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
      13. fabs-sqr56.6%

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
      14. add-sqr-sqrt57.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      15. fma-undefine55.6%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      16. associate-*r/51.3%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      17. associate-*l/52.6%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      18. div-inv52.5%

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

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

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
      2. sub-div54.4%

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{z - 1}{y}} \]
      2. sub-neg58.1%

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

        \[\leadsto x \cdot \frac{z + \color{blue}{-1}}{y} \]
    9. Simplified58.1%

      \[\leadsto \color{blue}{x \cdot \frac{z + -1}{y}} \]

    if -1.70000000000000009e-37 < x < 1.40000000000000006e-18 or 6.79999999999999958e157 < x

    1. Initial program 91.3%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub91.3%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac91.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative91.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in91.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg91.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval91.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified91.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(-\frac{-4 - x}{y}\right) \cdot \left(-\frac{-4 - x}{y}\right)}} \]
      6. distribute-frac-neg253.5%

        \[\leadsto \sqrt{\color{blue}{\frac{-4 - x}{-y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      7. sub-neg53.5%

        \[\leadsto \sqrt{\frac{\color{blue}{-4 + \left(-x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      8. metadata-eval53.5%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      9. distribute-neg-in53.5%

        \[\leadsto \sqrt{\frac{\color{blue}{-\left(4 + x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      10. +-commutative53.5%

        \[\leadsto \sqrt{\frac{-\color{blue}{\left(x + 4\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      11. frac-2neg53.5%

        \[\leadsto \sqrt{\color{blue}{\frac{x + 4}{y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      12. distribute-frac-neg253.5%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{-4 - x}{-y}}} \]
      13. sub-neg53.5%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-4 + \left(-x\right)}}{-y}} \]
      14. metadata-eval53.5%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y}} \]
      15. distribute-neg-in53.5%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-\left(4 + x\right)}}{-y}} \]
      16. +-commutative53.5%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{-\color{blue}{\left(x + 4\right)}}{-y}} \]
      17. frac-2neg53.5%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{x + 4}{y}}} \]
      18. sqrt-unprod37.6%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}} \]
      19. add-sqr-sqrt38.8%

        \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
    9. Applied egg-rr38.8%

      \[\leadsto \color{blue}{\frac{x + 4}{y}} \]

    if 1.40000000000000006e-18 < x < 6.79999999999999958e157

    1. Initial program 97.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt37.1%

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

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      3. add-sqr-sqrt37.8%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      4. sub-neg37.8%

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

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

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

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

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

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

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{-y} \]
      11. metadata-eval40.1%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{-4} + \left(-x\right)}{-y} \]
      12. sub-neg40.1%

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

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

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine40.1%

        \[\leadsto -\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      16. neg-sub040.1%

        \[\leadsto \color{blue}{0 - \mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      17. fma-undefine40.1%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.7 \cdot 10^{-37}:\\ \;\;\;\;x \cdot \frac{z + -1}{y}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-18} \lor \neg \left(x \leq 6.8 \cdot 10^{+157}\right):\\ \;\;\;\;\frac{x + 4}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(1 - z\right)}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 78.0% accurate, 5.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -1.7 \cdot 10^{-37}:\\ \;\;\;\;x \cdot \frac{z + -1}{y\_m}\\ \mathbf{elif}\;x \leq 1460000:\\ \;\;\;\;\frac{4 - x \cdot z}{y\_m}\\ \mathbf{elif}\;x \leq 1.32 \cdot 10^{+154}:\\ \;\;\;\;\frac{x \cdot \left(1 - z\right)}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x -1.7e-37)
   (* x (/ (+ z -1.0) y_m))
   (if (<= x 1460000.0)
     (/ (- 4.0 (* x z)) y_m)
     (if (<= x 1.32e+154) (/ (* x (- 1.0 z)) y_m) (/ (+ x 4.0) y_m)))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -1.7e-37) {
		tmp = x * ((z + -1.0) / y_m);
	} else if (x <= 1460000.0) {
		tmp = (4.0 - (x * z)) / y_m;
	} else if (x <= 1.32e+154) {
		tmp = (x * (1.0 - z)) / y_m;
	} else {
		tmp = (x + 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.7d-37)) then
        tmp = x * ((z + (-1.0d0)) / y_m)
    else if (x <= 1460000.0d0) then
        tmp = (4.0d0 - (x * z)) / y_m
    else if (x <= 1.32d+154) then
        tmp = (x * (1.0d0 - z)) / y_m
    else
        tmp = (x + 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.7e-37) {
		tmp = x * ((z + -1.0) / y_m);
	} else if (x <= 1460000.0) {
		tmp = (4.0 - (x * z)) / y_m;
	} else if (x <= 1.32e+154) {
		tmp = (x * (1.0 - z)) / y_m;
	} else {
		tmp = (x + 4.0) / y_m;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= -1.7e-37:
		tmp = x * ((z + -1.0) / y_m)
	elif x <= 1460000.0:
		tmp = (4.0 - (x * z)) / y_m
	elif x <= 1.32e+154:
		tmp = (x * (1.0 - z)) / y_m
	else:
		tmp = (x + 4.0) / y_m
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= -1.7e-37)
		tmp = Float64(x * Float64(Float64(z + -1.0) / y_m));
	elseif (x <= 1460000.0)
		tmp = Float64(Float64(4.0 - Float64(x * z)) / y_m);
	elseif (x <= 1.32e+154)
		tmp = Float64(Float64(x * Float64(1.0 - z)) / y_m);
	else
		tmp = Float64(Float64(x + 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.7e-37)
		tmp = x * ((z + -1.0) / y_m);
	elseif (x <= 1460000.0)
		tmp = (4.0 - (x * z)) / y_m;
	elseif (x <= 1.32e+154)
		tmp = (x * (1.0 - z)) / y_m;
	else
		tmp = (x + 4.0) / y_m;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, -1.7e-37], N[(x * N[(N[(z + -1.0), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1460000.0], N[(N[(4.0 - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision], If[LessEqual[x, 1.32e+154], N[(N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{-37}:\\
\;\;\;\;x \cdot \frac{z + -1}{y\_m}\\

\mathbf{elif}\;x \leq 1460000:\\
\;\;\;\;\frac{4 - x \cdot z}{y\_m}\\

\mathbf{elif}\;x \leq 1.32 \cdot 10^{+154}:\\
\;\;\;\;\frac{x \cdot \left(1 - z\right)}{y\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + 4}{y\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -1.70000000000000009e-37

    1. Initial program 89.2%

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      3. cancel-sign-sub-inv89.0%

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

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

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

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

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

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

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

        \[\leadsto \left|x \cdot \frac{z}{y} + \color{blue}{\frac{-4 - x}{y}}\right| \]
      11. fma-undefine96.8%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}\right| \]
      12. add-sqr-sqrt56.6%

        \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
      13. fabs-sqr56.6%

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
      14. add-sqr-sqrt57.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      15. fma-undefine55.6%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      16. associate-*r/51.3%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      17. associate-*l/52.6%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      18. div-inv52.5%

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

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

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
      2. sub-div54.4%

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{z - 1}{y}} \]
      2. sub-neg58.1%

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

        \[\leadsto x \cdot \frac{z + \color{blue}{-1}}{y} \]
    9. Simplified58.1%

      \[\leadsto \color{blue}{x \cdot \frac{z + -1}{y}} \]

    if -1.70000000000000009e-37 < x < 1.46e6

    1. Initial program 96.1%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt45.0%

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

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      3. add-sqr-sqrt46.4%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      4. sub-neg46.4%

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

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

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

        \[\leadsto \left(-\color{blue}{x \cdot \frac{z}{y}}\right) + \frac{x + 4}{y} \]
      8. frac-2neg44.7%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \color{blue}{\frac{-\left(x + 4\right)}{-y}} \]
      9. +-commutative44.7%

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

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{-y} \]
      11. metadata-eval44.7%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{-4} + \left(-x\right)}{-y} \]
      12. sub-neg44.7%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{-4 - x}}{-y} \]
      13. distribute-frac-neg244.7%

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

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine44.7%

        \[\leadsto -\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      16. neg-sub044.7%

        \[\leadsto \color{blue}{0 - \mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      17. fma-undefine44.7%

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

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

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

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

      \[\leadsto 0 - \frac{x \cdot z - \color{blue}{4}}{y} \]

    if 1.46e6 < x < 1.31999999999999998e154

    1. Initial program 96.8%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt38.1%

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

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      3. add-sqr-sqrt38.8%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      4. sub-neg38.8%

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

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

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

        \[\leadsto \left(-\color{blue}{x \cdot \frac{z}{y}}\right) + \frac{x + 4}{y} \]
      8. frac-2neg41.7%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \color{blue}{\frac{-\left(x + 4\right)}{-y}} \]
      9. +-commutative41.7%

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

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{-y} \]
      11. metadata-eval41.7%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{-4} + \left(-x\right)}{-y} \]
      12. sub-neg41.7%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{-4 - x}}{-y} \]
      13. distribute-frac-neg241.7%

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

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine41.7%

        \[\leadsto -\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      16. neg-sub041.7%

        \[\leadsto \color{blue}{0 - \mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      17. fma-undefine41.7%

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

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

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

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

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

    if 1.31999999999999998e154 < x

    1. Initial program 75.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub75.7%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac93.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative93.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in93.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg93.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval93.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified93.9%

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

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    8. Step-by-step derivation
      1. add-sqr-sqrt73.6%

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(-\frac{-4 - x}{y}\right) \cdot \left(-\frac{-4 - x}{y}\right)}} \]
      6. distribute-frac-neg274.7%

        \[\leadsto \sqrt{\color{blue}{\frac{-4 - x}{-y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      7. sub-neg74.7%

        \[\leadsto \sqrt{\frac{\color{blue}{-4 + \left(-x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      8. metadata-eval74.7%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      9. distribute-neg-in74.7%

        \[\leadsto \sqrt{\frac{\color{blue}{-\left(4 + x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      10. +-commutative74.7%

        \[\leadsto \sqrt{\frac{-\color{blue}{\left(x + 4\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      11. frac-2neg74.7%

        \[\leadsto \sqrt{\color{blue}{\frac{x + 4}{y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      12. distribute-frac-neg274.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{-4 - x}{-y}}} \]
      13. sub-neg74.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-4 + \left(-x\right)}}{-y}} \]
      14. metadata-eval74.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y}} \]
      15. distribute-neg-in74.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-\left(4 + x\right)}}{-y}} \]
      16. +-commutative74.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{-\color{blue}{\left(x + 4\right)}}{-y}} \]
      17. frac-2neg74.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{x + 4}{y}}} \]
      18. sqrt-unprod38.0%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}} \]
      19. add-sqr-sqrt38.4%

        \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
    9. Applied egg-rr38.4%

      \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification48.2%

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

Alternative 9: 77.5% accurate, 5.3× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \frac{x + 4}{y\_m}\\ \mathbf{if}\;x \leq -1.7 \cdot 10^{-37}:\\ \;\;\;\;x \cdot \frac{z}{y\_m} - t\_0\\ \mathbf{elif}\;x \leq 980:\\ \;\;\;\;\frac{4 - x \cdot z}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;t\_0 + \frac{x}{\frac{y\_m}{z}}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (let* ((t_0 (/ (+ x 4.0) y_m)))
   (if (<= x -1.7e-37)
     (- (* x (/ z y_m)) t_0)
     (if (<= x 980.0) (/ (- 4.0 (* x z)) y_m) (+ t_0 (/ x (/ y_m z)))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = (x + 4.0) / y_m;
	double tmp;
	if (x <= -1.7e-37) {
		tmp = (x * (z / y_m)) - t_0;
	} else if (x <= 980.0) {
		tmp = (4.0 - (x * z)) / y_m;
	} else {
		tmp = t_0 + (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 = (x + 4.0d0) / y_m
    if (x <= (-1.7d-37)) then
        tmp = (x * (z / y_m)) - t_0
    else if (x <= 980.0d0) then
        tmp = (4.0d0 - (x * z)) / y_m
    else
        tmp = t_0 + (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 = (x + 4.0) / y_m;
	double tmp;
	if (x <= -1.7e-37) {
		tmp = (x * (z / y_m)) - t_0;
	} else if (x <= 980.0) {
		tmp = (4.0 - (x * z)) / y_m;
	} else {
		tmp = t_0 + (x / (y_m / z));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	t_0 = (x + 4.0) / y_m
	tmp = 0
	if x <= -1.7e-37:
		tmp = (x * (z / y_m)) - t_0
	elif x <= 980.0:
		tmp = (4.0 - (x * z)) / y_m
	else:
		tmp = t_0 + (x / (y_m / z))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	t_0 = Float64(Float64(x + 4.0) / y_m)
	tmp = 0.0
	if (x <= -1.7e-37)
		tmp = Float64(Float64(x * Float64(z / y_m)) - t_0);
	elseif (x <= 980.0)
		tmp = Float64(Float64(4.0 - Float64(x * z)) / y_m);
	else
		tmp = Float64(t_0 + Float64(x / Float64(y_m / z)));
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	t_0 = (x + 4.0) / y_m;
	tmp = 0.0;
	if (x <= -1.7e-37)
		tmp = (x * (z / y_m)) - t_0;
	elseif (x <= 980.0)
		tmp = (4.0 - (x * z)) / y_m;
	else
		tmp = t_0 + (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[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]}, If[LessEqual[x, -1.7e-37], N[(N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 980.0], N[(N[(4.0 - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision], N[(t$95$0 + N[(x / N[(y$95$m / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := \frac{x + 4}{y\_m}\\
\mathbf{if}\;x \leq -1.7 \cdot 10^{-37}:\\
\;\;\;\;x \cdot \frac{z}{y\_m} - t\_0\\

\mathbf{elif}\;x \leq 980:\\
\;\;\;\;\frac{4 - x \cdot z}{y\_m}\\

\mathbf{else}:\\
\;\;\;\;t\_0 + \frac{x}{\frac{y\_m}{z}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.70000000000000009e-37

    1. Initial program 89.2%

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      3. cancel-sign-sub-inv89.0%

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

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

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

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

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

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

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

        \[\leadsto \left|x \cdot \frac{z}{y} + \color{blue}{\frac{-4 - x}{y}}\right| \]
      11. fma-undefine96.8%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}\right| \]
      12. add-sqr-sqrt56.6%

        \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
      13. fabs-sqr56.6%

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
      14. add-sqr-sqrt57.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      15. fma-undefine55.6%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      16. associate-*r/51.3%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      17. associate-*l/52.6%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      18. div-inv52.5%

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

      \[\leadsto \color{blue}{x \cdot \frac{z}{y} - \frac{x + 4}{y}} \]

    if -1.70000000000000009e-37 < x < 980

    1. Initial program 96.1%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt44.9%

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

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      3. add-sqr-sqrt46.3%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      4. sub-neg46.3%

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

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

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

        \[\leadsto \left(-\color{blue}{x \cdot \frac{z}{y}}\right) + \frac{x + 4}{y} \]
      8. frac-2neg44.6%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \color{blue}{\frac{-\left(x + 4\right)}{-y}} \]
      9. +-commutative44.6%

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

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{-y} \]
      11. metadata-eval44.6%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{-4} + \left(-x\right)}{-y} \]
      12. sub-neg44.6%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{-4 - x}}{-y} \]
      13. distribute-frac-neg244.6%

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

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine44.6%

        \[\leadsto -\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      16. neg-sub044.6%

        \[\leadsto \color{blue}{0 - \mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      17. fma-undefine44.6%

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

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

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

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

      \[\leadsto 0 - \frac{x \cdot z - \color{blue}{4}}{y} \]

    if 980 < x

    1. Initial program 86.8%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt31.7%

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

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      3. add-sqr-sqrt32.3%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      4. associate-*l/32.5%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      5. associate-*r/35.2%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}} \]
    4. Applied egg-rr35.2%

      \[\leadsto \color{blue}{\frac{x + 4}{y} - x \cdot \frac{z}{y}} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt13.3%

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

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{\sqrt{z \cdot z}}}{y} \]
      3. sqr-neg32.5%

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

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}}{y} \]
      5. add-sqr-sqrt56.3%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{-z}}{y} \]
      6. distribute-frac-neg56.3%

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

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

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

        \[\leadsto \frac{x + 4}{y} - \left(-x\right) \cdot \color{blue}{\frac{1}{\frac{y}{z}}} \]
      10. un-div-inv56.2%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{\frac{y}{z}}} \]
    6. Applied egg-rr56.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.7 \cdot 10^{-37}:\\ \;\;\;\;x \cdot \frac{z}{y} - \frac{x + 4}{y}\\ \mathbf{elif}\;x \leq 980:\\ \;\;\;\;\frac{4 - x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y} + \frac{x}{\frac{y}{z}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 78.3% accurate, 5.8× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} t_0 := \frac{x + 4}{y\_m}\\ \mathbf{if}\;x \leq -1.7 \cdot 10^{-37}:\\ \;\;\;\;x \cdot \frac{z}{y\_m} - t\_0\\ \mathbf{elif}\;x \leq 5.05 \cdot 10^{+157}:\\ \;\;\;\;\frac{\left(x + 4\right) - x \cdot z}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (let* ((t_0 (/ (+ x 4.0) y_m)))
   (if (<= x -1.7e-37)
     (- (* x (/ z y_m)) t_0)
     (if (<= x 5.05e+157) (/ (- (+ x 4.0) (* x z)) y_m) t_0))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double t_0 = (x + 4.0) / y_m;
	double tmp;
	if (x <= -1.7e-37) {
		tmp = (x * (z / y_m)) - t_0;
	} else if (x <= 5.05e+157) {
		tmp = ((x + 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 = (x + 4.0d0) / y_m
    if (x <= (-1.7d-37)) then
        tmp = (x * (z / y_m)) - t_0
    else if (x <= 5.05d+157) then
        tmp = ((x + 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 = (x + 4.0) / y_m;
	double tmp;
	if (x <= -1.7e-37) {
		tmp = (x * (z / y_m)) - t_0;
	} else if (x <= 5.05e+157) {
		tmp = ((x + 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 = (x + 4.0) / y_m
	tmp = 0
	if x <= -1.7e-37:
		tmp = (x * (z / y_m)) - t_0
	elif x <= 5.05e+157:
		tmp = ((x + 4.0) - (x * z)) / y_m
	else:
		tmp = t_0
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	t_0 = Float64(Float64(x + 4.0) / y_m)
	tmp = 0.0
	if (x <= -1.7e-37)
		tmp = Float64(Float64(x * Float64(z / y_m)) - t_0);
	elseif (x <= 5.05e+157)
		tmp = Float64(Float64(Float64(x + 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 = (x + 4.0) / y_m;
	tmp = 0.0;
	if (x <= -1.7e-37)
		tmp = (x * (z / y_m)) - t_0;
	elseif (x <= 5.05e+157)
		tmp = ((x + 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[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]}, If[LessEqual[x, -1.7e-37], N[(N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 5.05e+157], N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision], t$95$0]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
t_0 := \frac{x + 4}{y\_m}\\
\mathbf{if}\;x \leq -1.7 \cdot 10^{-37}:\\
\;\;\;\;x \cdot \frac{z}{y\_m} - t\_0\\

\mathbf{elif}\;x \leq 5.05 \cdot 10^{+157}:\\
\;\;\;\;\frac{\left(x + 4\right) - x \cdot z}{y\_m}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.70000000000000009e-37

    1. Initial program 89.2%

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      3. cancel-sign-sub-inv89.0%

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

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

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

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

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

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

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

        \[\leadsto \left|x \cdot \frac{z}{y} + \color{blue}{\frac{-4 - x}{y}}\right| \]
      11. fma-undefine96.8%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}\right| \]
      12. add-sqr-sqrt56.6%

        \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
      13. fabs-sqr56.6%

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
      14. add-sqr-sqrt57.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      15. fma-undefine55.6%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      16. associate-*r/51.3%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      17. associate-*l/52.6%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      18. div-inv52.5%

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

      \[\leadsto \color{blue}{x \cdot \frac{z}{y} - \frac{x + 4}{y}} \]

    if -1.70000000000000009e-37 < x < 5.04999999999999988e157

    1. Initial program 96.3%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt43.5%

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

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      3. add-sqr-sqrt44.7%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      4. sub-neg44.7%

        \[\leadsto \color{blue}{\frac{x + 4}{y} + \left(-\frac{x}{y} \cdot z\right)} \]
      5. +-commutative44.7%

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

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

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

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

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

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{-y} \]
      11. metadata-eval44.1%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{-4} + \left(-x\right)}{-y} \]
      12. sub-neg44.1%

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

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

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine44.1%

        \[\leadsto -\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      16. neg-sub044.1%

        \[\leadsto \color{blue}{0 - \mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      17. fma-undefine44.1%

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

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

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

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

    if 5.04999999999999988e157 < x

    1. Initial program 75.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub75.7%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac93.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative93.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in93.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg93.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval93.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified93.9%

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

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    8. Step-by-step derivation
      1. add-sqr-sqrt73.6%

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(-\frac{-4 - x}{y}\right) \cdot \left(-\frac{-4 - x}{y}\right)}} \]
      6. distribute-frac-neg274.7%

        \[\leadsto \sqrt{\color{blue}{\frac{-4 - x}{-y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      7. sub-neg74.7%

        \[\leadsto \sqrt{\frac{\color{blue}{-4 + \left(-x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      8. metadata-eval74.7%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      9. distribute-neg-in74.7%

        \[\leadsto \sqrt{\frac{\color{blue}{-\left(4 + x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      10. +-commutative74.7%

        \[\leadsto \sqrt{\frac{-\color{blue}{\left(x + 4\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      11. frac-2neg74.7%

        \[\leadsto \sqrt{\color{blue}{\frac{x + 4}{y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      12. distribute-frac-neg274.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{-4 - x}{-y}}} \]
      13. sub-neg74.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-4 + \left(-x\right)}}{-y}} \]
      14. metadata-eval74.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y}} \]
      15. distribute-neg-in74.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-\left(4 + x\right)}}{-y}} \]
      16. +-commutative74.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{-\color{blue}{\left(x + 4\right)}}{-y}} \]
      17. frac-2neg74.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{x + 4}{y}}} \]
      18. sqrt-unprod38.0%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}} \]
      19. add-sqr-sqrt38.4%

        \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
    9. Applied egg-rr38.4%

      \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification47.8%

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

Alternative 11: 78.6% accurate, 5.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{-37}:\\
\;\;\;\;x \cdot \frac{z + -1}{y\_m}\\

\mathbf{elif}\;x \leq 8 \cdot 10^{+156}:\\
\;\;\;\;\frac{\left(x + 4\right) - x \cdot z}{y\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + 4}{y\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.70000000000000009e-37

    1. Initial program 89.2%

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      3. cancel-sign-sub-inv89.0%

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

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

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

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

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

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

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

        \[\leadsto \left|x \cdot \frac{z}{y} + \color{blue}{\frac{-4 - x}{y}}\right| \]
      11. fma-undefine96.8%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}\right| \]
      12. add-sqr-sqrt56.6%

        \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
      13. fabs-sqr56.6%

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
      14. add-sqr-sqrt57.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      15. fma-undefine55.6%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      16. associate-*r/51.3%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      17. associate-*l/52.6%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      18. div-inv52.5%

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

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

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
      2. sub-div54.4%

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{z - 1}{y}} \]
      2. sub-neg58.1%

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

        \[\leadsto x \cdot \frac{z + \color{blue}{-1}}{y} \]
    9. Simplified58.1%

      \[\leadsto \color{blue}{x \cdot \frac{z + -1}{y}} \]

    if -1.70000000000000009e-37 < x < 7.9999999999999999e156

    1. Initial program 96.3%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt43.5%

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

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      3. add-sqr-sqrt44.7%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      4. sub-neg44.7%

        \[\leadsto \color{blue}{\frac{x + 4}{y} + \left(-\frac{x}{y} \cdot z\right)} \]
      5. +-commutative44.7%

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

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

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

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

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

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{-y} \]
      11. metadata-eval44.1%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{-4} + \left(-x\right)}{-y} \]
      12. sub-neg44.1%

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

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

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine44.1%

        \[\leadsto -\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      16. neg-sub044.1%

        \[\leadsto \color{blue}{0 - \mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      17. fma-undefine44.1%

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

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

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

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

    if 7.9999999999999999e156 < x

    1. Initial program 75.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub75.7%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac93.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative93.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in93.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg93.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval93.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified93.9%

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

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    8. Step-by-step derivation
      1. add-sqr-sqrt73.6%

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(-\frac{-4 - x}{y}\right) \cdot \left(-\frac{-4 - x}{y}\right)}} \]
      6. distribute-frac-neg274.7%

        \[\leadsto \sqrt{\color{blue}{\frac{-4 - x}{-y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      7. sub-neg74.7%

        \[\leadsto \sqrt{\frac{\color{blue}{-4 + \left(-x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      8. metadata-eval74.7%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      9. distribute-neg-in74.7%

        \[\leadsto \sqrt{\frac{\color{blue}{-\left(4 + x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      10. +-commutative74.7%

        \[\leadsto \sqrt{\frac{-\color{blue}{\left(x + 4\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      11. frac-2neg74.7%

        \[\leadsto \sqrt{\color{blue}{\frac{x + 4}{y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      12. distribute-frac-neg274.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{-4 - x}{-y}}} \]
      13. sub-neg74.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-4 + \left(-x\right)}}{-y}} \]
      14. metadata-eval74.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y}} \]
      15. distribute-neg-in74.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-\left(4 + x\right)}}{-y}} \]
      16. +-commutative74.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{-\color{blue}{\left(x + 4\right)}}{-y}} \]
      17. frac-2neg74.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{x + 4}{y}}} \]
      18. sqrt-unprod38.0%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}} \]
      19. add-sqr-sqrt38.4%

        \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
    9. Applied egg-rr38.4%

      \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification48.4%

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

Alternative 12: 60.2% accurate, 8.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -1.7 \cdot 10^{-37}:\\ \;\;\;\;x \cdot \frac{z}{y\_m}\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\frac{4}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x -1.7e-37) (* x (/ z y_m)) (if (<= x 4.0) (/ 4.0 y_m) (/ x y_m))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -1.7e-37) {
		tmp = x * (z / y_m);
	} else if (x <= 4.0) {
		tmp = 4.0 / y_m;
	} else {
		tmp = x / 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.7d-37)) then
        tmp = x * (z / y_m)
    else if (x <= 4.0d0) then
        tmp = 4.0d0 / y_m
    else
        tmp = x / 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.7e-37) {
		tmp = x * (z / y_m);
	} else if (x <= 4.0) {
		tmp = 4.0 / y_m;
	} else {
		tmp = x / y_m;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= -1.7e-37:
		tmp = x * (z / y_m)
	elif x <= 4.0:
		tmp = 4.0 / y_m
	else:
		tmp = x / y_m
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= -1.7e-37)
		tmp = Float64(x * Float64(z / y_m));
	elseif (x <= 4.0)
		tmp = Float64(4.0 / y_m);
	else
		tmp = Float64(x / y_m);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= -1.7e-37)
		tmp = x * (z / y_m);
	elseif (x <= 4.0)
		tmp = 4.0 / y_m;
	else
		tmp = x / y_m;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, -1.7e-37], N[(x * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.0], N[(4.0 / y$95$m), $MachinePrecision], N[(x / y$95$m), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{-37}:\\
\;\;\;\;x \cdot \frac{z}{y\_m}\\

\mathbf{elif}\;x \leq 4:\\
\;\;\;\;\frac{4}{y\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{y\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.70000000000000009e-37

    1. Initial program 89.2%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt36.7%

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

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      3. add-sqr-sqrt37.6%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      4. associate-*l/39.2%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      5. associate-*r/40.6%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}} \]
    4. Applied egg-rr40.6%

      \[\leadsto \color{blue}{\frac{x + 4}{y} - x \cdot \frac{z}{y}} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt18.7%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}{y} \]
      2. sqrt-unprod41.1%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{\sqrt{z \cdot z}}}{y} \]
      3. sqr-neg41.1%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\sqrt{\color{blue}{\left(-z\right) \cdot \left(-z\right)}}}{y} \]
      4. sqrt-unprod25.3%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}}{y} \]
      5. add-sqr-sqrt50.1%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{-z}}{y} \]
      6. distribute-frac-neg50.1%

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

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

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

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

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{\frac{y}{z}}} \]
    6. Applied egg-rr50.1%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{\frac{y}{z}}} \]
    7. Taylor expanded in z around inf 25.7%

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} \]
    8. Step-by-step derivation
      1. associate-*r/30.0%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y}} \]
    9. Simplified30.0%

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

    if -1.70000000000000009e-37 < x < 4

    1. Initial program 96.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt44.4%

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

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      3. add-sqr-sqrt45.8%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      4. associate-*l/48.1%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      5. associate-*r/44.0%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}} \]
    4. Applied egg-rr44.0%

      \[\leadsto \color{blue}{\frac{x + 4}{y} - x \cdot \frac{z}{y}} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt20.7%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}{y} \]
      2. sqrt-unprod38.3%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{\sqrt{z \cdot z}}}{y} \]
      3. sqr-neg38.3%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\sqrt{\color{blue}{\left(-z\right) \cdot \left(-z\right)}}}{y} \]
      4. sqrt-unprod22.5%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}}{y} \]
      5. add-sqr-sqrt42.2%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{-z}}{y} \]
      6. distribute-frac-neg42.2%

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

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

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

        \[\leadsto \frac{x + 4}{y} - \left(-x\right) \cdot \color{blue}{\frac{1}{\frac{y}{z}}} \]
      10. un-div-inv42.6%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{\frac{y}{z}}} \]
    6. Applied egg-rr42.6%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{\frac{y}{z}}} \]
    7. Taylor expanded in x around 0 37.7%

      \[\leadsto \color{blue}{\frac{4}{y}} \]

    if 4 < x

    1. Initial program 87.3%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub87.3%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac97.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative97.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in97.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg97.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval97.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified97.1%

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

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    8. Step-by-step derivation
      1. add-sqr-sqrt58.3%

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(-\frac{-4 - x}{y}\right) \cdot \left(-\frac{-4 - x}{y}\right)}} \]
      6. distribute-frac-neg266.7%

        \[\leadsto \sqrt{\color{blue}{\frac{-4 - x}{-y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      7. sub-neg66.7%

        \[\leadsto \sqrt{\frac{\color{blue}{-4 + \left(-x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      8. metadata-eval66.7%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      9. distribute-neg-in66.7%

        \[\leadsto \sqrt{\frac{\color{blue}{-\left(4 + x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      10. +-commutative66.7%

        \[\leadsto \sqrt{\frac{-\color{blue}{\left(x + 4\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      11. frac-2neg66.7%

        \[\leadsto \sqrt{\color{blue}{\frac{x + 4}{y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      12. distribute-frac-neg266.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{-4 - x}{-y}}} \]
      13. sub-neg66.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-4 + \left(-x\right)}}{-y}} \]
      14. metadata-eval66.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y}} \]
      15. distribute-neg-in66.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-\left(4 + x\right)}}{-y}} \]
      16. +-commutative66.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{-\color{blue}{\left(x + 4\right)}}{-y}} \]
      17. frac-2neg66.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{x + 4}{y}}} \]
      18. sqrt-unprod30.8%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}} \]
      19. add-sqr-sqrt31.4%

        \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
      20. clear-num31.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{x + 4}}} \]
    9. Applied egg-rr31.3%

      \[\leadsto \color{blue}{\frac{1}{\frac{y}{x + 4}}} \]
    10. Taylor expanded in x around inf 31.1%

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

Alternative 13: 71.6% accurate, 9.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{-37}:\\
\;\;\;\;x \cdot \frac{z + -1}{y\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + 4}{y\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.70000000000000009e-37

    1. Initial program 89.2%

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      3. cancel-sign-sub-inv89.0%

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

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

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

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

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

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

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

        \[\leadsto \left|x \cdot \frac{z}{y} + \color{blue}{\frac{-4 - x}{y}}\right| \]
      11. fma-undefine96.8%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}\right| \]
      12. add-sqr-sqrt56.6%

        \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
      13. fabs-sqr56.6%

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
      14. add-sqr-sqrt57.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      15. fma-undefine55.6%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      16. associate-*r/51.3%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      17. associate-*l/52.6%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      18. div-inv52.5%

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

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

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
      2. sub-div54.4%

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{z - 1}{y}} \]
      2. sub-neg58.1%

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

        \[\leadsto x \cdot \frac{z + \color{blue}{-1}}{y} \]
    9. Simplified58.1%

      \[\leadsto \color{blue}{x \cdot \frac{z + -1}{y}} \]

    if -1.70000000000000009e-37 < x

    1. Initial program 92.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub92.7%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac93.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative93.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in93.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg93.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval93.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified93.5%

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

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    8. Step-by-step derivation
      1. add-sqr-sqrt71.7%

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

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

        \[\leadsto \sqrt{\color{blue}{\left|-\frac{-4 - x}{y}\right|} \cdot \left|\frac{-4 - x}{y}\right|} \]
      4. neg-fabs54.8%

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

        \[\leadsto \sqrt{\color{blue}{\left(-\frac{-4 - x}{y}\right) \cdot \left(-\frac{-4 - x}{y}\right)}} \]
      6. distribute-frac-neg254.8%

        \[\leadsto \sqrt{\color{blue}{\frac{-4 - x}{-y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      7. sub-neg54.8%

        \[\leadsto \sqrt{\frac{\color{blue}{-4 + \left(-x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      8. metadata-eval54.8%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      9. distribute-neg-in54.8%

        \[\leadsto \sqrt{\frac{\color{blue}{-\left(4 + x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      10. +-commutative54.8%

        \[\leadsto \sqrt{\frac{-\color{blue}{\left(x + 4\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      11. frac-2neg54.8%

        \[\leadsto \sqrt{\color{blue}{\frac{x + 4}{y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      12. distribute-frac-neg254.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{-4 - x}{-y}}} \]
      13. sub-neg54.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-4 + \left(-x\right)}}{-y}} \]
      14. metadata-eval54.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y}} \]
      15. distribute-neg-in54.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-\left(4 + x\right)}}{-y}} \]
      16. +-commutative54.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{-\color{blue}{\left(x + 4\right)}}{-y}} \]
      17. frac-2neg54.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{x + 4}{y}}} \]
      18. sqrt-unprod34.2%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}} \]
      19. add-sqr-sqrt35.3%

        \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
    9. Applied egg-rr35.3%

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

Alternative 14: 70.1% accurate, 11.1× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{-4 - x}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (<= x -4.0) (/ (- -4.0 x) y_m) (/ (+ x 4.0) y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = (-4.0 - x) / y_m;
	} else {
		tmp = (x + 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 <= (-4.0d0)) then
        tmp = ((-4.0d0) - x) / y_m
    else
        tmp = (x + 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 <= -4.0) {
		tmp = (-4.0 - x) / y_m;
	} else {
		tmp = (x + 4.0) / y_m;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= -4.0:
		tmp = (-4.0 - x) / y_m
	else:
		tmp = (x + 4.0) / y_m
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= -4.0)
		tmp = Float64(Float64(-4.0 - x) / y_m);
	else
		tmp = Float64(Float64(x + 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 <= -4.0)
		tmp = (-4.0 - x) / y_m;
	else
		tmp = (x + 4.0) / y_m;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, -4.0], N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision], N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;\frac{-4 - x}{y\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + 4}{y\_m}\\


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

    1. Initial program 88.3%

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

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

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      3. cancel-sign-sub-inv88.1%

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

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

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

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

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

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}\right| \]
      12. add-sqr-sqrt58.0%

        \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
      13. fabs-sqr58.0%

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
      14. add-sqr-sqrt58.6%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      15. fma-undefine56.9%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      16. associate-*r/52.3%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      17. associate-*l/53.6%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      18. div-inv53.5%

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

      \[\leadsto \color{blue}{x \cdot \frac{z}{y} - \frac{x + 4}{y}} \]
    5. Taylor expanded in z around 0 36.4%

      \[\leadsto \color{blue}{-1 \cdot \left(4 \cdot \frac{1}{y} + \frac{x}{y}\right)} \]
    6. Step-by-step derivation
      1. mul-1-neg36.4%

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

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

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

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

        \[\leadsto -\color{blue}{\frac{1}{y} \cdot \left(4 + x\right)} \]
      6. +-commutative36.4%

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

        \[\leadsto -\color{blue}{\frac{1 \cdot \left(x + 4\right)}{y}} \]
      8. *-lft-identity36.5%

        \[\leadsto -\frac{\color{blue}{x + 4}}{y} \]
      9. distribute-frac-neg36.5%

        \[\leadsto \color{blue}{\frac{-\left(x + 4\right)}{y}} \]
      10. +-commutative36.5%

        \[\leadsto \frac{-\color{blue}{\left(4 + x\right)}}{y} \]
      11. mul-1-neg36.5%

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

        \[\leadsto \frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y} \]
      13. metadata-eval36.5%

        \[\leadsto \frac{\color{blue}{-4} + -1 \cdot x}{y} \]
      14. mul-1-neg36.5%

        \[\leadsto \frac{-4 + \color{blue}{\left(-x\right)}}{y} \]
      15. unsub-neg36.5%

        \[\leadsto \frac{\color{blue}{-4 - x}}{y} \]
    7. Simplified36.5%

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

    if -4 < x

    1. Initial program 92.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub92.9%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac93.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative93.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in93.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg93.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval93.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified93.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(-\frac{-4 - x}{y}\right) \cdot \left(-\frac{-4 - x}{y}\right)}} \]
      6. distribute-frac-neg254.5%

        \[\leadsto \sqrt{\color{blue}{\frac{-4 - x}{-y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      7. sub-neg54.5%

        \[\leadsto \sqrt{\frac{\color{blue}{-4 + \left(-x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      8. metadata-eval54.5%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      9. distribute-neg-in54.5%

        \[\leadsto \sqrt{\frac{\color{blue}{-\left(4 + x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      10. +-commutative54.5%

        \[\leadsto \sqrt{\frac{-\color{blue}{\left(x + 4\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      11. frac-2neg54.5%

        \[\leadsto \sqrt{\color{blue}{\frac{x + 4}{y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      12. distribute-frac-neg254.5%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{-4 - x}{-y}}} \]
      13. sub-neg54.5%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-4 + \left(-x\right)}}{-y}} \]
      14. metadata-eval54.5%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y}} \]
      15. distribute-neg-in54.5%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-\left(4 + x\right)}}{-y}} \]
      16. +-commutative54.5%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{-\color{blue}{\left(x + 4\right)}}{-y}} \]
      17. frac-2neg54.5%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{x + 4}{y}}} \]
      18. sqrt-unprod33.9%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}} \]
      19. add-sqr-sqrt35.0%

        \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
    9. Applied egg-rr35.0%

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

Alternative 15: 60.8% accurate, 11.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{-37}:\\
\;\;\;\;x \cdot \frac{z}{y\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + 4}{y\_m}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.70000000000000009e-37

    1. Initial program 89.2%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt36.7%

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

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      3. add-sqr-sqrt37.6%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      4. associate-*l/39.2%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      5. associate-*r/40.6%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}} \]
    4. Applied egg-rr40.6%

      \[\leadsto \color{blue}{\frac{x + 4}{y} - x \cdot \frac{z}{y}} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt18.7%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}{y} \]
      2. sqrt-unprod41.1%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{\sqrt{z \cdot z}}}{y} \]
      3. sqr-neg41.1%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\sqrt{\color{blue}{\left(-z\right) \cdot \left(-z\right)}}}{y} \]
      4. sqrt-unprod25.3%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}}{y} \]
      5. add-sqr-sqrt50.1%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{-z}}{y} \]
      6. distribute-frac-neg50.1%

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

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

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

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

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{\frac{y}{z}}} \]
    6. Applied egg-rr50.1%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{\frac{y}{z}}} \]
    7. Taylor expanded in z around inf 25.7%

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} \]
    8. Step-by-step derivation
      1. associate-*r/30.0%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y}} \]
    9. Simplified30.0%

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

    if -1.70000000000000009e-37 < x

    1. Initial program 92.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub92.7%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac93.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative93.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in93.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg93.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval93.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified93.5%

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

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    8. Step-by-step derivation
      1. add-sqr-sqrt71.7%

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

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

        \[\leadsto \sqrt{\color{blue}{\left|-\frac{-4 - x}{y}\right|} \cdot \left|\frac{-4 - x}{y}\right|} \]
      4. neg-fabs54.8%

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

        \[\leadsto \sqrt{\color{blue}{\left(-\frac{-4 - x}{y}\right) \cdot \left(-\frac{-4 - x}{y}\right)}} \]
      6. distribute-frac-neg254.8%

        \[\leadsto \sqrt{\color{blue}{\frac{-4 - x}{-y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      7. sub-neg54.8%

        \[\leadsto \sqrt{\frac{\color{blue}{-4 + \left(-x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      8. metadata-eval54.8%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      9. distribute-neg-in54.8%

        \[\leadsto \sqrt{\frac{\color{blue}{-\left(4 + x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      10. +-commutative54.8%

        \[\leadsto \sqrt{\frac{-\color{blue}{\left(x + 4\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      11. frac-2neg54.8%

        \[\leadsto \sqrt{\color{blue}{\frac{x + 4}{y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      12. distribute-frac-neg254.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{-4 - x}{-y}}} \]
      13. sub-neg54.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-4 + \left(-x\right)}}{-y}} \]
      14. metadata-eval54.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y}} \]
      15. distribute-neg-in54.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-\left(4 + x\right)}}{-y}} \]
      16. +-commutative54.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{-\color{blue}{\left(x + 4\right)}}{-y}} \]
      17. frac-2neg54.8%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{x + 4}{y}}} \]
      18. sqrt-unprod34.2%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}} \]
      19. add-sqr-sqrt35.3%

        \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
    9. Applied egg-rr35.3%

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

Alternative 16: 55.4% accurate, 13.8× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq 4:\\ \;\;\;\;\frac{4}{y\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y\_m}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z) :precision binary64 (if (<= x 4.0) (/ 4.0 y_m) (/ x y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= 4.0) {
		tmp = 4.0 / y_m;
	} else {
		tmp = x / 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 <= 4.0d0) then
        tmp = 4.0d0 / y_m
    else
        tmp = x / 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 <= 4.0) {
		tmp = 4.0 / y_m;
	} else {
		tmp = x / y_m;
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if x <= 4.0:
		tmp = 4.0 / y_m
	else:
		tmp = x / y_m
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if (x <= 4.0)
		tmp = Float64(4.0 / y_m);
	else
		tmp = Float64(x / y_m);
	end
	return tmp
end
y_m = abs(y);
function tmp_2 = code(x, y_m, z)
	tmp = 0.0;
	if (x <= 4.0)
		tmp = 4.0 / y_m;
	else
		tmp = x / y_m;
	end
	tmp_2 = tmp;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := If[LessEqual[x, 4.0], N[(4.0 / y$95$m), $MachinePrecision], N[(x / y$95$m), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

\\
\begin{array}{l}
\mathbf{if}\;x \leq 4:\\
\;\;\;\;\frac{4}{y\_m}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{y\_m}\\


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

    1. Initial program 93.6%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt41.7%

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

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      3. add-sqr-sqrt42.9%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      4. associate-*l/45.0%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      5. associate-*r/42.8%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}} \]
    4. Applied egg-rr42.8%

      \[\leadsto \color{blue}{\frac{x + 4}{y} - x \cdot \frac{z}{y}} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt20.0%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}{y} \]
      2. sqrt-unprod39.3%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{\sqrt{z \cdot z}}}{y} \]
      3. sqr-neg39.3%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\sqrt{\color{blue}{\left(-z\right) \cdot \left(-z\right)}}}{y} \]
      4. sqrt-unprod23.5%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}}{y} \]
      5. add-sqr-sqrt45.0%

        \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{-z}}{y} \]
      6. distribute-frac-neg45.0%

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

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

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

        \[\leadsto \frac{x + 4}{y} - \left(-x\right) \cdot \color{blue}{\frac{1}{\frac{y}{z}}} \]
      10. un-div-inv45.2%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{\frac{y}{z}}} \]
    6. Applied egg-rr45.2%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{\frac{y}{z}}} \]
    7. Taylor expanded in x around 0 26.2%

      \[\leadsto \color{blue}{\frac{4}{y}} \]

    if 4 < x

    1. Initial program 87.3%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub87.3%

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

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

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

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac97.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative97.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in97.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg97.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval97.1%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified97.1%

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

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

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

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

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

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

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

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    8. Step-by-step derivation
      1. add-sqr-sqrt58.3%

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{\left(-\frac{-4 - x}{y}\right) \cdot \left(-\frac{-4 - x}{y}\right)}} \]
      6. distribute-frac-neg266.7%

        \[\leadsto \sqrt{\color{blue}{\frac{-4 - x}{-y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      7. sub-neg66.7%

        \[\leadsto \sqrt{\frac{\color{blue}{-4 + \left(-x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      8. metadata-eval66.7%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      9. distribute-neg-in66.7%

        \[\leadsto \sqrt{\frac{\color{blue}{-\left(4 + x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      10. +-commutative66.7%

        \[\leadsto \sqrt{\frac{-\color{blue}{\left(x + 4\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      11. frac-2neg66.7%

        \[\leadsto \sqrt{\color{blue}{\frac{x + 4}{y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      12. distribute-frac-neg266.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{-4 - x}{-y}}} \]
      13. sub-neg66.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-4 + \left(-x\right)}}{-y}} \]
      14. metadata-eval66.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y}} \]
      15. distribute-neg-in66.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-\left(4 + x\right)}}{-y}} \]
      16. +-commutative66.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{-\color{blue}{\left(x + 4\right)}}{-y}} \]
      17. frac-2neg66.7%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{x + 4}{y}}} \]
      18. sqrt-unprod30.8%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}} \]
      19. add-sqr-sqrt31.4%

        \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
      20. clear-num31.3%

        \[\leadsto \color{blue}{\frac{1}{\frac{y}{x + 4}}} \]
    9. Applied egg-rr31.3%

      \[\leadsto \color{blue}{\frac{1}{\frac{y}{x + 4}}} \]
    10. Taylor expanded in x around inf 31.1%

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

Alternative 17: 41.0% accurate, 37.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \frac{4}{y\_m} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z) :precision binary64 (/ 4.0 y_m))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	return 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 = 4.0d0 / y_m
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z) {
	return 4.0 / y_m;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	return 4.0 / y_m
y_m = abs(y)
function code(x, y_m, z)
	return Float64(4.0 / y_m)
end
y_m = abs(y);
function tmp = code(x, y_m, z)
	tmp = 4.0 / y_m;
end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_] := N[(4.0 / y$95$m), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|

\\
\frac{4}{y\_m}
\end{array}
Derivation
  1. Initial program 91.8%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-sqr-sqrt39.3%

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

      \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
    3. add-sqr-sqrt40.3%

      \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
    4. associate-*l/41.8%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
    5. associate-*r/41.1%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}} \]
  4. Applied egg-rr41.1%

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

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

      \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{\sqrt{z \cdot z}}}{y} \]
    3. sqr-neg37.8%

      \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\sqrt{\color{blue}{\left(-z\right) \cdot \left(-z\right)}}}{y} \]
    4. sqrt-unprod22.8%

      \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{\sqrt{-z} \cdot \sqrt{-z}}}{y} \]
    5. add-sqr-sqrt47.9%

      \[\leadsto \frac{x + 4}{y} - x \cdot \frac{\color{blue}{-z}}{y} \]
    6. distribute-frac-neg47.9%

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

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\left(-x \cdot \frac{z}{y}\right)} \]
    8. distribute-lft-neg-in47.9%

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

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

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{\frac{y}{z}}} \]
  6. Applied egg-rr48.1%

    \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{-x}{\frac{y}{z}}} \]
  7. Taylor expanded in x around 0 19.8%

    \[\leadsto \color{blue}{\frac{4}{y}} \]
  8. Add Preprocessing

Reproduce

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