fabs fraction 1

Percentage Accurate: 91.8% → 98.8%
Time: 9.0s
Alternatives: 15
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 15 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.8% 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: 98.8% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 84.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -650 < x < 3.85000000000000009

    1. Initial program 94.9%

      \[\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. Taylor expanded in x around 0 99.6%

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

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

Alternative 2: 84.6% accurate, 0.9× speedup?

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

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

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

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

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


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

    1. Initial program 90.5%

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

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

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

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

        \[\leadsto \left|\color{blue}{\frac{-x \cdot z}{y}}\right| \]
      3. distribute-lft-neg-in84.4%

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

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

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

    if -1.39999999999999999e94 < z < -4e5

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}} \cdot \sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}}} \]
      11. rem-square-sqrt55.1%

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

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

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

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

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

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

    if -4e5 < z < 1.75e26

    1. Initial program 93.6%

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

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

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

        \[\leadsto \left|\frac{\color{blue}{x + 4}}{y}\right| \]
    6. Simplified99.4%

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

    if 1.75e26 < z

    1. Initial program 75.6%

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

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

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

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

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

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

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

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

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

Alternative 3: 85.5% accurate, 0.9× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1e94 or 4.00000000000000036e25 < z

    1. Initial program 82.5%

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

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

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

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

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

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

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

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

    if -1e94 < z < -48000

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}} \cdot \sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}}} \]
      11. rem-square-sqrt55.1%

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

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

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

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

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

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

    if -48000 < z < 4.00000000000000036e25

    1. Initial program 93.6%

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

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

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

        \[\leadsto \left|\frac{\color{blue}{x + 4}}{y}\right| \]
    6. Simplified99.4%

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

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

Alternative 4: 75.6% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 85.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4 < x < 1.4500000000000001e-34

    1. Initial program 94.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 95.8% accurate, 1.0× speedup?

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

\\
\left|\frac{x \cdot z - \left(x + 4\right)}{y}\right|
\end{array}
Derivation
  1. Initial program 90.2%

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

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

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

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

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

Alternative 6: 48.1% accurate, 6.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.088:\\ \;\;\;\;\frac{x \cdot z - x}{y}\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\frac{4 - x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - x \cdot z}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -0.088)
   (/ (- (* x z) x) y)
   (if (<= x 4.0) (/ (- 4.0 (* x z)) y) (/ (- x (* x z)) y))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -0.088) {
		tmp = ((x * z) - x) / y;
	} else if (x <= 4.0) {
		tmp = (4.0 - (x * z)) / y;
	} else {
		tmp = (x - (x * z)) / y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-0.088d0)) then
        tmp = ((x * z) - x) / y
    else if (x <= 4.0d0) then
        tmp = (4.0d0 - (x * z)) / y
    else
        tmp = (x - (x * z)) / y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -0.088) {
		tmp = ((x * z) - x) / y;
	} else if (x <= 4.0) {
		tmp = (4.0 - (x * z)) / y;
	} else {
		tmp = (x - (x * z)) / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -0.088:
		tmp = ((x * z) - x) / y
	elif x <= 4.0:
		tmp = (4.0 - (x * z)) / y
	else:
		tmp = (x - (x * z)) / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -0.088)
		tmp = Float64(Float64(Float64(x * z) - x) / y);
	elseif (x <= 4.0)
		tmp = Float64(Float64(4.0 - Float64(x * z)) / y);
	else
		tmp = Float64(Float64(x - Float64(x * z)) / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -0.088)
		tmp = ((x * z) - x) / y;
	elseif (x <= 4.0)
		tmp = (4.0 - (x * z)) / y;
	else
		tmp = (x - (x * z)) / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -0.088], N[(N[(N[(x * z), $MachinePrecision] - x), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[x, 4.0], N[(N[(4.0 - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 85.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.087999999999999995 < x < 4

    1. Initial program 94.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{4 - x \cdot z}{y}} \]
      3. *-commutative51.8%

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

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

    if 4 < x

    1. Initial program 84.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}} \cdot \sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}}} \]
      11. rem-square-sqrt38.4%

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

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

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

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

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

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

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

