fabs fraction 1

Percentage Accurate: 91.6% → 99.7%
Time: 14.9s
Alternatives: 19
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 19 alternatives:

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

Initial Program: 91.6% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 1.0× speedup?

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

    1. Initial program 92.6%

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

      \[\leadsto \color{blue}{\left|\frac{-1}{y} \cdot \mathsf{fma}\left(x, z, -4 - x\right)\right|} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. fma-undefine97.3%

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

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

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

    if 9.9999999999999996e-39 < y

    1. Initial program 97.1%

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

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

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

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

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

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

Alternative 2: 91.6% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 91.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4 < x < 7.80000000000000013e-57

    1. Initial program 96.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt49.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-sqr49.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-sqrt51.1%

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

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

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

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

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      2. clear-num52.0%

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

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

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

Alternative 3: 98.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 93.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2e20 < x

    1. Initial program 94.1%

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

      \[\leadsto \color{blue}{\left|\frac{-1}{y} \cdot \mathsf{fma}\left(x, z, -4 - x\right)\right|} \]
    3. Add Preprocessing
    4. Step-by-step derivation
      1. fma-undefine98.4%

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

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

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

Alternative 4: 85.5% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;z \leq -1.4 \cdot 10^{+23} \lor \neg \left(z \leq 9 \cdot 10^{+62}\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 -1.4e+23) (not (<= z 9e+62)))
   (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 <= -1.4e+23) || !(z <= 9e+62)) {
		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 <= (-1.4d+23)) .or. (.not. (z <= 9d+62))) 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 <= -1.4e+23) || !(z <= 9e+62)) {
		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 <= -1.4e+23) or not (z <= 9e+62):
		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 <= -1.4e+23) || !(z <= 9e+62))
		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 <= -1.4e+23) || ~((z <= 9e+62)))
		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, -1.4e+23], N[Not[LessEqual[z, 9e+62]], $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 -1.4 \cdot 10^{+23} \lor \neg \left(z \leq 9 \cdot 10^{+62}\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 < -1.4e23 or 8.99999999999999997e62 < z

    1. Initial program 90.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Simplified93.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 73.0%

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

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

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

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

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

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

    if -1.4e23 < z < 8.99999999999999997e62

    1. Initial program 95.9%

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

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

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

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fma-neg100.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 95.8%

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

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

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

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

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

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

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

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

Alternative 5: 84.7% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;z \leq -9.2 \cdot 10^{+22}:\\ \;\;\;\;\left|\frac{x \cdot z}{y\_m}\right|\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{+68}:\\ \;\;\;\;\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 -9.2e+22)
   (fabs (/ (* x z) y_m))
   (if (<= z 2.4e+68) (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 <= -9.2e+22) {
		tmp = fabs(((x * z) / y_m));
	} else if (z <= 2.4e+68) {
		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 <= (-9.2d+22)) then
        tmp = abs(((x * z) / y_m))
    else if (z <= 2.4d+68) 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 <= -9.2e+22) {
		tmp = Math.abs(((x * z) / y_m));
	} else if (z <= 2.4e+68) {
		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 <= -9.2e+22:
		tmp = math.fabs(((x * z) / y_m))
	elif z <= 2.4e+68:
		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 <= -9.2e+22)
		tmp = abs(Float64(Float64(x * z) / y_m));
	elseif (z <= 2.4e+68)
		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 <= -9.2e+22)
		tmp = abs(((x * z) / y_m));
	elseif (z <= 2.4e+68)
		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, -9.2e+22], N[Abs[N[(N[(x * z), $MachinePrecision] / y$95$m), $MachinePrecision]], $MachinePrecision], If[LessEqual[z, 2.4e+68], 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 -9.2 \cdot 10^{+22}:\\
\;\;\;\;\left|\frac{x \cdot z}{y\_m}\right|\\

\mathbf{elif}\;z \leq 2.4 \cdot 10^{+68}:\\
\;\;\;\;\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 < -9.2000000000000008e22

    1. Initial program 96.3%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Simplified97.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 z around inf 74.2%

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

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

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

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

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

    if -9.2000000000000008e22 < z < 2.40000000000000008e68

    1. Initial program 95.9%

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

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

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

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fma-neg100.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 95.8%

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

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

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

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

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

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

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

    if 2.40000000000000008e68 < z

    1. Initial program 85.9%

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

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

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

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

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

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

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

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

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

Alternative 6: 77.7% accurate, 1.0× speedup?

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

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

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

\mathbf{elif}\;z \leq 3.5 \cdot 10^{+182}:\\
\;\;\;\;\frac{4}{y\_m} - x \cdot \frac{z}{y\_m}\\

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


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

    1. Initial program 96.2%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt57.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-sqr57.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-sqrt58.0%

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

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

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

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

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

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

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

    if -4.29999999999999987e24 < z < 4.1e21

    1. Initial program 95.7%

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

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

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

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fma-neg100.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 96.2%

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

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

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

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

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

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

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

    if 4.1e21 < z < 3.50000000000000023e182

    1. Initial program 94.2%

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

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

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

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

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

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

    if 3.50000000000000023e182 < z

    1. Initial program 81.2%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt49.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-sqr49.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-sqrt50.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0 - \color{blue}{\frac{x \cdot z}{y}} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt53.9%

        \[\leadsto \color{blue}{\sqrt{0 - \frac{x \cdot z}{y}} \cdot \sqrt{0 - \frac{x \cdot z}{y}}} \]
      2. sqrt-unprod76.4%

        \[\leadsto \color{blue}{\sqrt{\left(0 - \frac{x \cdot z}{y}\right) \cdot \left(0 - \frac{x \cdot z}{y}\right)}} \]
      3. associate-*r/76.3%

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{x \cdot \frac{z}{y}} \cdot \sqrt{x \cdot \frac{z}{y}}} \]
      9. add-sqr-sqrt28.5%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y}} \]
      10. *-commutative28.5%

        \[\leadsto \color{blue}{\frac{z}{y} \cdot x} \]
      11. associate-/r/25.7%

        \[\leadsto \color{blue}{\frac{z}{\frac{y}{x}}} \]
      12. div-inv25.6%

        \[\leadsto \frac{z}{\color{blue}{y \cdot \frac{1}{x}}} \]
      13. associate-/r*28.5%

        \[\leadsto \color{blue}{\frac{\frac{z}{y}}{\frac{1}{x}}} \]
    7. Applied egg-rr28.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.3 \cdot 10^{+24}:\\ \;\;\;\;\frac{x + 4}{y} + \frac{-1}{\frac{y}{x \cdot z}}\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{+21}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{+182}:\\ \;\;\;\;\frac{4}{y} - x \cdot \frac{z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{z}{y}}{\frac{1}{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 60.6% accurate, 5.5× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{z}{\frac{y\_m}{x}}\\
\mathbf{if}\;x \leq -0.66:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 6.8 \cdot 10^{-18}:\\
\;\;\;\;\frac{4}{y\_m}\\

\mathbf{elif}\;x \leq 2.95 \cdot 10^{+32}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -0.660000000000000031 or 6.80000000000000002e-18 < x < 2.94999999999999983e32

    1. Initial program 94.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt38.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-sqr38.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-sqrt39.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0 - \color{blue}{\frac{x \cdot z}{y}} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt24.8%

        \[\leadsto \color{blue}{\sqrt{0 - \frac{x \cdot z}{y}} \cdot \sqrt{0 - \frac{x \cdot z}{y}}} \]
      2. sqrt-unprod42.5%

        \[\leadsto \color{blue}{\sqrt{\left(0 - \frac{x \cdot z}{y}\right) \cdot \left(0 - \frac{x \cdot z}{y}\right)}} \]
      3. associate-*r/42.5%

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

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

        \[\leadsto \sqrt{\left(-x \cdot \frac{z}{y}\right) \cdot \left(0 - \color{blue}{x \cdot \frac{z}{y}}\right)} \]
      6. neg-sub046.4%

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{z}{y}} \]
      10. *-commutative28.4%

        \[\leadsto \color{blue}{\frac{z}{y} \cdot x} \]
      11. associate-/r/32.1%

        \[\leadsto \color{blue}{\frac{z}{\frac{y}{x}}} \]
    7. Applied egg-rr32.1%

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

    if -0.660000000000000031 < x < 6.80000000000000002e-18

    1. Initial program 97.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt47.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-sqr47.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-sqrt49.1%

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

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

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

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

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      2. clear-num50.0%

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

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{1}{\frac{y}{x \cdot z}}} \]
    7. Step-by-step derivation
      1. div-inv50.0%

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

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

      \[\leadsto \frac{x + 4}{y} - \frac{1}{\color{blue}{y \cdot \frac{1}{z \cdot x}}} \]
    9. Step-by-step derivation
      1. *-commutative50.0%

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

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

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

        \[\leadsto \frac{x + 4}{y} - \frac{1}{\color{blue}{\frac{1 \cdot \frac{y}{x}}{z}}} \]
      5. *-lft-identity49.1%

        \[\leadsto \frac{x + 4}{y} - \frac{1}{\frac{\color{blue}{\frac{y}{x}}}{z}} \]
    10. Simplified49.1%

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

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

    if 2.94999999999999983e32 < x

    1. Initial program 86.1%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt49.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-sqr49.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-sqrt50.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - \frac{\color{blue}{-4} + -1 \cdot x}{y} \]
      4. neg-mul-130.0%

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

        \[\leadsto 0 - \frac{\color{blue}{-4 - x}}{y} \]
    7. Simplified30.0%

      \[\leadsto 0 - \color{blue}{\frac{-4 - x}{y}} \]
    8. Taylor expanded in x around inf 30.0%

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

