fabs fraction 1

Percentage Accurate: 92.0% → 99.0%
Time: 10.7s
Alternatives: 18
Speedup: 0.5×

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 18 alternatives:

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

Initial Program: 92.0% accurate, 1.0× speedup?

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

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

Alternative 1: 99.0% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x + 4}{y}\\
t_1 := \left|t\_0 - z \cdot \frac{x}{y}\right|\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{-124}:\\
\;\;\;\;\left|t\_0 - \frac{x}{\frac{y}{z}}\right|\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+299}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))) < 1.99999999999999987e-124

    1. Initial program 83.7%

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

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

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

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

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

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

    if 1.99999999999999987e-124 < (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))) < 2.0000000000000001e299

    1. Initial program 99.9%

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

    if 2.0000000000000001e299 < (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)))

    1. Initial program 71.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.2% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z))) < 2.0000000000000001e299

    1. Initial program 97.0%

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

    if 2.0000000000000001e299 < (fabs.f64 (-.f64 (/.f64 (+.f64 x #s(literal 4 binary64)) y) (*.f64 (/.f64 x y) z)))

    1. Initial program 71.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 97.8% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.4 \cdot 10^{-58}:\\
\;\;\;\;\left|\frac{-1}{y} \cdot \mathsf{fma}\left(x, z, -4 - x\right)\right|\\

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


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

    1. Initial program 89.9%

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

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

    if 3.39999999999999973e-58 < y

    1. Initial program 96.2%

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 97.6% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.3 \cdot 10^{-76}:\\
\;\;\;\;\left|\frac{-1}{y} \cdot \mathsf{fma}\left(x, z, -4 - x\right)\right|\\

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


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

    1. Initial program 89.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

    if 1.3e-76 < y

    1. Initial program 96.5%

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

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

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

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

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

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

Alternative 5: 74.6% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.3 \cdot 10^{-11} \lor \neg \left(x \leq 3 \cdot 10^{-11}\right):\\
\;\;\;\;\left|\frac{x}{y} \cdot \left(-1 + z\right)\right|\\

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


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

    1. Initial program 88.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left|\left(-1 + \color{blue}{\left(-\left(-z\right)\right)}\right) \cdot \frac{x}{y}\right| \]
      15. remove-double-neg99.3%

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

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

    if -3.3000000000000002e-11 < x < 3e-11

    1. Initial program 95.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 50.8% accurate, 4.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{-1 + z}{\frac{y}{x}}\\ \mathbf{elif}\;x \leq 10^{+31}:\\ \;\;\;\;\frac{x + 4}{y} + \frac{-1}{y} \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(1 - z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -4.0)
   (/ (+ -1.0 z) (/ y x))
   (if (<= x 1e+31)
     (+ (/ (+ x 4.0) y) (* (/ -1.0 y) (* x z)))
     (* (/ x y) (- 1.0 z)))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = (-1.0 + z) / (y / x);
	} else if (x <= 1e+31) {
		tmp = ((x + 4.0) / y) + ((-1.0 / y) * (x * z));
	} else {
		tmp = (x / y) * (1.0 - z);
	}
	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 = ((-1.0d0) + z) / (y / x)
    else if (x <= 1d+31) then
        tmp = ((x + 4.0d0) / y) + (((-1.0d0) / y) * (x * z))
    else
        tmp = (x / y) * (1.0d0 - z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = (-1.0 + z) / (y / x);
	} else if (x <= 1e+31) {
		tmp = ((x + 4.0) / y) + ((-1.0 / y) * (x * z));
	} else {
		tmp = (x / y) * (1.0 - z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -4.0:
		tmp = (-1.0 + z) / (y / x)
	elif x <= 1e+31:
		tmp = ((x + 4.0) / y) + ((-1.0 / y) * (x * z))
	else:
		tmp = (x / y) * (1.0 - z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -4.0)
		tmp = Float64(Float64(-1.0 + z) / Float64(y / x));
	elseif (x <= 1e+31)
		tmp = Float64(Float64(Float64(x + 4.0) / y) + Float64(Float64(-1.0 / y) * Float64(x * z)));
	else
		tmp = Float64(Float64(x / y) * Float64(1.0 - z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -4.0)
		tmp = (-1.0 + z) / (y / x);
	elseif (x <= 1e+31)
		tmp = ((x + 4.0) / y) + ((-1.0 / y) * (x * z));
	else
		tmp = (x / y) * (1.0 - z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -4.0], N[(N[(-1.0 + z), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1e+31], N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] + N[(N[(-1.0 / y), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 87.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4 < x < 9.9999999999999996e30

    1. Initial program 95.5%

      \[\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. Step-by-step derivation
      1. add-sqr-sqrt45.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999996e30 < x

    1. Initial program 87.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt48.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| \]
      13. fabs-sqr48.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}} \]
      14. add-sqr-sqrt49.4%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y} - \frac{x}{y} \cdot \left(-z\right)} \]
      9. *-un-lft-identity41.8%

        \[\leadsto \color{blue}{1 \cdot \frac{x}{y}} - \frac{x}{y} \cdot \left(-z\right) \]
      10. *-commutative41.8%

        \[\leadsto 1 \cdot \frac{x}{y} - \color{blue}{\left(-z\right) \cdot \frac{x}{y}} \]
      11. distribute-rgt-out--51.1%

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

        \[\leadsto \frac{x}{y} \cdot \left(1 - \color{blue}{\sqrt{-z} \cdot \sqrt{-z}}\right) \]
      13. sqrt-unprod42.3%

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

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

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

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

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

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

Alternative 7: 50.8% accurate, 5.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5.8:\\ \;\;\;\;\frac{-1 + z}{\frac{y}{x}}\\ \mathbf{elif}\;x \leq 5 \cdot 10^{+25}:\\ \;\;\;\;\frac{\left(x + 4\right) - x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(1 - z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -5.8)
   (/ (+ -1.0 z) (/ y x))
   (if (<= x 5e+25) (/ (- (+ x 4.0) (* x z)) y) (* (/ x y) (- 1.0 z)))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -5.8) {
		tmp = (-1.0 + z) / (y / x);
	} else if (x <= 5e+25) {
		tmp = ((x + 4.0) - (x * z)) / y;
	} else {
		tmp = (x / y) * (1.0 - z);
	}
	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 <= (-5.8d0)) then
        tmp = ((-1.0d0) + z) / (y / x)
    else if (x <= 5d+25) then
        tmp = ((x + 4.0d0) - (x * z)) / y
    else
        tmp = (x / y) * (1.0d0 - z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -5.8) {
		tmp = (-1.0 + z) / (y / x);
	} else if (x <= 5e+25) {
		tmp = ((x + 4.0) - (x * z)) / y;
	} else {
		tmp = (x / y) * (1.0 - z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -5.8:
		tmp = (-1.0 + z) / (y / x)
	elif x <= 5e+25:
		tmp = ((x + 4.0) - (x * z)) / y
	else:
		tmp = (x / y) * (1.0 - z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -5.8)
		tmp = Float64(Float64(-1.0 + z) / Float64(y / x));
	elseif (x <= 5e+25)
		tmp = Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y);
	else
		tmp = Float64(Float64(x / y) * Float64(1.0 - z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -5.8)
		tmp = (-1.0 + z) / (y / x);
	elseif (x <= 5e+25)
		tmp = ((x + 4.0) - (x * z)) / y;
	else
		tmp = (x / y) * (1.0 - z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -5.8], N[(N[(-1.0 + z), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5e+25], N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 87.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.79999999999999982 < x < 5.00000000000000024e25

    1. Initial program 95.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt42.0%

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

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

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

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

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

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

    if 5.00000000000000024e25 < x

    1. Initial program 88.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt48.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| \]
      13. fabs-sqr48.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}} \]
      14. add-sqr-sqrt49.5%

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{y}} + \frac{x}{y} \cdot \left(-z\right) \]
    8. Step-by-step derivation
      1. distribute-rgt-neg-out49.5%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y} - \frac{x}{y} \cdot \left(-z\right)} \]
      9. *-un-lft-identity40.6%

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

        \[\leadsto 1 \cdot \frac{x}{y} - \color{blue}{\left(-z\right) \cdot \frac{x}{y}} \]
      11. distribute-rgt-out--49.6%

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

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

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

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

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

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

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