Alternative 7: 44.8% accurate, 6.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -620:\\ \;\;\;\;\frac{4 - x}{y}\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\frac{4 - x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - x \cdot z}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -620.0)
   (/ (- 4.0 x) y)
   (if (<= x 4.0) (/ (- 4.0 (* x z)) y) (/ (- x (* x z)) y))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -620.0) {
		tmp = (4.0 - x) / y;
	} else if (x <= 4.0) {
		tmp = (4.0 - (x * z)) / y;
	} else {
		tmp = (x - (x * z)) / y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-620.0d0)) then
        tmp = (4.0d0 - x) / y
    else if (x <= 4.0d0) then
        tmp = (4.0d0 - (x * z)) / y
    else
        tmp = (x - (x * z)) / y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -620.0) {
		tmp = (4.0 - x) / y;
	} else if (x <= 4.0) {
		tmp = (4.0 - (x * z)) / y;
	} else {
		tmp = (x - (x * z)) / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -620.0:
		tmp = (4.0 - x) / y
	elif x <= 4.0:
		tmp = (4.0 - (x * z)) / y
	else:
		tmp = (x - (x * z)) / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -620.0)
		tmp = Float64(Float64(4.0 - x) / y);
	elseif (x <= 4.0)
		tmp = Float64(Float64(4.0 - Float64(x * z)) / y);
	else
		tmp = Float64(Float64(x - Float64(x * z)) / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -620.0)
		tmp = (4.0 - x) / y;
	elseif (x <= 4.0)
		tmp = (4.0 - (x * z)) / y;
	else
		tmp = (x - (x * z)) / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -620.0], N[(N[(4.0 - x), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[x, 4.0], N[(N[(4.0 - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 85.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x - 4}{y}} \]
    10. Step-by-step derivation
      1. sub-neg42.9%

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

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

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

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

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

        \[\leadsto \frac{0 - \color{blue}{\left(-4 + x\right)}}{y} \]
      7. associate--r+42.9%

        \[\leadsto \frac{\color{blue}{\left(0 - -4\right) - x}}{y} \]
      8. metadata-eval42.9%

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

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

    if -620 < x < 4

    1. Initial program 94.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{4 - x \cdot z}{y}} \]
      3. *-commutative51.8%

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

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

    if 4 < x

    1. Initial program 84.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}} \cdot \sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}}} \]
      11. rem-square-sqrt38.4%

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

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

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

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

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

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

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

Alternative 8: 40.9% accurate, 6.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -520:\\ \;\;\;\;\frac{4 - x}{y}\\ \mathbf{elif}\;x \leq 88:\\ \;\;\;\;\frac{4 - x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - -4}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -520.0)
   (/ (- 4.0 x) y)
   (if (<= x 88.0) (/ (- 4.0 (* x z)) y) (/ (- x -4.0) y))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -520.0) {
		tmp = (4.0 - x) / y;
	} else if (x <= 88.0) {
		tmp = (4.0 - (x * z)) / y;
	} else {
		tmp = (x - -4.0) / y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-520.0d0)) then
        tmp = (4.0d0 - x) / y
    else if (x <= 88.0d0) then
        tmp = (4.0d0 - (x * z)) / y
    else
        tmp = (x - (-4.0d0)) / y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -520.0) {
		tmp = (4.0 - x) / y;
	} else if (x <= 88.0) {
		tmp = (4.0 - (x * z)) / y;
	} else {
		tmp = (x - -4.0) / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -520.0:
		tmp = (4.0 - x) / y
	elif x <= 88.0:
		tmp = (4.0 - (x * z)) / y
	else:
		tmp = (x - -4.0) / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -520.0)
		tmp = Float64(Float64(4.0 - x) / y);
	elseif (x <= 88.0)
		tmp = Float64(Float64(4.0 - Float64(x * z)) / y);
	else
		tmp = Float64(Float64(x - -4.0) / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -520.0)
		tmp = (4.0 - x) / y;
	elseif (x <= 88.0)
		tmp = (4.0 - (x * z)) / y;
	else
		tmp = (x - -4.0) / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -520.0], N[(N[(4.0 - x), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[x, 88.0], N[(N[(4.0 - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(N[(x - -4.0), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 85.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x - 4}{y}} \]
    10. Step-by-step derivation
      1. sub-neg42.9%

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

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

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

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

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

        \[\leadsto \frac{0 - \color{blue}{\left(-4 + x\right)}}{y} \]
      7. associate--r+42.9%

        \[\leadsto \frac{\color{blue}{\left(0 - -4\right) - x}}{y} \]
      8. metadata-eval42.9%

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

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

    if -520 < x < 88

    1. Initial program 94.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{4 - x \cdot z}{y}} \]
      3. *-commutative52.2%

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

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

    if 88 < x

    1. Initial program 84.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}} \cdot \sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}}} \]
      11. rem-square-sqrt37.3%

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

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

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

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

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

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

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