Alternative 8: 59.9% accurate, 5.5× speedup?

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

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

\mathbf{elif}\;x \leq 6 \cdot 10^{-19}:\\
\;\;\;\;\frac{4}{y\_m}\\

\mathbf{elif}\;x \leq 7.4 \cdot 10^{+31}:\\
\;\;\;\;\frac{x}{\frac{y\_m}{z}}\\

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


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

    1. Initial program 93.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt37.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-sqr37.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-sqrt38.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0 - \frac{x \cdot z - \left(x + 4\right)}{y}} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt39.7%

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}} \cdot \sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}}} \]
      7. add-sqr-sqrt53.0%

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

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

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

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

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

    if -0.660000000000000031 < x < 5.99999999999999985e-19

    1. Initial program 97.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt47.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-sqr47.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-sqrt49.1%

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

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

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

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

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      2. clear-num50.0%

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

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{1}{\frac{y}{x \cdot z}}} \]
    7. Step-by-step derivation
      1. div-inv50.0%

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

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

      \[\leadsto \frac{x + 4}{y} - \frac{1}{\color{blue}{y \cdot \frac{1}{z \cdot x}}} \]
    9. Step-by-step derivation
      1. *-commutative50.0%

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

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

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

        \[\leadsto \frac{x + 4}{y} - \frac{1}{\color{blue}{\frac{1 \cdot \frac{y}{x}}{z}}} \]
      5. *-lft-identity49.1%

        \[\leadsto \frac{x + 4}{y} - \frac{1}{\frac{\color{blue}{\frac{y}{x}}}{z}} \]
    10. Simplified49.1%

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

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

    if 5.99999999999999985e-19 < x < 7.3999999999999996e31

    1. Initial program 99.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt41.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-sqr41.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-sqrt42.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0 - \color{blue}{\frac{x \cdot z}{y}} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt41.3%

        \[\leadsto \color{blue}{\sqrt{0 - \frac{x \cdot z}{y}} \cdot \sqrt{0 - \frac{x \cdot z}{y}}} \]
      2. sqrt-unprod53.6%

        \[\leadsto \color{blue}{\sqrt{\left(0 - \frac{x \cdot z}{y}\right) \cdot \left(0 - \frac{x \cdot z}{y}\right)}} \]
      3. associate-*r/53.6%

        \[\leadsto \sqrt{\left(0 - \color{blue}{x \cdot \frac{z}{y}}\right) \cdot \left(0 - \frac{x \cdot z}{y}\right)} \]
      4. neg-sub053.6%

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{x \cdot \frac{z}{y}} \cdot \sqrt{x \cdot \frac{z}{y}}} \]
      9. add-sqr-sqrt35.5%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y}} \]
      10. clear-num35.5%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{y}{z}}} \]
      11. un-div-inv42.6%

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

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

    if 7.3999999999999996e31 < x

    1. Initial program 86.1%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt49.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-sqr49.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-sqrt50.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - \frac{\color{blue}{-4} + -1 \cdot x}{y} \]
      4. neg-mul-130.0%

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

        \[\leadsto 0 - \frac{\color{blue}{-4 - x}}{y} \]
    7. Simplified30.0%

      \[\leadsto 0 - \color{blue}{\frac{-4 - x}{y}} \]
    8. Taylor expanded in x around inf 30.0%

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

