Variable introduction convention to reduce redundant terms

30 Views Asked by At

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?

1

There are 1 best solutions below

2
On BEST ANSWER

Strictly speaking, as long as you define your convention clearly in your work you can do whatever you want. However it's good to make it readable, easy to work with and not clash with any other notation that you will be using (i.e. don't use prime notation for labeling constants in calculus since it's usually reserved for labeling derivatives).

For example you can label those terms that you mentioned as $f_a$ and $f_b$ respectively (I called it $f$ for "floor" and the $a$ and $b$ are for the denominator). But this is just what I would do, like I said you can do whatever you like as long as it's not confusing to look at or cumbersome to work with.