6 ms·
Simple (warning: I did not verify this result): -( 11 x^11)/907200 +( 163 x^10)/181440 -( 37 x^9 )/1260 +( 13481 x^8 )/2419
by Someone 12y ago
Simple (warning: I did not verify this result):
-( 11 x^11)/907200
+( 163 x^10)/181440
-( 37 x^9 )/1260
+( 13481 x^8 )/24192
-( 2055371 x^7 )/302400
+( 240683 x^6 )/4320
-( 28268521 x^5 )/90720
+( 85774775 x^4 )/72576
-(446998571 x^3 )/151200
+( 46351537 x^2 )/10080
-( 221017 x )/56
+1416
That is a nice continuous, infinitely differentiable function.
Source: http://www.wolframalpha.com/input/?i=interpolating+polynomial+calculator&f1=%7B31%2C28%2C31%2C30%2C31%2C30%2C31%2C31%2C30%2C31%2C30%2C31%7D&f=InterpolatingPolynomialCalculator.data_%7B31%2C28%2C31%2C30%2C31%2C30%2C31%2C31%2C30%2C31%2C30%2C31%7D&a=*FVarOpt.1-_***InterpolatingPolynomialCalculator.data--.***InterpolatingPolynomialCalculator.data2---.*-- http://www.wolframalpha.com/input/?i=interpolating+polynomia...
To get something more impressive, I would use the discrete Fourier transform. That leads to http://en.wikipedia.org/wiki/Trigonometric_interpolation http://en.wikipedia.org/wiki/Trigonometric_interpolation. That gives you a nice formula with lots of sines and cosines.
- danbruc 12y agoI tried DFT, the result is not pleasant and there is no really obvious way to generate the coefficients with a compact formula.
- Someone 12y agoYou shouldn't believe everything you read on the Internet/I guess I should have added a smiley.
- danbruc 12y agoI tried it well before you wrote your comment because I hoped that the alternating pattern would yield something short but February messes everything up.
- repsilat 12y agoThat's a shame, it'd be nice to have a formula that "wrapped around" properly. I've been happy with the rhyme for a while. I can't remember it properly (in my head it ends "all the rest have strawberry jam, except my grandmother who rides a bicycle"), but it's obviously enough. Now that I see it all laid out, though, I wonder if I can do better -- "Odd is 31 days to July, then it flips." Now the people in school counting on their knuckles all makes sense.
- AnkhMorporkian 12y agoThis is especially handy when you want to figure out how many days are in that pesky month between January and February.
- yzzxy 12y agoI forgot how many days were in that month some time back in the 19A0s. http://boingboing.net/2011/10/11/mixtape-of-the-lost-decade.html http://boingboing.net/2011/10/11/mixtape-of-the-lost-decade....
- pavlov 12y agoLooking at the Wolfram Alpha plot, it appears that the month about halfway between November and December is the longest of the year, with almost 33 days. We could call it Gloomember, the month that seems to go on and on.
- cgriswald 12y agoI say we call it Partyember because it is the month most likely to have five full weekends.
- gfodor 12y agoCancelGymMember?
- 12y ago
- deleted 12y ago[deleted]
- dragonwriter 12y agoTIL that the month before January doesn't have the same number of days as December.
- jameshart 12y agoNo, we want a nice discrete function. The Möbius function[1] μ(x) has some potentially useful properties - it produces discrete values in the range [-1,1], and it has a kind of pseudorandomness to its output. Some sort of variation on 30 + μ(n + x) or 30 - μ(n + x) should produce the right values for the number of days per month in a leap year. 30 - μ(x+192)[2] starts off promisingly, giving the right day counts for January through to July, but then it goes off the rails. I've mounted a quick brute-force search, but it looks like there's no n < 1000000 for either of those formulations that correctly matches January through August, let alone through to December, but never mind: there's plenty more natural numbers. Surely someone will find a formulation that works. It's not like anyone's been mistaken about the continuation of this number series before[3]. [1] http://en.wikipedia.org/wiki/M%C3%B6bius_function http://en.wikipedia.org/wiki/M%C3%B6bius_function [2] http://www.wolframalpha.com/input/?i=30+-+%CE%BC%28n%2B192%29 http://www.wolframalpha.com/input/?i=30+-+%CE%BC%28n%2B192%2... [3] http://en.wikipedia.org/wiki/Mertens_conjecture http://en.wikipedia.org/wiki/Mertens_conjecture
- Someone 12y agoI don't want that, but you can always get there by replacing x by floor(x) everywhere it occurs, or, in strongly typed languages, by declaring the function to take an integer value. For those that dislike taking powers of x, try this in Python: def f(x): return 62648012/4**x - 4*(15662003/4**x) + 28 map( f, xrange( 1, 13))