-1
$\begingroup$

In an optimization program I pass around distance values quite often. In my case these are simple 2D Euclidean distances $\sqrt{\Delta x^2+\Delta y^2}$. Since I want to perform the square root calculation only at the end of all operations, I pass only squared distances $(\Delta x^2+\Delta y^2)$ around in the program.

Right now I'm using the variable name dist for distances and dist2 for squared distances, where dist2 is intended to mean dist$^2$.

Is this a mathematically good choice of naming, or is there a more commonly used name for this?

(Such as sqdist? Or sed = squared Euclidean distance? Or sos = sum of squares?)

$\endgroup$
3
  • 4
    $\begingroup$ you can name it anything you want in a computer program, as long as you don't use the same symbol twice. $\endgroup$ Oct 5, 2017 at 10:38
  • $\begingroup$ in statistics it is known as variance ... $\endgroup$ Oct 5, 2017 at 11:28
  • $\begingroup$ @CarloBeenakker Was this meant to be a helpful comment? Anyway, from a software engineering perspective, I strongly disagree. Choosing good variable names is especially important in computer programs, especially if these are meant to be reviewed, extended and maintained by other people. $\endgroup$
    – vog
    Oct 6, 2017 at 10:01

1 Answer 1

5
$\begingroup$

Norm Wildberger calls it quadrance. But at this point I wouldn't say that's a commonly used name for it.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.