fabs fraction 1

Percentage Accurate: 91.5% → 99.4%
Time: 37.2s
Alternatives: 17
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 17 alternatives:

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

Initial Program: 91.5% accurate, 1.0× speedup?

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

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

Alternative 1: 99.4% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 89.3%

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

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

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

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

    if 1.05e-78 < y

    1. Initial program 97.6%

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

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

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{x \cdot \frac{z}{y}}\right| \]
      3. clear-num99.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.9% 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 4 \cdot 10^{-15}\right):\\ \;\;\;\;\left|\frac{x}{y\_m} \cdot \left(1 - z\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{y\_m}{x + \left(4 + x \cdot z\right)}}\\ \end{array} \end{array} \]
y_m = (fabs.f64 y)
(FPCore (x y_m z)
 :precision binary64
 (if (or (<= x -4.0) (not (<= x 4e-15)))
   (fabs (* (/ x y_m) (- 1.0 z)))
   (/ 1.0 (/ y_m (+ x (+ 4.0 (* x z)))))))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if ((x <= -4.0) || !(x <= 4e-15)) {
		tmp = fabs(((x / y_m) * (1.0 - z)));
	} else {
		tmp = 1.0 / (y_m / (x + (4.0 + (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 <= 4d-15))) then
        tmp = abs(((x / y_m) * (1.0d0 - z)))
    else
        tmp = 1.0d0 / (y_m / (x + (4.0d0 + (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 <= 4e-15)) {
		tmp = Math.abs(((x / y_m) * (1.0 - z)));
	} else {
		tmp = 1.0 / (y_m / (x + (4.0 + (x * z))));
	}
	return tmp;
}
y_m = math.fabs(y)
def code(x, y_m, z):
	tmp = 0
	if (x <= -4.0) or not (x <= 4e-15):
		tmp = math.fabs(((x / y_m) * (1.0 - z)))
	else:
		tmp = 1.0 / (y_m / (x + (4.0 + (x * z))))
	return tmp
y_m = abs(y)
function code(x, y_m, z)
	tmp = 0.0
	if ((x <= -4.0) || !(x <= 4e-15))
		tmp = abs(Float64(Float64(x / y_m) * Float64(1.0 - z)));
	else
		tmp = Float64(1.0 / Float64(y_m / Float64(x + Float64(4.0 + 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 <= 4e-15)))
		tmp = abs(((x / y_m) * (1.0 - z)));
	else
		tmp = 1.0 / (y_m / (x + (4.0 + (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, 4e-15]], $MachinePrecision]], N[Abs[N[(N[(x / y$95$m), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(1.0 / N[(y$95$m / N[(x + N[(4.0 + N[(x * z), $MachinePrecision]), $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 4 \cdot 10^{-15}\right):\\
\;\;\;\;\left|\frac{x}{y\_m} \cdot \left(1 - z\right)\right|\\

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


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

    1. Initial program 88.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4 < x < 4.0000000000000003e-15

    1. Initial program 95.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 85.5% accurate, 1.0× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;z \leq -1.65 \cdot 10^{+97} \lor \neg \left(z \leq 3.9 \cdot 10^{+15}\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.65e+97) (not (<= z 3.9e+15)))
   (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.65e+97) || !(z <= 3.9e+15)) {
		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.65d+97)) .or. (.not. (z <= 3.9d+15))) 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.65e+97) || !(z <= 3.9e+15)) {
		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.65e+97) or not (z <= 3.9e+15):
		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.65e+97) || !(z <= 3.9e+15))
		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.65e+97) || ~((z <= 3.9e+15)))
		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.65e+97], N[Not[LessEqual[z, 3.9e+15]], $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.65 \cdot 10^{+97} \lor \neg \left(z \leq 3.9 \cdot 10^{+15}\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.6500000000000001e97 or 3.9e15 < z

    1. Initial program 88.6%

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

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

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

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

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

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

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

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

    if -1.6500000000000001e97 < z < 3.9e15

    1. Initial program 94.3%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 84.7% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 92.6%

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

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

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

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

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

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

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

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

    if -1.6500000000000001e97 < z < 1.9e15

    1. Initial program 94.3%

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

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

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

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

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

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

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

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

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

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

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

    if 1.9e15 < z

    1. Initial program 84.7%

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

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

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

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

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

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

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

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

Alternative 5: 98.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 80.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.54999999999999994e45 < x

    1. Initial program 95.5%

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

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

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

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

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

Alternative 6: 80.0% accurate, 6.2× speedup?

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

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

\mathbf{elif}\;x \leq 10.2:\\
\;\;\;\;\frac{\left(--4\right) - x \cdot z}{y\_m}\\

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


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

    1. Initial program 84.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - x \cdot \frac{z + \color{blue}{-1}}{y} \]
    7. Simplified55.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.20000000000000063e-8 < x < 10.199999999999999

    1. Initial program 95.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-4 - x\right) + \left(-\color{blue}{\left(-x \cdot z\right)}\right)}{-y} \]
      13. remove-double-neg52.4%

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

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

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

    if 10.199999999999999 < x

    1. Initial program 94.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-4 - x\right) + \left(-\color{blue}{\left(-x \cdot z\right)}\right)}{-y} \]
      13. remove-double-neg55.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{1 + -1 \cdot z}{y}} \]
      11. neg-mul-159.0%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{1 - z}{y}} \]
    10. Step-by-step derivation
      1. clear-num59.0%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{y}{1 - z}}} \]
      2. un-div-inv59.1%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{1 - z}}} \]
      3. *-un-lft-identity59.1%

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

        \[\leadsto \frac{x}{\frac{y}{\color{blue}{1 - z}}} \]
      5. sub-neg59.1%

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

        \[\leadsto \frac{x}{\frac{y}{\color{blue}{\left(-z\right) + 1}}} \]
      7. add-sqr-sqrt29.3%

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

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

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

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

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

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

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