Alternative 8: 50.4% accurate, 6.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1350:\\ \;\;\;\;\frac{-1 + z}{\frac{y}{x}}\\ \mathbf{elif}\;x \leq 0.000225:\\ \;\;\;\;\frac{4 - x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(1 - z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -1350.0)
   (/ (+ -1.0 z) (/ y x))
   (if (<= x 0.000225) (/ (- 4.0 (* x z)) y) (* (/ x y) (- 1.0 z)))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -1350.0) {
		tmp = (-1.0 + z) / (y / x);
	} else if (x <= 0.000225) {
		tmp = (4.0 - (x * z)) / y;
	} else {
		tmp = (x / y) * (1.0 - z);
	}
	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 <= (-1350.0d0)) then
        tmp = ((-1.0d0) + z) / (y / x)
    else if (x <= 0.000225d0) then
        tmp = (4.0d0 - (x * z)) / y
    else
        tmp = (x / y) * (1.0d0 - z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -1350.0) {
		tmp = (-1.0 + z) / (y / x);
	} else if (x <= 0.000225) {
		tmp = (4.0 - (x * z)) / y;
	} else {
		tmp = (x / y) * (1.0 - z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -1350.0:
		tmp = (-1.0 + z) / (y / x)
	elif x <= 0.000225:
		tmp = (4.0 - (x * z)) / y
	else:
		tmp = (x / y) * (1.0 - z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -1350.0)
		tmp = Float64(Float64(-1.0 + z) / Float64(y / x));
	elseif (x <= 0.000225)
		tmp = Float64(Float64(4.0 - Float64(x * z)) / y);
	else
		tmp = Float64(Float64(x / y) * Float64(1.0 - z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -1350.0)
		tmp = (-1.0 + z) / (y / x);
	elseif (x <= 0.000225)
		tmp = (4.0 - (x * z)) / y;
	else
		tmp = (x / y) * (1.0 - z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -1350.0], N[(N[(-1.0 + z), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.000225], N[(N[(4.0 - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 87.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1350 < x < 2.2499999999999999e-4

    1. Initial program 95.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt42.3%

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

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

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

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

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

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

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

    if 2.2499999999999999e-4 < x

    1. Initial program 89.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt47.6%

        \[\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| \]
      13. fabs-sqr47.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{y}} + \frac{x}{y} \cdot \left(-z\right) \]
    8. Step-by-step derivation
      1. distribute-rgt-neg-out48.3%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y} - \frac{x}{y} \cdot \left(-z\right)} \]
      9. *-un-lft-identity41.7%

        \[\leadsto \color{blue}{1 \cdot \frac{x}{y}} - \frac{x}{y} \cdot \left(-z\right) \]
      10. *-commutative41.7%

        \[\leadsto 1 \cdot \frac{x}{y} - \color{blue}{\left(-z\right) \cdot \frac{x}{y}} \]
      11. distribute-rgt-out--49.7%

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

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

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

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

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

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

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

Alternative 9: 44.2% accurate, 6.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.9 \cdot 10^{-11}:\\ \;\;\;\;\frac{x}{\frac{y}{-1 + z}}\\ \mathbf{elif}\;x \leq 0.000205:\\ \;\;\;\;\frac{x}{y} + \frac{4}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(1 - z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -2.9e-11)
   (/ x (/ y (+ -1.0 z)))
   (if (<= x 0.000205) (+ (/ x y) (/ 4.0 y)) (* (/ x y) (- 1.0 z)))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -2.9e-11) {
		tmp = x / (y / (-1.0 + z));
	} else if (x <= 0.000205) {
		tmp = (x / y) + (4.0 / y);
	} else {
		tmp = (x / y) * (1.0 - z);
	}
	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.9d-11)) then
        tmp = x / (y / ((-1.0d0) + z))
    else if (x <= 0.000205d0) then
        tmp = (x / y) + (4.0d0 / y)
    else
        tmp = (x / y) * (1.0d0 - z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -2.9e-11) {
		tmp = x / (y / (-1.0 + z));
	} else if (x <= 0.000205) {
		tmp = (x / y) + (4.0 / y);
	} else {
		tmp = (x / y) * (1.0 - z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -2.9e-11:
		tmp = x / (y / (-1.0 + z))
	elif x <= 0.000205:
		tmp = (x / y) + (4.0 / y)
	else:
		tmp = (x / y) * (1.0 - z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -2.9e-11)
		tmp = Float64(x / Float64(y / Float64(-1.0 + z)));
	elseif (x <= 0.000205)
		tmp = Float64(Float64(x / y) + Float64(4.0 / y));
	else
		tmp = Float64(Float64(x / y) * Float64(1.0 - z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -2.9e-11)
		tmp = x / (y / (-1.0 + z));
	elseif (x <= 0.000205)
		tmp = (x / y) + (4.0 / y);
	else
		tmp = (x / y) * (1.0 - z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -2.9e-11], N[(x / N[(y / N[(-1.0 + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.000205], N[(N[(x / y), $MachinePrecision] + N[(4.0 / y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 88.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{z + -1}{y}} \]
      8. clear-num61.6%

        \[\leadsto x \cdot \color{blue}{\frac{1}{\frac{y}{z + -1}}} \]
      9. un-div-inv61.8%

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

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

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

    if -2.9e-11 < x < 2.05e-4

    1. Initial program 95.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt41.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y} + \frac{4}{y}} \]
    10. Simplified38.3%

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

    if 2.05e-4 < x

    1. Initial program 89.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt47.6%

        \[\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| \]
      13. fabs-sqr47.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{y}} + \frac{x}{y} \cdot \left(-z\right) \]
    8. Step-by-step derivation
      1. distribute-rgt-neg-out48.3%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y} - \frac{x}{y} \cdot \left(-z\right)} \]
      9. *-un-lft-identity41.7%

        \[\leadsto \color{blue}{1 \cdot \frac{x}{y}} - \frac{x}{y} \cdot \left(-z\right) \]
      10. *-commutative41.7%

        \[\leadsto 1 \cdot \frac{x}{y} - \color{blue}{\left(-z\right) \cdot \frac{x}{y}} \]
      11. distribute-rgt-out--49.7%

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

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

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

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

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

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

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

Alternative 10: 44.2% accurate, 6.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -3.4 \cdot 10^{-11}:\\ \;\;\;\;x \cdot \frac{-1 + z}{y}\\ \mathbf{elif}\;x \leq 0.000225:\\ \;\;\;\;\frac{x}{y} + \frac{4}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(1 - z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -3.4e-11)
   (* x (/ (+ -1.0 z) y))
   (if (<= x 0.000225) (+ (/ x y) (/ 4.0 y)) (* (/ x y) (- 1.0 z)))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -3.4e-11) {
		tmp = x * ((-1.0 + z) / y);
	} else if (x <= 0.000225) {
		tmp = (x / y) + (4.0 / y);
	} else {
		tmp = (x / y) * (1.0 - z);
	}
	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.4d-11)) then
        tmp = x * (((-1.0d0) + z) / y)
    else if (x <= 0.000225d0) then
        tmp = (x / y) + (4.0d0 / y)
    else
        tmp = (x / y) * (1.0d0 - z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -3.4e-11) {
		tmp = x * ((-1.0 + z) / y);
	} else if (x <= 0.000225) {
		tmp = (x / y) + (4.0 / y);
	} else {
		tmp = (x / y) * (1.0 - z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -3.4e-11:
		tmp = x * ((-1.0 + z) / y)
	elif x <= 0.000225:
		tmp = (x / y) + (4.0 / y)
	else:
		tmp = (x / y) * (1.0 - z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -3.4e-11)
		tmp = Float64(x * Float64(Float64(-1.0 + z) / y));
	elseif (x <= 0.000225)
		tmp = Float64(Float64(x / y) + Float64(4.0 / y));
	else
		tmp = Float64(Float64(x / y) * Float64(1.0 - z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -3.4e-11)
		tmp = x * ((-1.0 + z) / y);
	elseif (x <= 0.000225)
		tmp = (x / y) + (4.0 / y);
	else
		tmp = (x / y) * (1.0 - z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -3.4e-11], N[(x * N[(N[(-1.0 + z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.000225], N[(N[(x / y), $MachinePrecision] + N[(4.0 / y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 88.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.3999999999999999e-11 < x < 2.2499999999999999e-4

    1. Initial program 95.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt41.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y} + \frac{4}{y}} \]
    10. Simplified38.3%

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

    if 2.2499999999999999e-4 < x

    1. Initial program 89.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt47.6%

        \[\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| \]
      13. fabs-sqr47.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{y}} + \frac{x}{y} \cdot \left(-z\right) \]
    8. Step-by-step derivation
      1. distribute-rgt-neg-out48.3%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y} - \frac{x}{y} \cdot \left(-z\right)} \]
      9. *-un-lft-identity41.7%

        \[\leadsto \color{blue}{1 \cdot \frac{x}{y}} - \frac{x}{y} \cdot \left(-z\right) \]
      10. *-commutative41.7%

        \[\leadsto 1 \cdot \frac{x}{y} - \color{blue}{\left(-z\right) \cdot \frac{x}{y}} \]
      11. distribute-rgt-out--49.7%

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

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

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

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

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

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

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

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

Alternative 11: 44.2% accurate, 6.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -3.4 \cdot 10^{-11}:\\ \;\;\;\;x \cdot \frac{-1 + z}{y}\\ \mathbf{elif}\;x \leq 0.000185:\\ \;\;\;\;\frac{x + 4}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \left(1 - z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -3.4e-11)
   (* x (/ (+ -1.0 z) y))
   (if (<= x 0.000185) (/ (+ x 4.0) y) (* (/ x y) (- 1.0 z)))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -3.4e-11) {
		tmp = x * ((-1.0 + z) / y);
	} else if (x <= 0.000185) {
		tmp = (x + 4.0) / y;
	} else {
		tmp = (x / y) * (1.0 - z);
	}
	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.4d-11)) then
        tmp = x * (((-1.0d0) + z) / y)
    else if (x <= 0.000185d0) then
        tmp = (x + 4.0d0) / y
    else
        tmp = (x / y) * (1.0d0 - z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -3.4e-11) {
		tmp = x * ((-1.0 + z) / y);
	} else if (x <= 0.000185) {
		tmp = (x + 4.0) / y;
	} else {
		tmp = (x / y) * (1.0 - z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -3.4e-11:
		tmp = x * ((-1.0 + z) / y)
	elif x <= 0.000185:
		tmp = (x + 4.0) / y
	else:
		tmp = (x / y) * (1.0 - z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -3.4e-11)
		tmp = Float64(x * Float64(Float64(-1.0 + z) / y));
	elseif (x <= 0.000185)
		tmp = Float64(Float64(x + 4.0) / y);
	else
		tmp = Float64(Float64(x / y) * Float64(1.0 - z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -3.4e-11)
		tmp = x * ((-1.0 + z) / y);
	elseif (x <= 0.000185)
		tmp = (x + 4.0) / y;
	else
		tmp = (x / y) * (1.0 - z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -3.4e-11], N[(x * N[(N[(-1.0 + z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.000185], N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 88.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.3999999999999999e-11 < x < 1.85e-4

    1. Initial program 95.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt41.3%

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

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

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

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

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

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

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

    if 1.85e-4 < x

    1. Initial program 89.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt47.6%

        \[\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| \]
      13. fabs-sqr47.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{y}} + \frac{x}{y} \cdot \left(-z\right) \]
    8. Step-by-step derivation
      1. distribute-rgt-neg-out48.3%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{y} - \frac{x}{y} \cdot \left(-z\right)} \]
      9. *-un-lft-identity41.7%

        \[\leadsto \color{blue}{1 \cdot \frac{x}{y}} - \frac{x}{y} \cdot \left(-z\right) \]
      10. *-commutative41.7%

        \[\leadsto 1 \cdot \frac{x}{y} - \color{blue}{\left(-z\right) \cdot \frac{x}{y}} \]
      11. distribute-rgt-out--49.7%

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

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

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

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

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

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

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

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

Alternative 12: 35.0% accurate, 8.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.55:\\ \;\;\;\;\frac{-1}{y} \cdot x\\ \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 -1.55) (* (/ -1.0 y) x) (if (<= x 4.0) (/ 4.0 y) (/ x y))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -1.55) {
		tmp = (-1.0 / y) * x;
	} 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 <= (-1.55d0)) then
        tmp = ((-1.0d0) / y) * x
    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 <= -1.55) {
		tmp = (-1.0 / y) * x;
	} else if (x <= 4.0) {
		tmp = 4.0 / y;
	} else {
		tmp = x / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -1.55:
		tmp = (-1.0 / y) * x
	elif x <= 4.0:
		tmp = 4.0 / y
	else:
		tmp = x / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -1.55)
		tmp = Float64(Float64(-1.0 / y) * x);
	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 <= -1.55)
		tmp = (-1.0 / y) * x;
	elseif (x <= 4.0)
		tmp = 4.0 / y;
	else
		tmp = x / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -1.55], N[(N[(-1.0 / y), $MachinePrecision] * x), $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 -1.55:\\
\;\;\;\;\frac{-1}{y} \cdot x\\

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

    1. Initial program 87.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y} \]
      9. metadata-eval55.3%

        \[\leadsto \frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y} \]
      10. distribute-neg-in55.3%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y} \]
      11. +-commutative55.3%

        \[\leadsto \frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y} \]
      12. cancel-sign-sub-inv55.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}} \]
      13. div-inv55.5%

        \[\leadsto \frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}} \]
      14. associate-*l/48.7%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
      15. sub-div57.6%

        \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
    6. Applied egg-rr57.6%

      \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
    7. Taylor expanded in x around inf 57.7%

      \[\leadsto \color{blue}{\frac{x \cdot \left(z - 1\right)}{y}} \]
    8. Step-by-step derivation
      1. associate-/l*64.2%

        \[\leadsto \color{blue}{x \cdot \frac{z - 1}{y}} \]
      2. sub-neg64.2%

        \[\leadsto x \cdot \frac{\color{blue}{z + \left(-1\right)}}{y} \]
      3. metadata-eval64.2%

        \[\leadsto x \cdot \frac{z + \color{blue}{-1}}{y} \]
    9. Simplified64.2%

      \[\leadsto \color{blue}{x \cdot \frac{z + -1}{y}} \]
    10. Taylor expanded in z around 0 35.5%

      \[\leadsto x \cdot \color{blue}{\frac{-1}{y}} \]

    if -1.55000000000000004 < x < 4

    1. Initial program 95.2%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub95.2%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/99.9%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/92.5%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def92.6%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac92.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative92.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in92.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg92.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval92.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified92.6%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine92.5%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
      2. associate-*r/99.9%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
      3. associate-*l/95.2%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
      4. div-inv95.2%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
      5. sub-neg95.2%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval95.2%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y}\right| \]
      7. distribute-neg-in95.2%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative95.2%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv95.2%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      10. div-inv95.2%

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub95.2%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt41.7%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      13. fabs-sqr41.7%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt43.0%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/46.6%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div46.6%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr46.6%

      \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    7. Taylor expanded in x around 0 36.7%

      \[\leadsto \color{blue}{\frac{4}{y}} \]

    if 4 < x

    1. Initial program 89.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub89.0%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/82.8%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/91.7%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def93.0%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac93.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative93.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in93.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg93.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval93.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified93.0%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine91.7%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
      2. associate-*r/82.8%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
      3. associate-*l/89.0%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
      4. div-inv88.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
      5. sub-neg88.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval88.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y}\right| \]
      7. distribute-neg-in88.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative88.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv88.8%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      10. div-inv89.0%

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub89.0%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt48.9%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      13. fabs-sqr48.9%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt49.6%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. sub-neg49.6%

        \[\leadsto \color{blue}{\frac{x + 4}{y} + \left(-\frac{x}{y} \cdot z\right)} \]
      16. distribute-rgt-neg-in49.6%

        \[\leadsto \frac{x + 4}{y} + \color{blue}{\frac{x}{y} \cdot \left(-z\right)} \]
    6. Applied egg-rr49.6%

      \[\leadsto \color{blue}{\frac{x + 4}{y} + \frac{x}{y} \cdot \left(-z\right)} \]
    7. Taylor expanded in x around inf 49.6%

      \[\leadsto \color{blue}{\frac{x}{y}} + \frac{x}{y} \cdot \left(-z\right) \]
    8. Taylor expanded in z around 0 37.1%

      \[\leadsto \color{blue}{\frac{x}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification36.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.55:\\ \;\;\;\;\frac{-1}{y} \cdot x\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\frac{4}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 39.9% accurate, 9.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -3.4 \cdot 10^{-11}:\\ \;\;\;\;x \cdot \frac{-1 + z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -3.4e-11) (* x (/ (+ -1.0 z) y)) (/ (+ x 4.0) y)))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -3.4e-11) {
		tmp = x * ((-1.0 + 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 <= (-3.4d-11)) then
        tmp = x * (((-1.0d0) + 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 <= -3.4e-11) {
		tmp = x * ((-1.0 + z) / y);
	} else {
		tmp = (x + 4.0) / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -3.4e-11:
		tmp = x * ((-1.0 + z) / y)
	else:
		tmp = (x + 4.0) / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -3.4e-11)
		tmp = Float64(x * Float64(Float64(-1.0 + 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 <= -3.4e-11)
		tmp = x * ((-1.0 + z) / y);
	else
		tmp = (x + 4.0) / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -3.4e-11], N[(x * N[(N[(-1.0 + z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.4 \cdot 10^{-11}:\\
\;\;\;\;x \cdot \frac{-1 + z}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + 4}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.3999999999999999e-11

    1. Initial program 88.1%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub88.1%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/81.8%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/88.2%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def91.5%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac91.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative91.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in91.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg91.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval91.5%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified91.5%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt54.7%

        \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
      2. fabs-sqr54.7%

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
      3. add-sqr-sqrt55.1%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      4. fma-undefine53.4%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      5. associate-*r/47.1%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      6. associate-*l/53.5%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      7. div-inv53.3%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}} \]
      8. sub-neg53.3%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y} \]
      9. metadata-eval53.3%

        \[\leadsto \frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y} \]
      10. distribute-neg-in53.3%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y} \]
      11. +-commutative53.3%

        \[\leadsto \frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y} \]
      12. cancel-sign-sub-inv53.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}} \]
      13. div-inv53.5%

        \[\leadsto \frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}} \]
      14. associate-*l/47.1%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
      15. sub-div55.5%

        \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
    6. Applied egg-rr55.5%

      \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
    7. Taylor expanded in x around inf 55.5%

      \[\leadsto \color{blue}{\frac{x \cdot \left(z - 1\right)}{y}} \]
    8. Step-by-step derivation
      1. associate-/l*61.6%

        \[\leadsto \color{blue}{x \cdot \frac{z - 1}{y}} \]
      2. sub-neg61.6%

        \[\leadsto x \cdot \frac{\color{blue}{z + \left(-1\right)}}{y} \]
      3. metadata-eval61.6%

        \[\leadsto x \cdot \frac{z + \color{blue}{-1}}{y} \]
    9. Simplified61.6%

      \[\leadsto \color{blue}{x \cdot \frac{z + -1}{y}} \]

    if -3.3999999999999999e-11 < x

    1. Initial program 92.8%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub92.8%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/93.5%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/92.1%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def92.6%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac92.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative92.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in92.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg92.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval92.6%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified92.6%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine92.1%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
      2. associate-*r/93.5%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
      3. associate-*l/92.8%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
      4. div-inv92.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
      5. sub-neg92.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval92.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y}\right| \]
      7. distribute-neg-in92.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative92.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv92.8%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      10. div-inv92.8%

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub92.8%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt43.7%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      13. fabs-sqr43.7%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt44.8%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/45.7%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div47.7%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr47.7%

      \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    7. Taylor expanded in z around 0 37.5%

      \[\leadsto \color{blue}{\frac{4 + x}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification43.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.4 \cdot 10^{-11}:\\ \;\;\;\;x \cdot \frac{-1 + z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 35.5% 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 87.4%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub87.4%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/80.6%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/87.4%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def90.9%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac90.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative90.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in90.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg90.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval90.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified90.9%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt56.8%

        \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
      2. fabs-sqr56.8%

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
      3. add-sqr-sqrt57.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      4. fma-undefine55.4%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      5. associate-*r/48.7%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      6. associate-*l/55.5%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      7. div-inv55.3%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}} \]
      8. sub-neg55.3%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y} \]
      9. metadata-eval55.3%

        \[\leadsto \frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y} \]
      10. distribute-neg-in55.3%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y} \]
      11. +-commutative55.3%

        \[\leadsto \frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y} \]
      12. cancel-sign-sub-inv55.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}} \]
      13. div-inv55.5%

        \[\leadsto \frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}} \]
      14. associate-*l/48.7%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
      15. sub-div57.6%

        \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
    6. Applied egg-rr57.6%

      \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
    7. Taylor expanded in z around 0 35.7%

      \[\leadsto \color{blue}{-1 \cdot \frac{4 + x}{y}} \]
    8. Step-by-step derivation
      1. associate-*r/35.7%

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(4 + x\right)}{y}} \]
      2. distribute-lft-in35.7%

        \[\leadsto \frac{\color{blue}{-1 \cdot 4 + -1 \cdot x}}{y} \]
      3. metadata-eval35.7%

        \[\leadsto \frac{\color{blue}{-4} + -1 \cdot x}{y} \]
      4. neg-mul-135.7%

        \[\leadsto \frac{-4 + \color{blue}{\left(-x\right)}}{y} \]
      5. sub-neg35.7%

        \[\leadsto \frac{\color{blue}{-4 - x}}{y} \]
    9. Simplified35.7%

      \[\leadsto \color{blue}{\frac{-4 - x}{y}} \]

    if -4 < x

    1. Initial program 92.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub92.9%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/93.6%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/92.2%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def92.7%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac92.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative92.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in92.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg92.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval92.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified92.7%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine92.2%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
      2. associate-*r/93.6%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
      3. associate-*l/92.9%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
      4. div-inv92.9%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
      5. sub-neg92.9%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval92.9%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y}\right| \]
      7. distribute-neg-in92.9%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative92.9%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv92.9%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      10. div-inv92.9%

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub92.9%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt44.3%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      13. fabs-sqr44.3%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt45.4%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/46.3%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div48.3%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr48.3%

      \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    7. Taylor expanded in z around 0 36.9%

      \[\leadsto \color{blue}{\frac{4 + x}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification36.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{-4 - x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 35.4% accurate, 11.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{-1}{y} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -4.0) (* (/ -1.0 y) x) (/ (+ x 4.0) y)))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -4.0) {
		tmp = (-1.0 / y) * x;
	} 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 = ((-1.0d0) / y) * x
    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 = (-1.0 / y) * x;
	} else {
		tmp = (x + 4.0) / y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -4.0:
		tmp = (-1.0 / y) * x
	else:
		tmp = (x + 4.0) / y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -4.0)
		tmp = Float64(Float64(-1.0 / y) * x);
	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 = (-1.0 / y) * x;
	else
		tmp = (x + 4.0) / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -4.0], N[(N[(-1.0 / y), $MachinePrecision] * x), $MachinePrecision], N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;\frac{-1}{y} \cdot x\\