Alternative 9: 35.0% accurate, 6.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 6.4 \cdot 10^{-14}:\\ \;\;\;\;\frac{4 - x}{y}\\ \mathbf{elif}\;x \leq 215:\\ \;\;\;\;z \cdot \frac{x}{-y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - -4}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x 6.4e-14)
   (/ (- 4.0 x) y)
   (if (<= x 215.0) (* z (/ x (- y))) (/ (- x -4.0) y))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= 6.4e-14) {
		tmp = (4.0 - x) / y;
	} else if (x <= 215.0) {
		tmp = z * (x / -y);
	} else {
		tmp = (x - -4.0) / y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 6.4d-14) then
        tmp = (4.0d0 - x) / y
    else if (x <= 215.0d0) then
        tmp = z * (x / -y)
    else
        tmp = (x - (-4.0d0)) / y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= 6.4e-14) {
		tmp = (4.0 - x) / y;
	} else if (x <= 215.0) {
		tmp = z * (x / -y);
	} else {
		tmp = (x - -4.0) / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= 6.4e-14:
		tmp = (4.0 - x) / y
	elif x <= 215.0:
		tmp = z * (x / -y)
	else:
		tmp = (x - -4.0) / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= 6.4e-14)
		tmp = Float64(Float64(4.0 - x) / y);
	elseif (x <= 215.0)
		tmp = Float64(z * Float64(x / Float64(-y)));
	else
		tmp = Float64(Float64(x - -4.0) / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= 6.4e-14)
		tmp = (4.0 - x) / y;
	elseif (x <= 215.0)
		tmp = z * (x / -y);
	else
		tmp = (x - -4.0) / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, 6.4e-14], N[(N[(4.0 - x), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[x, 215.0], N[(z * N[(x / (-y)), $MachinePrecision]), $MachinePrecision], N[(N[(x - -4.0), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.4 \cdot 10^{-14}:\\
\;\;\;\;\frac{4 - x}{y}\\

\mathbf{elif}\;x \leq 215:\\
\;\;\;\;z \cdot \frac{x}{-y}\\

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


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

    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/95.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\left(x + -4\right) + x \cdot z}{-y}} \]
    7. Step-by-step derivation
      1. *-commutative53.2%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x - 4}{y}} \]
    10. Step-by-step derivation
      1. sub-neg40.5%

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

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

        \[\leadsto \color{blue}{-\frac{x + -4}{y}} \]
      4. distribute-frac-neg40.5%

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

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

        \[\leadsto \frac{0 - \color{blue}{\left(-4 + x\right)}}{y} \]
      7. associate--r+40.5%

        \[\leadsto \frac{\color{blue}{\left(0 - -4\right) - x}}{y} \]
      8. metadata-eval40.5%

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

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

    if 6.4000000000000005e-14 < x < 215

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto z \cdot \color{blue}{\left(-\frac{x}{y}\right)} \]
      6. add-sqr-sqrt56.9%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-z\right) \cdot \frac{-x}{y}} \]
      13. add-sqr-sqrt0.0%

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

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

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

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

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

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

    if 215 < x

    1. Initial program 84.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}} \cdot \sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}}} \]
      11. rem-square-sqrt37.3%

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

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

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

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

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

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

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