Alternative 7: 79.9% accurate, 6.2× speedup?

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

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

\mathbf{elif}\;x \leq 23000:\\
\;\;\;\;\frac{\left(--4\right) - x \cdot z}{y\_m}\\

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


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

    1. Initial program 84.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - x \cdot \frac{z + \color{blue}{-1}}{y} \]
    7. Simplified55.7%

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

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

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

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

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

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

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

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

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

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

    if -8.20000000000000063e-8 < x < 23000

    1. Initial program 95.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-4 - x\right) + \left(-\color{blue}{\left(-x \cdot z\right)}\right)}{-y} \]
      13. remove-double-neg52.4%

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

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

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

    if 23000 < x

    1. Initial program 94.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-4 - x\right) + \left(-\color{blue}{\left(-x \cdot z\right)}\right)}{-y} \]
      13. remove-double-neg55.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{1 + -1 \cdot z}{y}} \]
      11. neg-mul-159.0%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{1 - z}{y}} \]
    10. Step-by-step derivation
      1. clear-num59.0%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{y}{1 - z}}} \]
      2. un-div-inv59.1%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{1 - z}}} \]
      3. *-un-lft-identity59.1%

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

        \[\leadsto \frac{x}{\frac{y}{\color{blue}{1 - z}}} \]
      5. sub-neg59.1%

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

        \[\leadsto \frac{x}{\frac{y}{\color{blue}{\left(-z\right) + 1}}} \]
      7. add-sqr-sqrt29.3%

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

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

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

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

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

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

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

