3 ms·
A new house number ...
- jgrahamc 17y agoFeels annoying to me that the pi^2 is left inside the infinite sum at the bottom: http://equationater.com/3887e31ec88fbf35d331554e06353358.png http://equationater.com/3887e31ec88fbf35d331554e06353358.png
- RiderOfGiraffes 17y agoI think the reasoning there is that sum(1/(n^2)) is rather well-known to be pi^2/6. They then need to invert and remove the pi^2. I think it's a reasonable part of the game to put the pi on the inside.
- bonsaitree 17y agoIt's just intentional obfuscation. Just like the double inversion.
- RiderOfGiraffes 17y agoI'm not sure what you mean by the double inversion. You inverting a sum of invertions - that can't be undone in any sensible way. Can you explain a little more what you mean?
- antirez 17y agoI had to write the following to understand this is going to converge to 6: >> 1/((1..1000000).map{|n| (1/((n*3.14)**2))}.inject{|a,b| a+b}) => 5.99392169730553
- RiderOfGiraffes 17y ago>>> from math import pi >>> 1/sum( [1/(pi*n)**2 for n in xrange(1,1000)] ) 6.00365160802217
- apgwoz 17y agolet's not get all fizzbuzz-y in here...
- antirez 17y agoShorter but, "ad hoc" like everything in Python (the reason I never liked it). The Ruby version looks like math, if you know the concepts of map and reduce it's trivial to understand what's going on. Compare this with sum() + "for n" and "xrange". Also if I remember some Python correctly "xrange" is almost like "range" but it's something like a lazy version, another ad-hoc stuff. Sorry, didn't resisted.
- RiderOfGiraffes 17y agoEach to his/her own. This isn't intended to be a language war. If you prefer map and reduce then you can have them: >>> from math import pi >>> add = float.__add__ >>> def f(x): return (pi*x)**(-2) >>> 1/reduce(add, map(f,range(1,1000)) ) 6.0036796863530508 Or, as a one-liner: >>> 1/reduce(float.__add__, map(lambda x:1.0/(3.1416*x)**2,range(1,1000)) ) People who aren't mathmos often find the list comprehensions more comprehensible, hence the version I wrote not as a competitor, but as an alternative, to yours. Horses for courses. Personally, I've found the Python version to look more like math when I choose to express it like math, but I'm programming, so why not make it look like what I'm doing? Golf is a stupid game in programming. Understandability is the goal, but different readers find different things natural. That's never going to go away.
- antirez 17y agoI guess it's really a matter of tastes indeed. My point is that, no matter the fact that I can try to mimic the Python idiomatic way or the reverse, there is a real difference between this languages, and is a difference that I see in many other languages, splitting them into two families: the "tools" languages that try to provide already build abstractions able to solve common problems, and the "concepts" languages where there are just a few rules you can combine to solve problems. I love the latter approach.
- 17y ago
- andrewparker 17y agoSorry if this is obvious, dusting off the math mind here... How is this solved without brute force computation?
- RiderOfGiraffes 17y agoIt's neither obvious nor easy. It was an outstanding problem in the mid 1700's, and it was Euler that solved it but some superbly reckless arguments. Euler's original paper: http://www.17centurymaths.com/contents/euler/e041tr.pdf http://www.17centurymaths.com/contents/euler/e041tr.pdf The bottom of this page has a more modern treatment, although it takes a lot for granted: http://www.math.wpi.edu/IQP/BVCalcHist/calc3.html http://www.math.wpi.edu/IQP/BVCalcHist/calc3.html Another treatment of Euler's proof is here: http://library.thinkquest.org/28049/Summing%20reciprocals.html http://library.thinkquest.org/28049/Summing%20reciprocals.ht...
- stilist 17y agoLast link needs to swap %20 for the space.
- RiderOfGiraffes 17y agoDone - thanks.
- abalashov 17y agoCongratulations, now I'll never find your address if you invite me over. Last math I took was "advanced" algebra & trigonometry my junior year of high school.
- modoc 17y agoIt works as a visitor filtering mechanism. "You must be at least this good at maths..."
- deleted 17y ago[deleted]
- Edinburger 17y agoI'm glad I am not your mailman.
- RiderOfGiraffes 17y agoIt's not me - I live at http://www.penzba.co.uk/my_house_number.png http://www.penzba.co.uk/my_house_number.png
- jacquesm 17y agoHumor for mathematicians. I really should come to attend one of your talks. Need 48 hour days. And a calculus course.
- robertk 17y agoYou need parentheses around the -1. Otherwise the series is divergent. I presume you do not live at a divergent address? :)
- RiderOfGiraffes 17y agoThat depends on which school you went to, but point taken. I've inserted the parentheses.
- bhousel 17y agoOr the local EMS, Fire, Police, etc.. Seriously, I'd get that changed. There are plenty of reasons someone might want to find your house quickly.
- anamax 17y agoPeople often need to solve the problem of finding a house where the number is readily apparent. In some/many places, one could find that house by interpolation. (In the US, even numbers tend to be on one side of the street and odd numbers on the other. And they're almost always in-order.) With an apartment, things can be more complicated. That said, there are instances of "vanity addresses", where "<some number> 5th Ave" appears to not be on 5th Ave. I don't know what one does in Japan, where the numbers are supposedly assigned chronologically. (Hmm - I wonder what triggers number generation and if they ever reuse or allow transfers.)
- ynniv 17y agoHey, a use for Wolfram Alpha! [ http://www.wolframalpha.com/input/?i=sum%281%2F%28n+*+pi%29%5E2%2C+n%3D1%2C+inf%29 http://www.wolframalpha.com/input/?i=sum%281%2F%28n+*+pi%29%... ]
- aeroevan 17y agoThis works for me: http://www.wolframalpha.com/input/?i=%28sum+1%2F+%28n+*+pi%29+^2+from+n+%3D+1+to+inf http://www.wolframalpha.com/input/?i=%28sum+1%2F+%28n+*+pi%2...