Alternative 10: 48.5% accurate, 7.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -3.1:\\ \;\;\;\;\frac{x \cdot z - x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \left(x \cdot z - 4\right)}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -3.1) (/ (- (* x z) x) y) (/ (- x (- (* x z) 4.0)) y)))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -3.1) {
		tmp = ((x * z) - x) / y;
	} else {
		tmp = (x - ((x * z) - 4.0)) / y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-3.1d0)) then
        tmp = ((x * z) - x) / y
    else
        tmp = (x - ((x * z) - 4.0d0)) / y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -3.1) {
		tmp = ((x * z) - x) / y;
	} else {
		tmp = (x - ((x * z) - 4.0)) / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -3.1:
		tmp = ((x * z) - x) / y
	else:
		tmp = (x - ((x * z) - 4.0)) / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -3.1)
		tmp = Float64(Float64(Float64(x * z) - x) / y);
	else
		tmp = Float64(Float64(x - Float64(Float64(x * z) - 4.0)) / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -3.1)
		tmp = ((x * z) - x) / y;
	else
		tmp = (x - ((x * z) - 4.0)) / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -3.1], N[(N[(N[(x * z), $MachinePrecision] - x), $MachinePrecision] / y), $MachinePrecision], N[(N[(x - N[(N[(x * z), $MachinePrecision] - 4.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 85.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.10000000000000009 < x

    1. Initial program 91.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}} \cdot \sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}}} \]
      11. rem-square-sqrt48.0%

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

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

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

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

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

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

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

Alternative 11: 34.8% accurate, 8.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -8.5 \cdot 10^{-5}:\\ \;\;\;\;z \cdot \frac{x}{y}\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\frac{4}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -8.5e-5) (* z (/ x y)) (if (<= x 4.0) (/ 4.0 y) (/ x y))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -8.5e-5) {
		tmp = z * (x / y);
	} else if (x <= 4.0) {
		tmp = 4.0 / y;
	} else {
		tmp = x / y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-8.5d-5)) then
        tmp = z * (x / y)
    else if (x <= 4.0d0) then
        tmp = 4.0d0 / y
    else
        tmp = x / y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -8.5e-5) {
		tmp = z * (x / y);
	} else if (x <= 4.0) {
		tmp = 4.0 / y;
	} else {
		tmp = x / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -8.5e-5:
		tmp = z * (x / y)
	elif x <= 4.0:
		tmp = 4.0 / y
	else:
		tmp = x / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -8.5e-5)
		tmp = Float64(z * Float64(x / y));
	elseif (x <= 4.0)
		tmp = Float64(4.0 / y);
	else
		tmp = Float64(x / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -8.5e-5)
		tmp = z * (x / y);
	elseif (x <= 4.0)
		tmp = 4.0 / y;
	else
		tmp = x / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -8.5e-5], N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.0], N[(4.0 / y), $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{-5}:\\
\;\;\;\;z \cdot \frac{x}{y}\\

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

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


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

    1. Initial program 85.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{-x} \cdot \sqrt{-x}}}{y} \cdot z \]
      7. sqrt-unprod33.4%

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

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

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

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

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

    if -8.500000000000001e-5 < x < 4

    1. Initial program 94.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}} \cdot \sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}}} \]
      11. rem-square-sqrt52.1%

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

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

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

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

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

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

    if 4 < x

    1. Initial program 84.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}} \cdot \sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}}} \]
      11. rem-square-sqrt38.4%

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

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

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

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

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

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

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

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

Alternative 12: 35.1% accurate, 11.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{4 - x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - -4}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -4.0) (/ (- 4.0 x) y) (/ (- x -4.0) y)))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = (4.0 - x) / y;
	} else {
		tmp = (x - -4.0) / y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-4.0d0)) then
        tmp = (4.0d0 - x) / y
    else
        tmp = (x - (-4.0d0)) / y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = (4.0 - x) / y;
	} else {
		tmp = (x - -4.0) / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -4.0:
		tmp = (4.0 - x) / y
	else:
		tmp = (x - -4.0) / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -4.0)
		tmp = Float64(Float64(4.0 - x) / y);
	else
		tmp = Float64(Float64(x - -4.0) / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -4.0)
		tmp = (4.0 - x) / y;
	else
		tmp = (x - -4.0) / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -4.0], N[(N[(4.0 - x), $MachinePrecision] / y), $MachinePrecision], N[(N[(x - -4.0), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 85.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x - 4}{y}} \]
    10. Step-by-step derivation
      1. sub-neg42.9%

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

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

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

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

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

        \[\leadsto \frac{0 - \color{blue}{\left(-4 + x\right)}}{y} \]
      7. associate--r+42.9%

        \[\leadsto \frac{\color{blue}{\left(0 - -4\right) - x}}{y} \]
      8. metadata-eval42.9%

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

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

    if -4 < x

    1. Initial program 91.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}} \cdot \sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}}} \]
      11. rem-square-sqrt48.0%

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

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

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

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

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

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