Alternative 8: 74.4% accurate, 6.5× speedup?

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

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

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

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


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

    1. Initial program 83.1%

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

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

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

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

        \[\leadsto \color{blue}{\left(-\frac{x}{y} \cdot z\right) + \frac{x + 4}{y}} \]
      6. associate-*l/48.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-undefine60.2%

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

        \[\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/46.4%

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

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

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

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

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

        \[\leadsto 0 - x \cdot \frac{z + \color{blue}{-1}}{y} \]
    7. Simplified59.0%

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

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

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

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

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

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

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

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

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

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

    if -2 < x < 6.2e11

    1. Initial program 95.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.2e11 < x

    1. Initial program 94.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-4 - x\right) + \left(-\color{blue}{\left(-x \cdot z\right)}\right)}{-y} \]
      13. remove-double-neg55.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{1 + -1 \cdot z}{y}} \]
      11. neg-mul-159.0%

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

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

      \[\leadsto \color{blue}{x \cdot \frac{1 - z}{y}} \]
    10. Step-by-step derivation
      1. clear-num59.0%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{y}{1 - z}}} \]
      2. un-div-inv59.1%

        \[\leadsto \color{blue}{\frac{x}{\frac{y}{1 - z}}} \]
      3. *-un-lft-identity59.1%

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

        \[\leadsto \frac{x}{\frac{y}{\color{blue}{1 - z}}} \]
      5. sub-neg59.1%

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

        \[\leadsto \frac{x}{\frac{y}{\color{blue}{\left(-z\right) + 1}}} \]
      7. add-sqr-sqrt29.3%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2:\\ \;\;\;\;x \cdot \frac{z + -1}{y}\\ \mathbf{elif}\;x \leq 620000000000:\\ \;\;\;\;\frac{-1}{\frac{y}{-4 - x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{z + 1}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 74.6% accurate, 6.5× speedup?

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

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

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

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


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

    1. Initial program 83.1%

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

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

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

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

        \[\leadsto \color{blue}{\left(-\frac{x}{y} \cdot z\right) + \frac{x + 4}{y}} \]
      6. associate-*l/48.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-undefine60.2%

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

        \[\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/46.4%

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

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

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

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

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

        \[\leadsto 0 - x \cdot \frac{z + \color{blue}{-1}}{y} \]
    7. Simplified59.0%

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

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

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

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

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

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

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

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

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

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

    if -2.7999999999999998 < x < 4.0000000000000003e-15

    1. Initial program 95.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.0000000000000003e-15 < x

    1. Initial program 94.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(x \cdot \left(z - 1\right)\right)}{y}} \]
      2. sub-neg55.2%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{1 + -1 \cdot z}{y}} \]
      11. neg-mul-158.6%

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

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

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

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

Alternative 10: 71.8% accurate, 6.5× speedup?

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

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

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

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


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

    1. Initial program 82.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(4 \cdot \frac{1}{y} + \frac{x}{y}\right)} \]
    6. Step-by-step derivation
      1. mul-1-neg21.8%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-4}{y} - \frac{x}{y}} \]
      8. div-sub21.8%

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

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

    if -4 < x < 4.0000000000000003e-15

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.0000000000000003e-15 < x

    1. Initial program 94.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(x \cdot \left(z - 1\right)\right)}{y}} \]
      2. sub-neg55.2%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{1 + -1 \cdot z}{y}} \]
      11. neg-mul-158.6%

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

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

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

Alternative 11: 77.5% accurate, 6.9× speedup?

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

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

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


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

    1. Initial program 82.8%

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

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

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

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

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

    if -4 < x

    1. Initial program 95.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 80.5% accurate, 7.9× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -2.7:\\ \;\;\;\;\frac{x}{\frac{y\_m}{z + -1}}\\ \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 -2.7) (/ x (/ y_m (+ z -1.0))) (/ (- (- x -4.0) (* x z)) y_m)))