\mathbf{else}:\\
\;\;\;\;\frac{x + 4}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4

    1. Initial program 87.4%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub87.4%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/80.6%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/87.4%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def90.9%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac90.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative90.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in90.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg90.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval90.9%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified90.9%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt56.8%

        \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
      2. fabs-sqr56.8%

        \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
      3. add-sqr-sqrt57.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
      4. fma-undefine55.4%

        \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
      5. associate-*r/48.7%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
      6. associate-*l/55.5%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
      7. div-inv55.3%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}} \]
      8. sub-neg55.3%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y} \]
      9. metadata-eval55.3%

        \[\leadsto \frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y} \]
      10. distribute-neg-in55.3%

        \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y} \]
      11. +-commutative55.3%

        \[\leadsto \frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y} \]
      12. cancel-sign-sub-inv55.3%

        \[\leadsto \color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}} \]
      13. div-inv55.5%

        \[\leadsto \frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}} \]
      14. associate-*l/48.7%

        \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
      15. sub-div57.6%

        \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
    6. Applied egg-rr57.6%

      \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
    7. Taylor expanded in x around inf 57.7%

      \[\leadsto \color{blue}{\frac{x \cdot \left(z - 1\right)}{y}} \]
    8. Step-by-step derivation
      1. associate-/l*64.2%

        \[\leadsto \color{blue}{x \cdot \frac{z - 1}{y}} \]
      2. sub-neg64.2%

        \[\leadsto x \cdot \frac{\color{blue}{z + \left(-1\right)}}{y} \]
      3. metadata-eval64.2%

        \[\leadsto x \cdot \frac{z + \color{blue}{-1}}{y} \]
    9. Simplified64.2%

      \[\leadsto \color{blue}{x \cdot \frac{z + -1}{y}} \]
    10. Taylor expanded in z around 0 35.5%

      \[\leadsto x \cdot \color{blue}{\frac{-1}{y}} \]

    if -4 < x

    1. Initial program 92.9%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub92.9%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/93.6%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/92.2%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def92.7%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac92.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative92.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in92.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg92.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval92.7%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified92.7%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine92.2%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
      2. associate-*r/93.6%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
      3. associate-*l/92.9%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
      4. div-inv92.9%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
      5. sub-neg92.9%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval92.9%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y}\right| \]
      7. distribute-neg-in92.9%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative92.9%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv92.9%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      10. div-inv92.9%

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub92.9%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt44.3%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      13. fabs-sqr44.3%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt45.4%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/46.3%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div48.3%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr48.3%

      \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    7. Taylor expanded in z around 0 36.9%

      \[\leadsto \color{blue}{\frac{4 + x}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification36.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4:\\ \;\;\;\;\frac{-1}{y} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{x + 4}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 27.7% 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 92.8%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub92.8%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/94.0%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/91.0%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def92.0%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac92.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative92.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in92.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg92.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval92.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified92.0%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine91.0%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
      2. associate-*r/94.0%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
      3. associate-*l/92.8%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
      4. div-inv92.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
      5. sub-neg92.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval92.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y}\right| \]
      7. distribute-neg-in92.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative92.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv92.8%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      10. div-inv92.8%

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub92.8%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt38.7%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      13. fabs-sqr38.7%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt39.8%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. associate-*l/42.4%

        \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
      16. sub-div43.4%

        \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    6. Applied egg-rr43.4%

      \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
    7. Taylor expanded in x around 0 26.5%

      \[\leadsto \color{blue}{\frac{4}{y}} \]

    if 4 < x

    1. Initial program 89.0%

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Step-by-step derivation
      1. fabs-sub89.0%

        \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
      2. associate-*l/82.8%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
      3. associate-*r/91.7%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
      4. fmm-def93.0%

        \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
      5. distribute-neg-frac93.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
      6. +-commutative93.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
      7. distribute-neg-in93.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
      8. unsub-neg93.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
      9. metadata-eval93.0%

        \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
    3. Simplified93.0%

      \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine91.7%

        \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
      2. associate-*r/82.8%

        \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
      3. associate-*l/89.0%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
      4. div-inv88.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
      5. sub-neg88.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
      6. metadata-eval88.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y}\right| \]
      7. distribute-neg-in88.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
      8. +-commutative88.8%

        \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
      9. cancel-sign-sub-inv88.8%

        \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
      10. div-inv89.0%

        \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
      11. fabs-sub89.0%

        \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
      12. add-sqr-sqrt48.9%

        \[\leadsto \left|\color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}}\right| \]
      13. fabs-sqr48.9%

        \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
      14. add-sqr-sqrt49.6%

        \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
      15. sub-neg49.6%

        \[\leadsto \color{blue}{\frac{x + 4}{y} + \left(-\frac{x}{y} \cdot z\right)} \]
      16. distribute-rgt-neg-in49.6%

        \[\leadsto \frac{x + 4}{y} + \color{blue}{\frac{x}{y} \cdot \left(-z\right)} \]
    6. Applied egg-rr49.6%

      \[\leadsto \color{blue}{\frac{x + 4}{y} + \frac{x}{y} \cdot \left(-z\right)} \]
    7. Taylor expanded in x around inf 49.6%

      \[\leadsto \color{blue}{\frac{x}{y}} + \frac{x}{y} \cdot \left(-z\right) \]
    8. Taylor expanded in z around 0 37.1%

      \[\leadsto \color{blue}{\frac{x}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 17: 20.6% 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 91.7%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Step-by-step derivation
    1. fabs-sub91.7%

      \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
    2. associate-*l/90.8%

      \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
    3. associate-*r/91.2%

      \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
    4. fmm-def92.3%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
    5. distribute-neg-frac92.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
    6. +-commutative92.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
    7. distribute-neg-in92.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
    8. unsub-neg92.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
    9. metadata-eval92.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
  3. Simplified92.3%

    \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. fma-undefine91.2%

      \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}}\right| \]
    2. associate-*r/90.8%

      \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y}\right| \]
    3. associate-*l/91.7%

      \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y}\right| \]
    4. div-inv91.6%

      \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}}\right| \]
    5. sub-neg91.6%

      \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y}\right| \]
    6. metadata-eval91.6%

      \[\leadsto \left|\frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y}\right| \]
    7. distribute-neg-in91.6%

      \[\leadsto \left|\frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y}\right| \]
    8. +-commutative91.6%

      \[\leadsto \left|\frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y}\right| \]
    9. cancel-sign-sub-inv91.6%

      \[\leadsto \left|\color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}}\right| \]
    10. div-inv91.7%

      \[\leadsto \left|\frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}}\right| \]
    11. fabs-sub91.7%

      \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]
    12. add-sqr-sqrt41.6%

      \[\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| \]
    13. fabs-sqr41.6%

      \[\leadsto \color{blue}{\sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \cdot \sqrt{\frac{x + 4}{y} - \frac{x}{y} \cdot z}} \]
    14. add-sqr-sqrt42.6%

      \[\leadsto \color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z} \]
    15. associate-*l/43.3%

      \[\leadsto \frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}} \]
    16. sub-div45.6%

      \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
  6. Applied egg-rr45.6%

    \[\leadsto \color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}} \]
  7. Taylor expanded in x around 0 19.8%

    \[\leadsto \color{blue}{\frac{4}{y}} \]
  8. Add Preprocessing

