1

What's the purpose (or the origin) of the use habit of i, j, k or for example n, m as indexes for math equations in general? Also this is carried into programing languajes. For example to do a simple for, we commonly use:

for i in rows: 
  for j in columns: 

to iterate over matrixes. I mean, why we don't use a,b,c or e,f,g, etc as indexes?

2 Answers2

4

Back in the day, Fortran had implicit typing rules which said that a variable with a name starting with I, J, K, L, M or N would be assumed to be an integer variable unless explicitly declared otherwise - all other variables were assumed by default to be real i.e. floating point numbers (see https://docs.oracle.com/cd/E19957-01/805-4939/z40007365fbc/index.html).

This could explain why it has become conventional to denote loop indices by i, j etc. We could use blick or frump instead but that would be unexpected.

gandalf61
  • 15,326
1

This has to do with the purpose for you with need a symbol or alphabet with which you want to denote a mathematical entity. Examples:

When we want to denote a number tend to think of the letter n because that is the first letter of the word number.

Similarly, when we want to denote a prime number number theorist usually use the letter p because that is the first letter of the word prime.

When we want to denote an iterative step/process which repeats a finite or infinite a number tend to think of the letter i because that is the first letter of the word iteration.

Naturally when you want to denote the second iterative step/process within the same calculations we tend to think of the letter j because we have already used up i so be automatically go to the next available letter j. Similarly we have one more iterative step, k is the logically the next preferred letter.