Alternative 9: 77.4% accurate, 6.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -3.7:\\ \;\;\;\;\frac{x \cdot z - \left(x + 4\right)}{y\_m}\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{+23}:\\ \;\;\;\;\frac{4 - 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 -3.7)
   (/ (- (* x z) (+ x 4.0)) y_m)
   (if (<= x 2.3e+23) (/ (- 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 <= -3.7) {
		tmp = ((x * z) - (x + 4.0)) / y_m;
	} else if (x <= 2.3e+23) {
		tmp = (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 <= (-3.7d0)) then
        tmp = ((x * z) - (x + 4.0d0)) / y_m
    else if (x <= 2.3d+23) then
        tmp = (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 <= -3.7) {
		tmp = ((x * z) - (x + 4.0)) / y_m;
	} else if (x <= 2.3e+23) {
		tmp = (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 <= -3.7:
		tmp = ((x * z) - (x + 4.0)) / y_m
	elif x <= 2.3e+23:
		tmp = (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 <= -3.7)
		tmp = Float64(Float64(Float64(x * z) - Float64(x + 4.0)) / y_m);
	elseif (x <= 2.3e+23)
		tmp = Float64(Float64(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 <= -3.7)
		tmp = ((x * z) - (x + 4.0)) / y_m;
	elseif (x <= 2.3e+23)
		tmp = (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, -3.7], N[(N[(N[(x * z), $MachinePrecision] - N[(x + 4.0), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision], If[LessEqual[x, 2.3e+23], N[(N[(4.0 - 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 -3.7:\\
\;\;\;\;\frac{x \cdot z - \left(x + 4\right)}{y\_m}\\

\mathbf{elif}\;x \leq 2.3 \cdot 10^{+23}:\\
\;\;\;\;\frac{4 - 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 < -3.7000000000000002

    1. Initial program 93.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt37.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-sqr37.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-sqrt38.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0 - \frac{x \cdot z - \left(x + 4\right)}{y}} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt39.7%

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}} \cdot \sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}}} \]
      7. add-sqr-sqrt53.0%

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

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

    if -3.7000000000000002 < x < 2.3e23

    1. Initial program 97.2%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt47.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-sqr47.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-sqrt48.9%

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

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

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

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

      \[\leadsto \frac{\color{blue}{4}}{y} - x \cdot \frac{z}{y} \]
    6. Taylor expanded in y around 0 48.6%

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

    if 2.3e23 < x

    1. Initial program 86.3%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt48.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-sqr48.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-sqrt49.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - \frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y} \]
      3. metadata-eval29.6%

        \[\leadsto 0 - \frac{\color{blue}{-4} + -1 \cdot x}{y} \]
      4. neg-mul-129.6%

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

        \[\leadsto 0 - \frac{\color{blue}{-4 - x}}{y} \]
    7. Simplified29.6%

      \[\leadsto 0 - \color{blue}{\frac{-4 - x}{y}} \]
    8. Taylor expanded in y around 0 29.6%

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

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

Alternative 10: 77.2% accurate, 6.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -0.8:\\ \;\;\;\;\frac{x \cdot z - x}{y\_m}\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{+23}:\\ \;\;\;\;\frac{4 - 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 -0.8)
   (/ (- (* x z) x) y_m)
   (if (<= x 2.3e+23) (/ (- 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 <= -0.8) {
		tmp = ((x * z) - x) / y_m;
	} else if (x <= 2.3e+23) {
		tmp = (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 <= (-0.8d0)) then
        tmp = ((x * z) - x) / y_m
    else if (x <= 2.3d+23) then
        tmp = (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 <= -0.8) {
		tmp = ((x * z) - x) / y_m;
	} else if (x <= 2.3e+23) {
		tmp = (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 <= -0.8:
		tmp = ((x * z) - x) / y_m
	elif x <= 2.3e+23:
		tmp = (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 <= -0.8)
		tmp = Float64(Float64(Float64(x * z) - x) / y_m);
	elseif (x <= 2.3e+23)
		tmp = Float64(Float64(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 <= -0.8)
		tmp = ((x * z) - x) / y_m;
	elseif (x <= 2.3e+23)
		tmp = (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, -0.8], N[(N[(N[(x * z), $MachinePrecision] - x), $MachinePrecision] / y$95$m), $MachinePrecision], If[LessEqual[x, 2.3e+23], N[(N[(4.0 - 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 -0.8:\\
\;\;\;\;\frac{x \cdot z - x}{y\_m}\\

\mathbf{elif}\;x \leq 2.3 \cdot 10^{+23}:\\
\;\;\;\;\frac{4 - 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 < -0.80000000000000004

    1. Initial program 93.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt37.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-sqr37.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-sqrt38.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0 - \frac{x \cdot z - \left(x + 4\right)}{y}} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt39.7%

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}} \cdot \sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}}} \]
      7. add-sqr-sqrt53.0%

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

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

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

    if -0.80000000000000004 < x < 2.3e23

    1. Initial program 97.2%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt47.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-sqr47.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-sqrt48.9%

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

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

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

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

      \[\leadsto \frac{\color{blue}{4}}{y} - x \cdot \frac{z}{y} \]
    6. Taylor expanded in y around 0 48.6%

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

    if 2.3e23 < x

    1. Initial program 86.3%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt48.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-sqr48.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-sqrt49.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - \frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y} \]
      3. metadata-eval29.6%

        \[\leadsto 0 - \frac{\color{blue}{-4} + -1 \cdot x}{y} \]
      4. neg-mul-129.6%

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

        \[\leadsto 0 - \frac{\color{blue}{-4 - x}}{y} \]
    7. Simplified29.6%

      \[\leadsto 0 - \color{blue}{\frac{-4 - x}{y}} \]
    8. Taylor expanded in y around 0 29.6%

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

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

Alternative 11: 75.6% accurate, 6.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -4.8:\\ \;\;\;\;\frac{-4 - x}{y\_m}\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{+23}:\\ \;\;\;\;\frac{4 - 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 -4.8)
   (/ (- -4.0 x) y_m)
   (if (<= x 2.3e+23) (/ (- 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 <= -4.8) {
		tmp = (-4.0 - x) / y_m;
	} else if (x <= 2.3e+23) {
		tmp = (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 <= (-4.8d0)) then
        tmp = ((-4.0d0) - x) / y_m
    else if (x <= 2.3d+23) then
        tmp = (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 <= -4.8) {
		tmp = (-4.0 - x) / y_m;
	} else if (x <= 2.3e+23) {
		tmp = (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 <= -4.8:
		tmp = (-4.0 - x) / y_m
	elif x <= 2.3e+23:
		tmp = (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 <= -4.8)
		tmp = Float64(Float64(-4.0 - x) / y_m);
	elseif (x <= 2.3e+23)
		tmp = Float64(Float64(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 <= -4.8)
		tmp = (-4.0 - x) / y_m;
	elseif (x <= 2.3e+23)
		tmp = (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, -4.8], N[(N[(-4.0 - x), $MachinePrecision] / y$95$m), $MachinePrecision], If[LessEqual[x, 2.3e+23], N[(N[(4.0 - 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 -4.8:\\
\;\;\;\;\frac{-4 - x}{y\_m}\\

\mathbf{elif}\;x \leq 2.3 \cdot 10^{+23}:\\
\;\;\;\;\frac{4 - 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 < -4.79999999999999982

    1. Initial program 93.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt37.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-sqr37.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-sqrt38.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0 - \frac{x \cdot z - \left(x + 4\right)}{y}} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt39.7%

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}} \cdot \sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}}} \]
      7. add-sqr-sqrt53.0%

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(4 + x\right)}}{y} \]
    8. Step-by-step derivation
      1. distribute-lft-in40.9%

        \[\leadsto \frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y} \]
      2. metadata-eval40.9%

        \[\leadsto \frac{\color{blue}{-4} + -1 \cdot x}{y} \]
      3. neg-mul-140.9%

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

        \[\leadsto \frac{\color{blue}{-4 - x}}{y} \]
    9. Simplified40.9%

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

    if -4.79999999999999982 < x < 2.3e23

    1. Initial program 97.2%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt47.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-sqr47.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-sqrt48.9%

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

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

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

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

      \[\leadsto \frac{\color{blue}{4}}{y} - x \cdot \frac{z}{y} \]
    6. Taylor expanded in y around 0 48.6%

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

    if 2.3e23 < x

    1. Initial program 86.3%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt48.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-sqr48.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-sqrt49.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - \frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y} \]
      3. metadata-eval29.6%

        \[\leadsto 0 - \frac{\color{blue}{-4} + -1 \cdot x}{y} \]
      4. neg-mul-129.6%

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

        \[\leadsto 0 - \frac{\color{blue}{-4 - x}}{y} \]
    7. Simplified29.6%

      \[\leadsto 0 - \color{blue}{\frac{-4 - x}{y}} \]
    8. Taylor expanded in y around 0 29.6%

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

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

Alternative 12: 80.5% accurate, 6.9× speedup?

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

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

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


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

    1. Initial program 93.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4 < x

    1. Initial program 93.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt47.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-sqr47.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-sqrt49.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 80.1% accurate, 7.9× speedup?

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

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

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


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

    1. Initial program 93.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt37.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-sqr37.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-sqrt38.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0 - \frac{x \cdot z - \left(x + 4\right)}{y}} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt39.7%

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}} \cdot \sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}}} \]
      7. add-sqr-sqrt53.0%

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

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

    if -4 < x

    1. Initial program 93.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt47.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-sqr47.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-sqrt49.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 60.6% accurate, 8.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -0.62:\\ \;\;\;\;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 -0.62) (* 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 <= -0.62) {
		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 <= (-0.62d0)) 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 <= -0.62) {
		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 <= -0.62:
		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 <= -0.62)
		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 <= -0.62)
		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, -0.62], 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 -0.62:\\