Alternative 18: 20.7% 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 91.7%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Step-by-step derivation
    1. fabs-sub91.7%

      \[\leadsto \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]
    2. associate-*l/90.8%

      \[\leadsto \left|\color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y}\right| \]
    3. associate-*r/91.2%

      \[\leadsto \left|\color{blue}{x \cdot \frac{z}{y}} - \frac{x + 4}{y}\right| \]
    4. fmm-def92.3%

      \[\leadsto \left|\color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, -\frac{x + 4}{y}\right)}\right| \]
    5. distribute-neg-frac92.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \color{blue}{\frac{-\left(x + 4\right)}{y}}\right)\right| \]
    6. +-commutative92.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-\color{blue}{\left(4 + x\right)}}{y}\right)\right| \]
    7. distribute-neg-in92.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) + \left(-x\right)}}{y}\right)\right| \]
    8. unsub-neg92.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{\left(-4\right) - x}}{y}\right)\right| \]
    9. metadata-eval92.3%

      \[\leadsto \left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{\color{blue}{-4} - x}{y}\right)\right| \]
  3. Simplified92.3%

    \[\leadsto \color{blue}{\left|\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)\right|} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. add-sqr-sqrt50.2%

      \[\leadsto \left|\color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}}\right| \]
    2. fabs-sqr50.2%

      \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \cdot \sqrt{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)}} \]
    3. add-sqr-sqrt51.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{z}{y}, \frac{-4 - x}{y}\right)} \]
    4. fma-undefine50.2%

      \[\leadsto \color{blue}{x \cdot \frac{z}{y} + \frac{-4 - x}{y}} \]
    5. associate-*r/48.8%

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} + \frac{-4 - x}{y} \]
    6. associate-*l/50.4%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot z} + \frac{-4 - x}{y} \]
    7. div-inv50.4%

      \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 - x\right) \cdot \frac{1}{y}} \]
    8. sub-neg50.4%

      \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-4 + \left(-x\right)\right)} \cdot \frac{1}{y} \]
    9. metadata-eval50.4%

      \[\leadsto \frac{x}{y} \cdot z + \left(\color{blue}{\left(-4\right)} + \left(-x\right)\right) \cdot \frac{1}{y} \]
    10. distribute-neg-in50.4%

      \[\leadsto \frac{x}{y} \cdot z + \color{blue}{\left(-\left(4 + x\right)\right)} \cdot \frac{1}{y} \]
    11. +-commutative50.4%

      \[\leadsto \frac{x}{y} \cdot z + \left(-\color{blue}{\left(x + 4\right)}\right) \cdot \frac{1}{y} \]
    12. cancel-sign-sub-inv50.4%

      \[\leadsto \color{blue}{\frac{x}{y} \cdot z - \left(x + 4\right) \cdot \frac{1}{y}} \]
    13. div-inv50.4%

      \[\leadsto \frac{x}{y} \cdot z - \color{blue}{\frac{x + 4}{y}} \]
    14. associate-*l/48.8%

      \[\leadsto \color{blue}{\frac{x \cdot z}{y}} - \frac{x + 4}{y} \]
    15. sub-div51.5%

      \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
  6. Applied egg-rr51.5%

    \[\leadsto \color{blue}{\frac{x \cdot z - \left(x + 4\right)}{y}} \]
  7. Taylor expanded in x around 0 22.2%

    \[\leadsto \color{blue}{\frac{-4}{y}} \]
  8. Add Preprocessing

Reproduce

?
herbie shell --seed 2024154 
(FPCore (x y z)
  :name "fabs fraction 1"
  :precision binary64
  (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))