1

Once in a while I need to implement more or less complex math formulas in various programming languages. To ensure that some time later I'm still able to read and understand my code, I strive to give my variables meaningful names.

Sometimes, the term 1 - x is precalculated and stored in a variable but to this day I have not come up with a good name for that variable. Therefore, my question is, does this term have a name in mathematics?

To be more specific, let me make an example. Let's say the formula I implement uses both the terms sin(angle) and 1 - sin(angle) multiple times. In that case I would write it as follows:

float sinus    = sin(angle);
float whatever = 1 - sinus;

// formula with multiple uses of 'sinus' and whatever

What would be a mathematically understandable name for whatever?

And yes, I know that whatever is just a variable that can be named arbitrarily and many will say it doesn't matter much. But I'm curious if there is a descriptive name given by mathematics.

ackh
  • 133
  • 3
    You don't want a name like oneminusx ? – GEdgar Jun 16 '23 at 15:34
  • 3
    "Complement to one" – Jean Marie Jun 16 '23 at 15:46
  • @GEdgar Well, it is certainly an option if there isn't any meaningful term for it – ackh Jun 16 '23 at 15:52
  • @JeanMarie That sounds promising – ackh Jun 16 '23 at 15:52
  • 2
    Sometimes the function $1-\sin(x)$ is given the name $\operatorname{coversin}(x)$, but it's a little bit old fashioned and arbitrary. – Theo Diamantakis Jun 16 '23 at 15:53
  • 1
    Generally speaking, individual formulas do not have names. This one, indeed, has no name. So have at it, use whatever name makes sense to you (or to someone in the future who, perhaps, may use your code). – Lee Mosher Jun 16 '23 at 15:59
  • If I had to describe it in words other than "the line $x+y=1$", I would probably just say "diagonal" because a diagonal of the unit square (https://mathworld.wolfram.com/UnitSquare.html) sits on the line $x+y=1$. Or maybe something like "diagonal shift" because it is a shift by 1 from the line $x+y=0$ which is a diagonal of the "square" $(\infty,\infty)$, $(-\infty,\infty)$, $(-\infty, -\infty)$, $(\infty,-\infty)$. – Randy Marsh Jun 16 '23 at 16:17
  • Naming mathematical expressions or variables in programming is an art. The two first comments above are in my personal short list. – Kurt G. Jun 16 '23 at 17:39
  • 1
    Incidentally, your "whatever" is the "coversine", though essentially no one uses that term today. – Mark S. Jun 16 '23 at 20:25

0 Answers0