The Common Mean and APL
Vector 11:4, page 123
Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 123
I read with interest Joseph De Kerf’s article "The Common Mean and APL" in the January 1995 Education Vector. The various computations described therein have terse restatements in J:
The arithmetic mean is the number of items divided into the sum; the geometric mean is the n-th root of the product (n is the number of items); and the harmonic mean is the arithmetic mean under reciprocal, i.e. h v ←→ %a%v. All three verbs work on arrays of numbers.
The common mean on a 2-element vector is an iteration where at each step, the elements are replaced by the geometric and arithmetic means. That is, at each step, v is replaced by (g,a)v, and the common mean is the first element of the limit (g,a)^:_
Since the power conjunction ^: accepts an array of powers, successive iteration values are produced readily:
(g,a)^:(i.6) 1 99
1 99
9.949874371 50
22.30456721 29.97493719
25.85687532 26.1397522
25.99792902 25.99831376
25.99812139 25.99812139
Finally, the "ubiquitous constant U", the common mean of 1 and the reciprocal of the square root of 2, is: