Is there some guideline or mathematical norm for when to introduce new variables in order to reduce redundancy in an expression or equation?
Say I have the function:
$S(n)=a\left(\frac{\left\lfloor\frac{n-1}{a}\right\rfloor\left(\left\lfloor\frac{n-1}{a}\right\rfloor+1\right)}{2}\right)+b\left(\frac{\left\lfloor\frac{n-1}{b}\right\rfloor\left(\left\lfloor\frac{n-1}{b}\right\rfloor+1\right)}{2}\right).$
In function $S$, I have two repeated terms—$\left\lfloor\frac{n-1}{a}\right\rfloor$ and $\left\lfloor\frac{n-1}{b}\right\rfloor$—which are relatively similar in nature. Should I split this into a seperate function? Should I introduce this two as variables?
What is the convention for these types of redundancies?
Would you say this is okay? Any comments?
– Shon Verch Jun 09 '18 at 14:22