\;\;\;\;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 < -0.619999999999999996

    1. Initial program 93.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt37.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-sqr37.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-sqrt38.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0 - \frac{x \cdot z - \left(x + 4\right)}{y}} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt39.7%

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}} \cdot \sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}}} \]
      7. add-sqr-sqrt53.0%

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

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

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

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

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

    if -0.619999999999999996 < x < 4

    1. Initial program 97.1%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt47.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-sqr47.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-sqrt48.8%

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

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

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

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

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

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

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{1}{\frac{y}{x \cdot z}}} \]
    7. Step-by-step derivation
      1. div-inv49.6%

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

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

      \[\leadsto \frac{x + 4}{y} - \frac{1}{\color{blue}{y \cdot \frac{1}{z \cdot x}}} \]
    9. Step-by-step derivation
      1. *-commutative49.6%

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

        \[\leadsto \frac{x + 4}{y} - \frac{1}{\color{blue}{\frac{1 \cdot y}{z \cdot x}}} \]
      3. times-frac48.8%

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

        \[\leadsto \frac{x + 4}{y} - \frac{1}{\color{blue}{\frac{1 \cdot \frac{y}{x}}{z}}} \]
      5. *-lft-identity48.8%

        \[\leadsto \frac{x + 4}{y} - \frac{1}{\frac{\color{blue}{\frac{y}{x}}}{z}} \]
    10. Simplified48.8%

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

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

    if 4 < x

    1. Initial program 87.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt48.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-sqr48.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-sqrt49.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - \frac{\color{blue}{-4} + -1 \cdot x}{y} \]
      4. neg-mul-127.1%

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

        \[\leadsto 0 - \frac{\color{blue}{-4 - x}}{y} \]
    7. Simplified27.1%

      \[\leadsto 0 - \color{blue}{\frac{-4 - x}{y}} \]
    8. Taylor expanded in x around inf 27.1%

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