Alternative 13: 34.8% accurate, 11.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2:\\ \;\;\;\;\frac{4 - x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
(FPCore (x y z) :precision binary64 (if (<= x 2.0) (/ (- 4.0 x) y) (/ x y)))
double code(double x, double y, double z) {
	double tmp;
	if (x <= 2.0) {
		tmp = (4.0 - x) / y;
	} else {
		tmp = x / y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 2.0d0) then
        tmp = (4.0d0 - x) / y
    else
        tmp = x / y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= 2.0) {
		tmp = (4.0 - x) / y;
	} else {
		tmp = x / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= 2.0:
		tmp = (4.0 - x) / y
	else:
		tmp = x / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= 2.0)
		tmp = Float64(Float64(4.0 - x) / y);
	else
		tmp = Float64(x / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= 2.0)
		tmp = (4.0 - x) / y;
	else
		tmp = x / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, 2.0], N[(N[(4.0 - x), $MachinePrecision] / y), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 91.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x - 4}{y}} \]
    10. Step-by-step derivation
      1. sub-neg39.4%

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

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

        \[\leadsto \color{blue}{-\frac{x + -4}{y}} \]
      4. distribute-frac-neg39.4%

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

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

        \[\leadsto \frac{0 - \color{blue}{\left(-4 + x\right)}}{y} \]
      7. associate--r+39.4%

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

        \[\leadsto \frac{\color{blue}{4} - x}{y} \]
    11. Simplified39.4%

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

    if 2 < x

    1. Initial program 84.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}} \cdot \sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}}} \]
      11. rem-square-sqrt38.4%

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

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

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

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

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

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

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

Alternative 14: 27.9% accurate, 13.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 4:\\ \;\;\;\;\frac{4}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
(FPCore (x y z) :precision binary64 (if (<= x 4.0) (/ 4.0 y) (/ x y)))
double code(double x, double y, double z) {
	double tmp;
	if (x <= 4.0) {
		tmp = 4.0 / y;
	} else {
		tmp = x / y;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= 4.0d0) then
        tmp = 4.0d0 / y
    else
        tmp = x / y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= 4.0) {
		tmp = 4.0 / y;
	} else {
		tmp = x / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= 4.0:
		tmp = 4.0 / y
	else:
		tmp = x / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= 4.0)
		tmp = Float64(4.0 / y);
	else
		tmp = Float64(x / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= 4.0)
		tmp = 4.0 / y;
	else
		tmp = x / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, 4.0], N[(4.0 / y), $MachinePrecision], N[(x / y), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 91.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}} \cdot \sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}}} \]
      11. rem-square-sqrt49.9%

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

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

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

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

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

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

    if 4 < x

    1. Initial program 84.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}} \cdot \sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}}} \]
      11. rem-square-sqrt38.4%

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

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

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

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

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

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

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

Alternative 15: 21.1% accurate, 37.0× speedup?

\[\begin{array}{l} \\ \frac{4}{y} \end{array} \]
(FPCore (x y z) :precision binary64 (/ 4.0 y))
double code(double x, double y, double z) {
	return 4.0 / y;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = 4.0d0 / y
end function
public static double code(double x, double y, double z) {
	return 4.0 / y;
}
def code(x, y, z):
	return 4.0 / y
function code(x, y, z)
	return Float64(4.0 / y)
end
function tmp = code(x, y, z)
	tmp = 4.0 / y;
end
code[x_, y_, z_] := N[(4.0 / y), $MachinePrecision]
\begin{array}{l}

\\
\frac{4}{y}
\end{array}
Derivation
  1. Initial program 90.2%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}} \cdot \sqrt{\frac{\mathsf{fma}\left(x, z, -4 - x\right)}{-y}}} \]
    11. rem-square-sqrt47.3%

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{4}}{y} \]
  8. Add Preprocessing

Reproduce

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