y_m = fabs(y);
double code(double x, double y_m, double z) {
	double tmp;
	if (x <= -2.7) {
		tmp = x / (y_m / (z + -1.0));
	} 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 <= (-2.7d0)) then
        tmp = x / (y_m / (z + (-1.0d0)))
    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 <= -2.7) {
		tmp = x / (y_m / (z + -1.0));
	} 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 <= -2.7:
		tmp = x / (y_m / (z + -1.0))
	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 <= -2.7)
		tmp = Float64(x / Float64(y_m / Float64(z + -1.0)));
	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 <= -2.7)
		tmp = x / (y_m / (z + -1.0));
	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, -2.7], N[(x / N[(y$95$m / N[(z + -1.0), $MachinePrecision]), $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 -2.7:\\
\;\;\;\;\frac{x}{\frac{y\_m}{z + -1}}\\

\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 < -2.7000000000000002

    1. Initial program 83.1%

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

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

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

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

        \[\leadsto \color{blue}{\left(-\frac{x}{y} \cdot z\right) + \frac{x + 4}{y}} \]
      6. associate-*l/48.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-undefine60.2%

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

        \[\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/46.4%

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

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

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

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

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

        \[\leadsto 0 - x \cdot \frac{z + \color{blue}{-1}}{y} \]
    7. Simplified59.0%

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

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

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

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

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

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

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

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

        \[\leadsto 0 - \color{blue}{\left(0 + \left(-x\right) \cdot \frac{z + -1}{y}\right)} \]
      9. +-lft-identity40.3%

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

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

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

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

    if -2.7000000000000002 < x

    1. Initial program 95.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 61.3% accurate, 8.5× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -8 \cdot 10^{-8}:\\ \;\;\;\;z \cdot \frac{x}{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 -8e-8) (* z (/ x 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 <= -8e-8) {
		tmp = z * (x / 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 <= (-8d-8)) then
        tmp = z * (x / 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 <= -8e-8) {
		tmp = z * (x / 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 <= -8e-8:
		tmp = z * (x / 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 <= -8e-8)
		tmp = Float64(z * Float64(x / 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 <= -8e-8)
		tmp = z * (x / 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, -8e-8], N[(z * N[(x / 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 -8 \cdot 10^{-8}:\\
\;\;\;\;z \cdot \frac{x}{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 < -8.0000000000000002e-8

    1. Initial program 84.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 0 - \color{blue}{\frac{x \cdot z}{y}} \]
    6. Step-by-step derivation
      1. *-commutative20.7%

        \[\leadsto 0 - \frac{\color{blue}{z \cdot x}}{y} \]
      2. associate-*r/27.5%

        \[\leadsto 0 - \color{blue}{z \cdot \frac{x}{y}} \]
    7. Simplified27.5%

      \[\leadsto 0 - \color{blue}{z \cdot \frac{x}{y}} \]
    8. Step-by-step derivation
      1. sub0-neg27.5%

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

        \[\leadsto -\color{blue}{\frac{x}{y} \cdot z} \]
      3. distribute-lft-neg-in27.5%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-x}{-y}} \cdot z \]
      10. frac-2neg39.8%

        \[\leadsto \color{blue}{\frac{x}{y}} \cdot z \]
    9. Applied egg-rr39.8%

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

    if -8.0000000000000002e-8 < x < 4

    1. Initial program 95.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-4 - x\right) + \left(-\color{blue}{\left(-x \cdot z\right)}\right)}{-y} \]
      13. remove-double-neg52.4%

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

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

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

    if 4 < x

    1. Initial program 94.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 - x \cdot \frac{z + \color{blue}{-1}}{y} \]
    7. Simplified59.0%

      \[\leadsto 0 - \color{blue}{x \cdot \frac{z + -1}{y}} \]
    8. Taylor expanded in z around 0 37.1%

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

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

Alternative 14: 69.7% 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 82.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(4 \cdot \frac{1}{y} + \frac{x}{y}\right)} \]
    6. Step-by-step derivation
      1. mul-1-neg21.8%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-4}{y} - \frac{x}{y}} \]
      8. div-sub21.8%

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

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

    if -4 < x

    1. Initial program 95.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified96.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 73.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 62.1% accurate, 11.1× speedup?

\[\begin{array}{l} y_m = \left|y\right| \\ \begin{array}{l} \mathbf{if}\;x \leq -0.88:\\ \;\;\;\;z \cdot \frac{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 -0.88) (* z (/ 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 <= -0.88) {
		tmp = z * (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 <= (-0.88d0)) then
        tmp = z * (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 <= -0.88) {
		tmp = z * (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 <= -0.88:
		tmp = z * (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 <= -0.88)
		tmp = Float64(z * Float64(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 <= -0.88)
		tmp = z * (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, -0.88], N[(z * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(x + 4.0), $MachinePrecision] / y$95$m), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -0.880000000000000004

    1. Initial program 83.1%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt45.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-sqr45.9%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      3. add-sqr-sqrt46.4%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      4. sub-neg46.4%

        \[\leadsto \color{blue}{\frac{x + 4}{y} + \left(-\frac{x}{y} \cdot z\right)} \]
      5. +-commutative46.4%

        \[\leadsto \color{blue}{\left(-\frac{x}{y} \cdot z\right) + \frac{x + 4}{y}} \]
      6. associate-*l/48.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-undefine60.2%

        \[\leadsto -\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      16. neg-sub060.2%

        \[\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/46.4%

        \[\leadsto 0 - \left(\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right) \]
    4. Applied egg-rr55.9%

      \[\leadsto \color{blue}{0 - \frac{x \cdot z - \left(x + 4\right)}{y}} \]
    5. Taylor expanded in z around inf 21.7%

      \[\leadsto 0 - \color{blue}{\frac{x \cdot z}{y}} \]
    6. Step-by-step derivation
      1. *-commutative21.7%

        \[\leadsto 0 - \frac{\color{blue}{z \cdot x}}{y} \]
      2. associate-*r/28.9%

        \[\leadsto 0 - \color{blue}{z \cdot \frac{x}{y}} \]
    7. Simplified28.9%

      \[\leadsto 0 - \color{blue}{z \cdot \frac{x}{y}} \]
    8. Step-by-step derivation
      1. sub0-neg28.9%

        \[\leadsto \color{blue}{-z \cdot \frac{x}{y}} \]
      2. *-commutative28.9%

        \[\leadsto -\color{blue}{\frac{x}{y} \cdot z} \]
      3. distribute-lft-neg-in28.9%

        \[\leadsto \color{blue}{\left(-\frac{x}{y}\right) \cdot z} \]
      4. add-sqr-sqrt11.1%

        \[\leadsto \left(-\frac{x}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}\right) \cdot z \]
      5. sqrt-unprod32.1%

        \[\leadsto \left(-\frac{x}{\color{blue}{\sqrt{y \cdot y}}}\right) \cdot z \]
      6. sqr-neg32.1%

        \[\leadsto \left(-\frac{x}{\sqrt{\color{blue}{\left(-y\right) \cdot \left(-y\right)}}}\right) \cdot z \]
      7. sqrt-unprod25.5%

        \[\leadsto \left(-\frac{x}{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}}\right) \cdot z \]
      8. add-sqr-sqrt39.9%

        \[\leadsto \left(-\frac{x}{\color{blue}{-y}}\right) \cdot z \]
      9. distribute-frac-neg39.9%

        \[\leadsto \color{blue}{\frac{-x}{-y}} \cdot z \]
      10. frac-2neg39.9%

        \[\leadsto \color{blue}{\frac{x}{y}} \cdot z \]
    9. Applied egg-rr39.9%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot z} \]

    if -0.880000000000000004 < x

    1. Initial program 95.3%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub95.3%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/97.9%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/95.4%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fma-neg96.0%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac96.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative96.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in96.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg96.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval96.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified96.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 74.1%

      \[\leadsto \left|\color{blue}{-1 \cdot \frac{4 + x}{y}}\right| \]
    6. Step-by-step derivation
      1. associate-*r/74.1%

        \[\leadsto \left|\color{blue}{\frac{-1 \cdot \left(4 + x\right)}{y}}\right| \]
      2. distribute-lft-in74.1%

        \[\leadsto \left|\frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y}\right| \]
      3. metadata-eval74.1%

        \[\leadsto \left|\frac{\color{blue}{-4} + -1 \cdot x}{y}\right| \]
      4. neg-mul-174.1%

        \[\leadsto \left|\frac{-4 + \color{blue}{\left(-x\right)}}{y}\right| \]
      5. sub-neg74.1%

        \[\leadsto \left|\frac{\color{blue}{-4 - x}}{y}\right| \]
    7. Simplified74.1%

      \[\leadsto \left|\color{blue}{\frac{-4 - x}{y}}\right| \]
    8. Step-by-step derivation
      1. add-sqr-sqrt73.6%

        \[\leadsto \color{blue}{\sqrt{\left|\frac{-4 - x}{y}\right|} \cdot \sqrt{\left|\frac{-4 - x}{y}\right|}} \]
      2. sqrt-unprod50.3%

        \[\leadsto \color{blue}{\sqrt{\left|\frac{-4 - x}{y}\right| \cdot \left|\frac{-4 - x}{y}\right|}} \]
      3. neg-fabs50.3%

        \[\leadsto \sqrt{\color{blue}{\left|-\frac{-4 - x}{y}\right|} \cdot \left|\frac{-4 - x}{y}\right|} \]
      4. neg-fabs50.3%

        \[\leadsto \sqrt{\left|-\frac{-4 - x}{y}\right| \cdot \color{blue}{\left|-\frac{-4 - x}{y}\right|}} \]
      5. sqr-abs50.3%

        \[\leadsto \sqrt{\color{blue}{\left(-\frac{-4 - x}{y}\right) \cdot \left(-\frac{-4 - x}{y}\right)}} \]
      6. distribute-frac-neg250.3%

        \[\leadsto \sqrt{\color{blue}{\frac{-4 - x}{-y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      7. sub-neg50.3%

        \[\leadsto \sqrt{\frac{\color{blue}{-4 + \left(-x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      8. metadata-eval50.3%

        \[\leadsto \sqrt{\frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      9. distribute-neg-in50.3%

        \[\leadsto \sqrt{\frac{\color{blue}{-\left(4 + x\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      10. +-commutative50.3%

        \[\leadsto \sqrt{\frac{-\color{blue}{\left(x + 4\right)}}{-y} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      11. frac-2neg50.3%

        \[\leadsto \sqrt{\color{blue}{\frac{x + 4}{y}} \cdot \left(-\frac{-4 - x}{y}\right)} \]
      12. distribute-frac-neg250.3%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{-4 - x}{-y}}} \]
      13. sub-neg50.3%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-4 + \left(-x\right)}}{-y}} \]
      14. metadata-eval50.3%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{\left(-4\right)} + \left(-x\right)}{-y}} \]
      15. distribute-neg-in50.3%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{\color{blue}{-\left(4 + x\right)}}{-y}} \]
      16. +-commutative50.3%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \frac{-\color{blue}{\left(x + 4\right)}}{-y}} \]
      17. frac-2neg50.3%

        \[\leadsto \sqrt{\frac{x + 4}{y} \cdot \color{blue}{\frac{x + 4}{y}}} \]
      18. sqrt-unprod39.4%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y}} \cdot \sqrt{\frac{x + 4}{y}}} \]
      19. add-sqr-sqrt40.5%

        \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
    9. Applied egg-rr40.5%

      \[\leadsto \color{blue}{\frac{x + 4}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification40.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.88:\\ \;\;\;\;z \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 54.3% 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 91.7%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*l/93.3%

        \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
      2. sub-div96.7%

        \[\leadsto \left|\color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}}\right| \]
    4. Applied egg-rr96.7%

      \[\leadsto \left|\color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}}\right| \]
    5. Step-by-step derivation
      1. add-sqr-sqrt52.4%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{\left(x + 4\right) - x \cdot z}{y}} \cdot \sqrt{\frac{\left(x + 4\right) - x \cdot z}{y}}}\right| \]
      2. fabs-sqr52.4%

        \[\leadsto \color{blue}{\sqrt{\frac{\left(x + 4\right) - x \cdot z}{y}} \cdot \sqrt{\frac{\left(x + 4\right) - x \cdot z}{y}}} \]
      3. add-sqr-sqrt53.5%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
      4. frac-2neg53.5%

        \[\leadsto \color{blue}{\frac{-\left(\left(x + 4\right) - x \cdot z\right)}{-y}} \]
      5. sub-neg53.5%

        \[\leadsto \frac{-\color{blue}{\left(\left(x + 4\right) + \left(-x \cdot z\right)\right)}}{-y} \]
      6. distribute-rgt-neg-out53.5%

        \[\leadsto \frac{-\left(\left(x + 4\right) + \color{blue}{x \cdot \left(-z\right)}\right)}{-y} \]
      7. distribute-neg-in53.5%

        \[\leadsto \frac{\color{blue}{\left(-\left(x + 4\right)\right) + \left(-x \cdot \left(-z\right)\right)}}{-y} \]
      8. +-commutative53.5%

        \[\leadsto \frac{\left(-\color{blue}{\left(4 + x\right)}\right) + \left(-x \cdot \left(-z\right)\right)}{-y} \]
      9. distribute-neg-in53.5%

        \[\leadsto \frac{\color{blue}{\left(\left(-4\right) + \left(-x\right)\right)} + \left(-x \cdot \left(-z\right)\right)}{-y} \]
      10. metadata-eval53.5%

        \[\leadsto \frac{\left(\color{blue}{-4} + \left(-x\right)\right) + \left(-x \cdot \left(-z\right)\right)}{-y} \]
      11. sub-neg53.5%

        \[\leadsto \frac{\color{blue}{\left(-4 - x\right)} + \left(-x \cdot \left(-z\right)\right)}{-y} \]
      12. distribute-rgt-neg-out53.5%

        \[\leadsto \frac{\left(-4 - x\right) + \left(-\color{blue}{\left(-x \cdot z\right)}\right)}{-y} \]
      13. remove-double-neg53.5%

        \[\leadsto \frac{\left(-4 - x\right) + \color{blue}{x \cdot z}}{-y} \]
    6. Applied egg-rr53.5%

      \[\leadsto \color{blue}{\frac{\left(-4 - x\right) + x \cdot z}{-y}} \]
    7. Taylor expanded in x around 0 28.5%

      \[\leadsto \color{blue}{\frac{4}{y}} \]

    if 4 < x

    1. Initial program 94.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt54.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-sqr54.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-sqrt55.2%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      4. sub-neg55.2%

        \[\leadsto \color{blue}{\frac{x + 4}{y} + \left(-\frac{x}{y} \cdot z\right)} \]
      5. +-commutative55.2%

        \[\leadsto \color{blue}{\left(-\frac{x}{y} \cdot z\right) + \frac{x + 4}{y}} \]
      6. associate-*l/51.4%

        \[\leadsto \left(-\color{blue}{\frac{x \cdot z}{y}}\right) + \frac{x + 4}{y} \]
      7. associate-*r/55.1%

        \[\leadsto \left(-\color{blue}{x \cdot \frac{z}{y}}\right) + \frac{x + 4}{y} \]
      8. frac-2neg55.1%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \color{blue}{\frac{-\left(x + 4\right)}{-y}} \]
      9. +-commutative55.1%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{-\color{blue}{\left(4 + x\right)}}{-y} \]
      10. distribute-neg-in55.1%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{-y} \]
      11. metadata-eval55.1%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{-4} + \left(-x\right)}{-y} \]
      12. sub-neg55.1%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \frac{\color{blue}{-4 - x}}{-y} \]
      13. distribute-frac-neg255.1%

        \[\leadsto \left(-x \cdot \frac{z}{y}\right) + \color{blue}{\left(-\frac{-4 - x}{y}\right)} \]
      14. distribute-neg-in55.1%

        \[\leadsto \color{blue}{-\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      15. fma-undefine57.1%

        \[\leadsto -\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      16. neg-sub057.1%

        \[\leadsto \color{blue}{0 - \mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      17. fma-undefine55.1%

        \[\leadsto 0 - \color{blue}{\left(x \cdot \frac{z}{y} + \frac{-4 - x}{y}\right)} \]
      18. associate-*r/51.4%

        \[\leadsto 0 - \left(\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right) \]
      19. associate-*l/55.2%

        \[\leadsto 0 - \left(\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right) \]
    4. Applied egg-rr55.4%

      \[\leadsto \color{blue}{0 - \frac{x \cdot z - \left(x + 4\right)}{y}} \]
    5. Taylor expanded in x around inf 55.4%

      \[\leadsto 0 - \color{blue}{\frac{x \cdot \left(z - 1\right)}{y}} \]
    6. Step-by-step derivation
      1. associate-/l*59.0%

        \[\leadsto 0 - \color{blue}{x \cdot \frac{z - 1}{y}} \]
      2. sub-neg59.0%

        \[\leadsto 0 - x \cdot \frac{\color{blue}{z + \left(-1\right)}}{y} \]
      3. metadata-eval59.0%

        \[\leadsto 0 - x \cdot \frac{z + \color{blue}{-1}}{y} \]
    7. Simplified59.0%

      \[\leadsto 0 - \color{blue}{x \cdot \frac{z + -1}{y}} \]
    8. Taylor expanded in z around 0 37.1%

      \[\leadsto \color{blue}{\frac{x}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 17: 40.4% 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 92.2%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. associate-*l/93.1%

      \[\leadsto \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]
    2. sub-div96.6%

      \[\leadsto \left|\color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}}\right| \]
  4. Applied egg-rr96.6%

    \[\leadsto \left|\color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}}\right| \]
  5. Step-by-step derivation
    1. add-sqr-sqrt52.9%

      \[\leadsto \left|\color{blue}{\sqrt{\frac{\left(x + 4\right) - x \cdot z}{y}} \cdot \sqrt{\frac{\left(x + 4\right) - x \cdot z}{y}}}\right| \]
    2. fabs-sqr52.9%

      \[\leadsto \color{blue}{\sqrt{\frac{\left(x + 4\right) - x \cdot z}{y}} \cdot \sqrt{\frac{\left(x + 4\right) - x \cdot z}{y}}} \]
    3. add-sqr-sqrt53.9%

      \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    4. frac-2neg53.9%

      \[\leadsto \color{blue}{\frac{-\left(\left(x + 4\right) - x \cdot z\right)}{-y}} \]
    5. sub-neg53.9%

      \[\leadsto \frac{-\color{blue}{\left(\left(x + 4\right) + \left(-x \cdot z\right)\right)}}{-y} \]
    6. distribute-rgt-neg-out53.9%

      \[\leadsto \frac{-\left(\left(x + 4\right) + \color{blue}{x \cdot \left(-z\right)}\right)}{-y} \]
    7. distribute-neg-in53.9%

      \[\leadsto \frac{\color{blue}{\left(-\left(x + 4\right)\right) + \left(-x \cdot \left(-z\right)\right)}}{-y} \]
    8. +-commutative53.9%

      \[\leadsto \frac{\left(-\color{blue}{\left(4 + x\right)}\right) + \left(-x \cdot \left(-z\right)\right)}{-y} \]
    9. distribute-neg-in53.9%

      \[\leadsto \frac{\color{blue}{\left(\left(-4\right) + \left(-x\right)\right)} + \left(-x \cdot \left(-z\right)\right)}{-y} \]
    10. metadata-eval53.9%

      \[\leadsto \frac{\left(\color{blue}{-4} + \left(-x\right)\right) + \left(-x \cdot \left(-z\right)\right)}{-y} \]
    11. sub-neg53.9%

      \[\leadsto \frac{\color{blue}{\left(-4 - x\right)} + \left(-x \cdot \left(-z\right)\right)}{-y} \]
    12. distribute-rgt-neg-out53.9%

      \[\leadsto \frac{\left(-4 - x\right) + \left(-\color{blue}{\left(-x \cdot z\right)}\right)}{-y} \]
    13. remove-double-neg53.9%

      \[\leadsto \frac{\left(-4 - x\right) + \color{blue}{x \cdot z}}{-y} \]
  6. Applied egg-rr53.9%

    \[\leadsto \color{blue}{\frac{\left(-4 - x\right) + x \cdot z}{-y}} \]
  7. Taylor expanded in x around 0 23.5%

    \[\leadsto \color{blue}{\frac{4}{y}} \]
  8. Add Preprocessing

Reproduce

?
herbie shell --seed 2024116 
(FPCore (x y z)
  :name "fabs fraction 1"
  :precision binary64
  (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))