Jump to content

Wikipedia:Reference desk/Archives/Computing/2022 May 21

From Wikipedia, the free encyclopedia
Computing desk
< May 20 << Apr | May | Jun >> May 22 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


May 21

[edit]

Thirty days hath September (13 May)

[edit]

Those who have been following this discussion may be curious to know what was the trigonometrical formula which, when evaluated, produced the irregular sequence of the number of days in each month (in the post which mentioned it the word "shift" appears to have been omitted between "phase" and "of"). It's this:

d (m, y) = 30.9 + cos (2.9 (m - 7.5)) - [(1 + cos (m - 2 + π/2(y - 1)(y - 2)(y - 3)))/2].

Thomas Edison remarked: "I have not failed. I have found a thousand ways that won't work." As discussed in the thread, someone eventually came up with a formula which gave the right answer for not only the months whose lengths never change but also February irrespective of whether or not the year is or isn't exactly divisible by 4 and 100:

d = 30 + [0.6m + 0.4] - [0.6m - 0.2] - 2[m/12] + [m/12][((y - 1)/4) - [y - 1)/4] + 0.25] + [m/12]([[0.3 + (([y/100] - 3)/4.5) - [([y/100] - 3)/4.5]] + 99 + 100((y/100) - [y/100])/100] - 1).

d is the number of days in month m of year y, except that in the second formula only the value of m is set at 11 in January, 12 in February and 1 in March, rising to 10 in December (i.e. it corresponds to the Latin name of the month). The square brackets, which mathematicians will recognise as the floor function, denote the integer part; for example, [x] is the largest integer which is equal to or less than x. 92.31.139.91 (talk) 11:12, 21 May 2022 (UTC)[reply]

Mathematicians usually use the notation ⌊x⌋ for the floor function.  --Lambiam 20:15, 21 May 2022 (UTC)[reply]
Using square brackets for the greatest-integer function is an older notation, I think, but still with sufficient currency that you need to be able to recognize it. I personally would prefer ⌊·⌋, simply because square brackets can mean too many other things. --Trovatore (talk) 21:17, 21 May 2022 (UTC)[reply]
The notation [x] is used for the integral part of x, which is the same as ⌊x⌋ provided x ≥ 0.  --Lambiam 04:43, 22 May 2022 (UTC)[reply]
Hmm, I am suspicious of that unreferenced claim in the article. My memory is that square brackets are used for the greatest-integer function. -Trovatore (talk) 05:37, 22 May 2022 (UTC)[reply]
Some uses through the centuries: [1], [2], [3], [4], [5].  --Lambiam 11:55, 22 May 2022 (UTC)[reply]
Your search is specifically crafted to find the answer you're looking for. Also it is not clear to me that "integral part" has a standard meaning for negative numbers. --Trovatore (talk) 17:29, 22 May 2022 (UTC)[reply]
While some sources define the integral part of a number as "the part to the left of the decimal point",[6][7][8] I must concede that more than a few more recent sources define "integral part" as equivalent (or even explicitly as equal) to the floor function.[9][10][11]  --Lambiam 05:32, 23 May 2022 (UTC)[reply]
Thanks. That information might usefully find a place in our calendrical calculation article. Shantavira|feed me 18:40, 21 May 2022 (UTC)[reply]
Provided it is referenced to a reliable source.  --Lambiam 20:15, 21 May 2022 (UTC)[reply]
I'm not sure it needs to be said, but this construction - to fit an integer sequence, using a trigonometric formula, with a few extra (nonlinear!) operations - is ill-posed. Very ill-posed. Posted above, somebody has found one specific formula - but it is not unique! This is tantamount to performing regression with an underdetermined system... we can in fact find an infinite number of formulae, or functions, or operators, (trigonometric or otherwise), that will generate this integer sequence...
So the pertinent details to follow up on - does this particular formula have useful explanatory power? Do these coefficients mean anything, do they relate to any particular item of interest in either this particular calendar, or the astronomical phenomena that this calendar approximates?
I think no - I think these are "magic numbers." We're looking at one particular, weird, and difficult-to-use function that solves for the residual (that is - "the number of days in a month that differs from 30"...). And, this particular formula is messy...
So I'm not trying to nitpick it - it sure is neat that someone did work this out - but in science and math, there's value in knowing the difference between "a good theory" and "some random equation that perfectly fits the data." This is especially relevant in the modern era of throwing computational horsepower to fit high-dimensional functions. Just because we found a calculation that perfectly fits the data does not categorically mean that we created something useful, reliable, reusable! In fact, one of the great dangers is exactly this: we can perfectly fit the test-data with zero error using an infinite number of functions. And contained in this set of functions that perfectly fit all our tests- and benchmarks-, there exists an equally large infinite subset of functions that are invalid for one reason or other!
The profoundness of this basic, provable, nigh axiomatic fact of mathematics, seems dangerously lost on a huge number of modern computer users...
Nimur (talk) 17:13, 23 May 2022 (UTC)[reply]