Alternative 15: 70.3% 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 93.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt37.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-sqr37.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-sqrt38.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0 - \frac{x \cdot z - \left(x + 4\right)}{y}} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt39.7%

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}} \cdot \sqrt{\frac{x \cdot z - \left(x + 4\right)}{y}}} \]
      7. add-sqr-sqrt53.0%

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(4 + x\right)}}{y} \]
    8. Step-by-step derivation
      1. distribute-lft-in40.9%

        \[\leadsto \frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y} \]
      2. metadata-eval40.9%

        \[\leadsto \frac{\color{blue}{-4} + -1 \cdot x}{y} \]
      3. neg-mul-140.9%

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

        \[\leadsto \frac{\color{blue}{-4 - x}}{y} \]
    9. Simplified40.9%

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

    if -4 < x

    1. Initial program 93.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt47.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-sqr47.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-sqrt49.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - \frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y} \]
      3. metadata-eval36.9%

        \[\leadsto 0 - \frac{\color{blue}{-4} + -1 \cdot x}{y} \]
      4. neg-mul-136.9%

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

        \[\leadsto 0 - \frac{\color{blue}{-4 - x}}{y} \]
    7. Simplified36.9%

      \[\leadsto 0 - \color{blue}{\frac{-4 - x}{y}} \]
    8. Taylor expanded in y around 0 36.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{-4 - x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 62.1% accurate, 11.1× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{z}{\frac{y\_m}{x}}\\ \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) (/ z (/ y_m x)) (/ (+ 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 = z / (y_m / x);
	} 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 = z / (y_m / x)
    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 = z / (y_m / x);
	} 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 = z / (y_m / x)
	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(z / Float64(y_m / x));
	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 = z / (y_m / x);
	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[(z / N[(y$95$m / x), $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 -4:\\
\;\;\;\;\frac{z}{\frac{y\_m}{x}}\\

\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 93.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt37.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-sqr37.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-sqrt38.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0 - \color{blue}{\frac{x \cdot z}{y}} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt21.7%

        \[\leadsto \color{blue}{\sqrt{0 - \frac{x \cdot z}{y}} \cdot \sqrt{0 - \frac{x \cdot z}{y}}} \]
      2. sqrt-unprod40.4%

        \[\leadsto \color{blue}{\sqrt{\left(0 - \frac{x \cdot z}{y}\right) \cdot \left(0 - \frac{x \cdot z}{y}\right)}} \]
      3. associate-*r/40.4%

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{x \cdot \frac{z}{y}} \cdot \sqrt{x \cdot \frac{z}{y}}} \]
      9. add-sqr-sqrt27.1%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y}} \]
      10. *-commutative27.1%

        \[\leadsto \color{blue}{\frac{z}{y} \cdot x} \]
      11. associate-/r/30.1%

        \[\leadsto \color{blue}{\frac{z}{\frac{y}{x}}} \]
    7. Applied egg-rr30.1%

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

    if -4 < x

    1. Initial program 93.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt47.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-sqr47.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-sqrt49.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - \frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y} \]
      3. metadata-eval36.9%

        \[\leadsto 0 - \frac{\color{blue}{-4} + -1 \cdot x}{y} \]
      4. neg-mul-136.9%

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

        \[\leadsto 0 - \frac{\color{blue}{-4 - x}}{y} \]
    7. Simplified36.9%

      \[\leadsto 0 - \color{blue}{\frac{-4 - x}{y}} \]
    8. Taylor expanded in y around 0 36.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{z}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 55.1% 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 95.9%

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

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

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

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

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

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

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

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      2. clear-num44.9%

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

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{1}{\frac{y}{x \cdot z}}} \]
    7. Step-by-step derivation
      1. div-inv44.9%

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

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

      \[\leadsto \frac{x + 4}{y} - \frac{1}{\color{blue}{y \cdot \frac{1}{z \cdot x}}} \]
    9. Step-by-step derivation
      1. *-commutative44.9%

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

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

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

        \[\leadsto \frac{x + 4}{y} - \frac{1}{\color{blue}{\frac{1 \cdot \frac{y}{x}}{z}}} \]
      5. *-lft-identity45.4%

        \[\leadsto \frac{x + 4}{y} - \frac{1}{\frac{\color{blue}{\frac{y}{x}}}{z}} \]
    10. Simplified45.4%

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

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

    if 4 < x

    1. Initial program 87.5%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt48.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-sqr48.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-sqrt49.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - \frac{\color{blue}{-4} + -1 \cdot x}{y} \]
      4. neg-mul-127.1%

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

        \[\leadsto 0 - \frac{\color{blue}{-4 - x}}{y} \]
    7. Simplified27.1%

      \[\leadsto 0 - \color{blue}{\frac{-4 - x}{y}} \]
    8. Taylor expanded in x around inf 27.1%

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

Alternative 18: 40.9% 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 93.8%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-sqr-sqrt45.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-sqr45.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-sqrt46.4%

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

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

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

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

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
    2. clear-num45.7%

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

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

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

      \[\leadsto \frac{x + 4}{y} - \frac{1}{y \cdot \frac{1}{\color{blue}{z \cdot x}}} \]
  8. Applied egg-rr45.7%

    \[\leadsto \frac{x + 4}{y} - \frac{1}{\color{blue}{y \cdot \frac{1}{z \cdot x}}} \]
  9. Step-by-step derivation
    1. *-commutative45.7%

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

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

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

      \[\leadsto \frac{x + 4}{y} - \frac{1}{\color{blue}{\frac{1 \cdot \frac{y}{x}}{z}}} \]
    5. *-lft-identity46.4%

      \[\leadsto \frac{x + 4}{y} - \frac{1}{\frac{\color{blue}{\frac{y}{x}}}{z}} \]
  10. Simplified46.4%

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

    \[\leadsto \color{blue}{\frac{4}{y}} \]
  12. Add Preprocessing

Alternative 19: 1.7% 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 93.8%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-sqr-sqrt45.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-sqr45.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-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/45.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{-4}}{y} \]
  8. Add Preprocessing

Reproduce

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