Category Archives: heart

Math Joke 3

Until last week I only knew 2 good math jokes. But then I heard this one! Without further ado, I hereby inflict it upon you:

An engineer, a physicist and a mathematician are chatting over lunch when the engineer says, “I just don’t get problems in higher dimensions. I mean, stuff in 3 dimensions I can visualize quite easily, but how do you visualize something with more?”

The physicist shrugs and says “You just have to imagine integrating. For example, if you have an object in three dimensions and integrate it over time, you have added a fourth dimension, time. It’s like taking an object’s position and integrating it to get the object’s velocity. You can do it again with time, to get the object’s acceleration, or with another dimension; each integration changes the units appropriately.”

The engineer thinks for a minute and says, “That’s okay for a few dimensions, but what about some of the really wacky stuff like 17 dimensions?”

The mathematician looks up and says, “Oh, that’s really easy, actually. Just imagine an n-dimensional space and set n=17.”

Math Joke 2

Until last week I knew exactly 2 funny math jokes. Now I know three. I’ll post the third one tomorrow. Here’s the second one.

An engineer, a physicist, and a mathematician are asleep in a hotel when the curtains in each of their rooms catch fire. (Inexplicably, and all at the same time. Don’t ask why, it’s not important.)

The engineer wakes up and sees the fire, runs into the bathroom, fills the wastebasket with water, comes back and throws it on the fire. The fire goes out immediately, but there’s quite a bit of water damage.

The physicist wakes up and sees the fire, and pauses to estimate the rate at which the curtains are being consumed. He runs into the bathroom, fills the wastebasket with exactly 1.7 liters of water, comes back and carefully pours it on the fire. There’s a bit more fire and smoke damage due to the delay, but not a drop of water is spilled unnecessarily.

The mathematician wakes up and sees the fire, and pauses to contemplate the problem. Then he calmly walks into the bathroom. He turns on the faucet and strikes a match, then douses the match under the running water. He examines the match closely for a minute, then says, “Ah yes, this problem has a solution.” And then he goes back to bed.

Math Joke 1

Until yesterday I knew exactly 2 funny math jokes. Now I know three. Here’s the first one.

Two math professors are arguing in a cafe about the education level of the average person. One insists that the average person has little grasp of mathematics beyond arithmetic. The other asserts that the average person knows at least rudimentary calculus. They pass their lunch in fruitless debate.

Finally, the first professor goes to the bathroom. The second professor waves the waitress over. “I am having a bit of a debate with my friend here. When he returns, I’ll ask you a question. If you answer with the exact phrase ‘one third x cubed’, I’ll leave a ten dollar tip.”

“Ten bucks? You bet,” says the waitress.

The first professor returns. The second professor announces, “Here, I’ll prove it to you.” He turns to the waitress and asks, “What is the integral of x squared?”

“One third x cubed,” replies the waitress. They both laugh and the second professor leaves the $10 tip.

As they’re leaving, the waitress mutters, “…plus a constant.”

Straight Out of Dilbert

I approached the IT office delicately, knowing that I was in violation of process, procedure, protocol, and a few other pro- words.

“Um,” I said. Sysadmin heads swiveled my direction. “I need to manually report a trouble ticket.”

“You need to file tickets with the online helpdesk,” said Senior Sysadmin.

“Um, yeah…” I replied. “My ticket is that the helpdesk is down.”

“No it’s not,” said Junior Sysadmin, without looking at his computer.

I pondered for a moment how to counter this logic. Finally I settled on, “Yes it is.”

My debating skills having proven too much for them, they both turned to their computers. The helpdesk came up immediately.

“No it’s not,” repeated Junior Sysadmin, with just a hint of smugness.

“I wish to amend my ticket,” I said after a moment of thought. “The helpdesk is not reachable from my computer.”

Junior Sysadmin knowingly told me to use https, because everybody forgets it. I said I had checked that.

Senior Sysadmin asked if I knew how to spell “helpdesk”. All traces of intimidation gone, I gave him a stare. He turned back to his machine and typed some more. Finally he shrugged and said, “It works on my machine.”

“Do you see that your machine is not my machine?” I asked sweetly.

“I’ll go check it out,” said Junior Sysadmin.

NOTE: This is a true story that happened to me yesterday; in our Sysadmins’ defense all of this was done in a spirit of teasing, not of mean-spiritedness. The problem actually turned out to be IT’s fault, by the way–they had configured my machine to use the wrong DNS server.

Twitterable Mandelbrot II: The Mandelbrottening

Yesterday I posted my Twitterable Mandelbrot, a ruby script that generates the Mandelbrot Set in 134 characters. A few of you took this as a challenge to shorten my code even further. I didn’t mind, and in fact was interested to see your results; I was sure that an extra character here or there could be shaved off.

What I didn’t expect at all was that somebody would shave fourteen characters off.

Reader brahbur on rubyflow came up with this:

a couple of these changes could be considered “cheating” (-:

80.times{|a|p (0..300).map{|b|x=y=i=0;(x,y,i=x*x-y*y+b/150.0-1.5,2*x*y+a/40.0-1,i+1)until(x*x+y*y>4||i>98);i>98?0:1}*''}

Brahbur’s solution does look different; there are quote marks on each line and it outputs 1s and 0s instead of #s and .s, but the mandelbrot is still clearly visible (Edit: I reduced the size from 300×80 to 240×60 just to keep the outputs roughly the same size):


Click for larger version (1400×800)

I think this is just awesome. Once we’re playing with 0’s and 1’s, I can see another optimization: i>98?0:1 can be replaced with 99i. This bring us down to 118:

60.times{|a|p (0..240).map{|b|x=y=i=0;(x,y,i=x*x-y*y+b/120.0-1.5,2*x*y+a/30.0-1,i+1)until(x*x+y*y>4||i>98);99i}*''}

I have to give most of the credit to brahbur, though–I just saw a tiny tweak, on top of the amazing rewrite they already did. So great. THANK YOU brahbur!

Now, the challenge continues: can you shorten this further? Brahbur was concerned about “cheating”, so let’s define the rules for clarity: Output should be 240×60 (extra quotes and padding are okay) and it should be visually recognizable as a Mandelbrot set. Other than that, go for it.

Twitterable Mandelbrot

As a kid I always thought fractals were neat, but every time I tried to learn how to do them, I got lost in the math. I guess 20 years makes all the difference: today I went and read up on the Mandelbrot set and had one of those “wait, that’s it?” moments.

It took me about 15 minutes to write the program. Here’s the output:


Click for larger version (1400×800)

The whole program was about 400 characters long. I got to thinking, “that’s *almost* small enough to fit into a single tweet…” and then I spent the next hour and a half refactoring my code for size.

Victory:


http://twitter.com/dbrady/status/12546255974

What do you mean I need a hobby? I have one. See?

Terrible Beauty

Recently I dumped all of the data out of one of our geographic tables in our database, and plotted a red dot for every record. This was the result:

Click the link for a larger version (1200×800).

This is an interesting graph. It appears to follow population, but there are also some patterns that follow state outlines: there are some curious voids in North Carolina and Minnesota, for example. In the west, we can almost make out highways; there’s a visible north/south track through Denver along I-25, and there’s a strong clustering down I-15 through Utah with a big blotch over Las Vegas.

Kinda neat, huh?

What you are looking at is every registered sex offender in the United States. My job is to collect and analyze that data, along with crime information.

Still neat? Sigh.

There are still some interesting patterns, however. Population centers follow the freeways in the western states. As the population density rises to the east, we lose track of individual roads; sex offenders are only absent where people cannot live. Physical barriers like coastlines and bays are clearly marked, of course; but you can also clearly see places where people merely aren’t allowed to live: the Okefenokee National Wildlife Refuge in Florida, the Allegheny and Susquehannock National Forests in Pennsylvania, and the cluster of tiny national parks all throughout upstate New York.

I am most interested, however, in North Carolina and Minnesota. Why are they so obviously underrepresented here? Are people just less likely to offend sexually in those states? Possibly; I am too cynical to believe that people in those states behave differently than in the other 48, but it could be that NC and MN convict sex offenders less often, or they could simply have less strict sex offender laws.

Ah, but see how trusting you are of my little dots? It could be that the NC and MN sex offender registry systems are just harder to get data from. While I haven’t worked with those states directly, I have worked on the code that aggregates this data, and I can tell you that no two states provide data the same way. Some states are sensible and reliable, while others are such a headbashing nightmare—Alaska, I am looking at you here—that you wonder if their IT department had to make do with wild monkeys because the trained ones were too expensive.

Here’s a really good possibility: Some states track sex offenders at different levels, and sex offenders under a certain level are tracked inside the state but not published to national registries. It could be that those two states have just as many RSO’s per capita, but they do not report misdemeanor offenses outside the state.

Or, who knows. It really could be that in North Carolina people are too nice—and in Minnesota it’s just too cold—for that sort of thing.

Note: some of the dots lie outside the US. This is not always a mistake. Sex offenders are required to keep their address registered even if they move outside the USA. There are a few thousand US sex offenders scattered across the globe—including one at the South Pole.