Posts Tagged ‘math’

Integration by parts

April 19, 2013

How did loving the ground-up toenails of bisexuals get an interior designer to take up geology? Simple, he went from noting decor to what the core denotes by being into grated bi-parts.

I don’t really get why this XKCD is funny.

But here is a picture explaining integration by parts:

The area of the entire rectangle is uv, and it is made of two parts we integrate, so


uv = \int \!u\, \text{d}v + \int\! v\,\text{d}u


and therefore


\int \! u \,\text{d}v = uv - \int\! v \,\text{d}u


Also, take \text{d}(uv) = \text{d}(\int \!u \,\text{d}v + \int \!v\,\text{d}u) and you find


\text{d}(uv) = u \,\text{d}v + v\,\text{d}u,


which is the product rule.


That and Why

May 8, 2010

When I was a kid, my parents had two ways of justifying rules. In the first class there was a pretty understandable reason:

Me: Why do I have to brush my teeth?
Mom: Because it will give you a beautiful smile.
Dad: And because if you don’t the germs from your gums will spread to your nervous system and rot the area of your brain related to inhibitions.
Mom: Oh, please don’t tell him things like that, honey.
Dad: Don’t tell me what to do, woman.
Mom: Are you off your meds again?
Dad: What did I just say? Everyone’s a critic. [to the pet turtle] What are you staring at you retractable hockey puck?
Mom: Mark, dear, see, this is what happens. Your father didn’t brush his teeth when he was a little boy.
Dad: That turtle is a demon. Somebody get me a soldering iron and some holy water.

These days I have some doubts as to the authenticity of those little performances, but they were certainly effective. On the other hand, sometimes my parents’ justifications could be a little obscure:

Me: Why do I have to take out the trash?
Mom: Because I say so.
Dad: And because if you don’t, I will tell you in detail what sex really is, and remember in my Navy days I did two tours on a submarine.

Both are devastatingly convincing – either way I am completely sure I need to do my chores. But in only one case do I feel like there’s a real reason why.

I recently saw this mathematical relation somewhere (I forget where, but it’s pretty well-known):

1^3 + 2^3 + \ldots + n^3 = (1 + 2 + \ldots + n)^2

For example, if n = 5, then

1^3 + 2^3 + 3^3 + 4^3 + 5^3 = 1 + 8 + 27 + 64 + 125 = 225


(1 + 2 + 3 + 4 + 5)^2 = 15^2 = 225

This will be true no matter how big n gets. Obviously no one has checked all the way up to n = 935467568777043682111, for example. Even with a computer it would not be possible, and if you did check up to that number, how do you know it would still work for that, plus one? We’ll come back to this.

A simpler example is this one:

2 + 4 + 6 + \ldots + 2n = n(n+1).

Again you can check it out for as many numbers as you want. For n = 7 it says

2 + 4 + 6 + 8 + 10 + 12 + 14 = 7*(7+1)

And that’s right. The left hand side adds up to 56 and the right hand side is 7*8 = 56.

The idea in math, though, is to show that it’s always true, even for n equal to the number of stars in the universe.

Here is proof based on dominoes with dots on them. We’ll lay the dominoes out on a table so that both the sum 2 + 4 + \ldots + n and the multiplication problem n(n+1) count the number of dots on the dominoes.

Our dominoes will have two dots, one on each half, like this:

It's like Wall-E has fallen on his side.  And also lost his body.

One domino. Two dots. This will be the 2 from 2 + 4 + ... + 2n

That domino represents 2, the first number in our sum 2 + 4 + \ldots + 2n.

Next we add 4, which means 2 more dominoes:

You know that story about how if you hold your nose while you sneeze, you'll blow a hole in the back of your head? That's basically what happened to whales.

Two more dominoes with four more dots. Now we have 2 + 4 dots.

But we can rearrange the dominoes however we want and still keep the number of dots the same, so for the hell of it, let’s put them like this:

If there is a deity, it is probably pretty confused about how to live up to everyone's expectations at once.

The same dominoes rearranged.

Now we add three more dominoes to get this:

I bet Carmen Sandiego and Waldo are doing it right now.  I just don't know where.

Adding three more dominoes. Now we have 2 + 4 + 6 dots.

Can you see the pattern? Each time we want to add a another number in the series, we add another layer of dominoes around the edge of the rectangle. It’ll be more obvious if we gray out the middle layer a little.

I will always stand by you. Not because I support you, but because it makes me look good by comparison.

Same image with the layers highlighted. Each layer is one number from the sum (2 + 4 + ... + 2n) and n is the number of layers.

We can keep doing that until we have n layers of dominoes. So, for n=5, our finished picture would look like this:

I am so tired of these stupid domino pictures.  Hey, stop filling in the alt-text on my images, Dad.

For n = 5, we have (2 + 4 + 6 + 8 + 10) dots.

We know that we’ve added the numbers 2 + 4 + 6 + 8 + 10 because each layer has one more domino, hence two more dots, than the previous one. But we can also use a shortcut to count the dots. Ignoring the edges of the dominoes and just focusing on the dots, we see that the dots form a rectangle. The rectangle is 5 dots high and 6 dots long, so the total number of dots is 5*6 = 30. This checks out. 2 + 4 + 6 + 8 + 10 = 30.

The same pattern will hold for as many layer as we please. It’s clear from the picture that each new layer adds two dots, so n layers will have 2 + 4 + \ldots + n dots. But it’s also clear that each new layer makes the rectangle one dot higher and one dot longer, so that in all the rectangle is n dots high and n+1 dots long. That means the total number of dots can be counted two ways, and since the number of dots is the same either way,

2 + 4 + \ldots + 2n = n(n+1)

That’s one sort of proof. We might say, after seeing this proof, that now we understand not only that the equation

2 + 4 + \ldots + 2n = n(n+1)

is true, but also why it is true.

This is a subjective thing. This particular proof makes a lot of sense to me, but to someone else it might not. The proof is very informal. What if there’s an error I just don’t see?

Let’s look at a different type of proof – a more formal type based on symbols rather than pictures. This time we’ll prove the more difficult equality

1^3 + 2^3 + \ldots + n^3 = (1 + 2 + \ldots + n)^2

from the beginning of the post.

Let’s start with the right hand side.

We already know

2 + 4 + \ldots + 2n = n(n+1)

so dividing both sides by 2

1 + 2 + \ldots + n = \frac{n(n+1)}{2}


(1 + 2 + \ldots + n)^2 = \frac{n^2(n+1)^2}{4} = \frac{n^4 + 2n^3 + n^2}{4}

That’s the right hand side. Now for the left. By algebra

k^4 - (k-1)^4 = 4k^3 - 6k^2 + 4k - 1


\sum_{k=1}^n k^4 - (k-1)^4 = 4\sum_{k=1}^n k^3 - 6\sum_{k=1}^n k^2 + 4\sum_{k=1}^n k - \sum_{k=1}^n 1

But also

\sum_{k=1}^n k^4 - (k-1)^4 = \sum_{k=1}^n k^4 - \sum_{k = 1}^n (k-1)^4 = \sum_{k=1}^n k^4 - \sum_{k=0}^{n-1} k^4  = n^4


n^4 = 4\sum_{k=1}^n k^3 - 6\sum_{k=1}^n k^2 + 4\sum_{k=1}^n k - \sum_{k=1}^n 1


\sum_1^n k^3 = \frac{n^4 + 6\sum_1^n k^2 + 4 \sum_1^n k - \sum_1^n 1}{4}.

In general, we can find the sum \sum_{k=1}^n k^p for any p based on the binomial coefficients and the sums for lesser powers. Simplifying out the algebra in this case gives

\sum_{k=1}^n k^3 = \frac{n^4 + 2n^3 + n^2}{4},

which is the same as the result from before, so

1^3 + 2^3 + \ldots + n^3 = (1 + 2 + \ldots + n)^2.

This proof is pretty much solid. You could make it formal and rigorous if you wanted to. But unlike the first proof, I don’t get from it much sense of the “why”. Sometimes I feel like numbers are just telling me what to do and threatening me with horrible consequences if I don’t.

The Asians Are Coming! But I Can’t Count How Many

December 11, 2008

Since I’ve started reading blogs, I’ve seen a lot of instances of people ranting madly about topics they don’t understand very well. These people also don’t understand why they aren’t taken more seriously, or why, in fact, the whole system doesn’t immediately bow to their sagacity. But now that I, too, am a blogger, I’m beginning to understand the severely-debilitating effect the freedom to publish uncensored material has on human judgment. So here I am joining the ranks of men screaming into a hurricane, and unknowingly pointing the wrong direction.

A recent story from the NY Times warns repeatedly that those tricky little Asian people are eating a gazillion tons of fish every day and getting way too good at math. You see, for at least the last ten years both a generic statement and its complement have been considered racist if they involve black people in any way. Further, the whole feeling-generally-uncomfortable-about-anything-Islamic thing has been used as the hook on enough network TV shows that people are starting to get pretty sensitive about that, too. But we haven’t done anything really bad to the Asians since Vietnam, so it’s pretty much okay to treat them as one big group and find reasons to be scared of them.

Apparently, kids in Singapore, Taiwan, and Japan do very well, on average, on standardized math tests. It’s supposed to send off alarm bells and spur us to reform the educational system. But the stat is not what it’s made out to be.

Here are three of the more practical reasons we might want students to be mathematically competent:
1) it helps them balance their checkbook and etc.
2) it’s necessary background for engineers and accountants, etc.
3) it’s necessary for innovation. great technological and scientific breakthroughs are made by people who understand math

But here’s why childrens’ average test scores are irrelevant to these points
1) (math helps with life) It’s increasingly unnecessary for the average person to know math. Computers will do it all for you. Anything that requires a minimal amount of the sort of mathematical, logical, and/or algorithmic thinking employed by a math, science, or computer-type person can now be automated to the point where an intelligent chimpanzee can do it. Want to calculate your BMI? Don’t bother with the formula. Just plug in the numbers to a calculator, which automatically multiplies them to each other for you. Don’t want to figure out your taxes? Plug it into Quicken. Or hire an accountant, who also doesn’t know math very well but can plug things into Quicken more efficiently than you. Don’t know how much longer to boil an ostrich egg than a chicken egg? Don’t bother with dimensional analysis. Just look it up online.

2) (math helps with jobs) Partially, more of the same argument as point 1) applies here. Want to be an airline pilot? Don’t worry yourself too much with the math. Just make sure the numbers from this instrument agree with the numbers from that instrument, and the computers will take care of everything. The percentage of people who really need to be good at math is quite small, so we should be more interested in the scores of the top 5% or top 1% of students than the average score.

3) (math leads to technological and scientific excellence) The average performance of students is simply irrelevant to this one. Big ideas come from people who work hard on problems because they’re intrigued by them and genuinely interested in the work itself. They need a spark of creativity to go with their technical competence, but spark is the really essential thing. It’s far easier to be very good at electrical engineering (for example) than it is to do something important in it. And frankly, hours upon hours drilling practice problems until you’ve memorized all the methods of solution is not going to get you far beyond good test scores. But that, as best I can tell from here, it’s what’s going on with the Asia/West divide in math scores. The Asian kids study longer and work harder. The cuiture is extremely performance-based, so that parents push their kids hard, but they only thing anyone cares about are good grades and good test scores. Since the tests don’t require creativity, why bother encouraging it?

I’ve been teaching American high school kids for a while. Many of them have been first or second generation Americans from Asian families. They grew up bilingual and their households retain most of the traditional values of Korea/Taiwan/Japan, including those relating to education. I’ve also taught kids from America, the UK, India, France, Italy, Turkey, Japan, China, Mexico, Canada, and various places I hadn’t even heard of before i met them. I’ve taught whites, blacks, east asians, south asians, hispanics, polynesians, native americans, and various combinations thereof. And guess what? They’re all the same. Not the kids, I mean, of course they’re quite different from each other. But I do not see any systematic difference in competence, creativity, interest, brilliance, ability to concentrate, or whatever other factors are essential to doing great things with technical material.

It has been my experience that when you look at the top few percent – the ones who are truly gifted at this stuff, and occasionally ask questions that startle me with their insight, or find clearer and more direct explanations of the topic at hand than I had sniffed up myself – are more likely to be male. Not exclusively, of course. The most insightful student I ever had was a girl. But that gender bias is the only systematic tendency that’s stuck out to me.

So the Asian kids kicking American kids’ butts at math is not a clarion call. It may be a benchmark for how effective our educational system is, and how seriously our culture treats education, but not for how many great thinkers we’ll have in this country twenty years from now. If we want to have a home-grown army of thinkers and innovators, we should be more concerned with how much kids like math and want to do it on their own, rather than how many formulas they’ve memorized by age 10. A high schooler’s knowledge of math won’t get you all that far, anyway. It only comes from higher study, and America still has the world’s best system of institutes of higher learning. So it’s not a matter of cramming more into their heads while they’re young. It’s a matter of honestly and fairly presenting to young people what math is and what it can do. As long as grade school doesn’t make kids hate math, it’s doing fine. The ones who have aptitude will naturally gravitate towards it. We need to make sure that when they do, there’s someone there to guide that top 5%, and that we’re not all too busy worrying about the grade of the kid in the middle of the class to notice that the kid at the top just proved a new result in number theory.

My guess is that most of the people who spend their time screaming, “The Asians are coming! They traded their abacuses for TI-89’s and they’re going to swipe the technical carpet from under our fat, complacent feet!” know much more about statistics than about the process of becoming technically competent, one part of which is to learn never to take statistics at face value. If our goal is really to raise the average test score, it has to come as much from a shift in cultural values as a change to the educational system. But if our goal is to be a scientifically and technologically vital society, the masses are not the place to look.

Putnam 2008

December 9, 2008

Somebody linked me to a board post with the problems for 2008. I never tried these while an undergrad, but that’s because I was never insanely good enough to be invited. It’s more fun when you’re not in competition mode, anyway. Go have a crack at it.

Let’s Read the Internet! week 8

December 8, 2008

Wind-Powered Perpetual Motion
Why the Directly-Downwind Faster Than the Wind Car Works”
Mark Chu-Carroll on Good Math, Bad Math

“The only true wisdom is in knowing you know nothing.”

Socrates would have to be a fan of the scientific method. We frequently acclaim the shift towards naturalism in Western thought, as a turning point in our intellectual maturity, but that shift brought with it the less-recognized roots of an even higher goal – the eradication of hubris in the search for understanding. Naturalism, the philosophical position that empirical observation holds the final word in debates on truth, essentially kills the argument of “because I say so.” Truth comes from no one in particular, so there’s at least the faint possibility that people trying to understand the way things work will some day no longer jockey and battle to be “the one who got it right.” That’s a far-out ideal, and maybe if nobody thought they were going to be credited with brilliance, nobody would have the incentive to try to do something brilliant in the first place. But at the very least, when two naturalists have an argument, they can frequently appeal to a common, impartial, higher source – nature – as arbiter.

That’s what’s happened here on Mark Chu-Carroll’s widely-read blog. He initially, and incorrectly, believed a certain device that drives overland into the wind and faster than the wind was a fraud. After long, long debates, he changed his mind, and carefully explained the mistakes in his own reasoning and what he had learned in the process of investigating his own error. Which is pretty much awesome, because such things hardly ever occur in arguments on less savory topics, like abortion. (Oh my God, was that an eating-dead-babies joke?)

I also appreciated the sort of emergent didactic property of the hundred-some post comment thread on Chu-Carroll’s original post. After watching the youtube video of the device (linked from the original post), I wasn’t completely sure whether the treadmill test was fair. It seemed reasonable enough, but I certainly wouldn’t have been prepared to defend it against someone eager to argue the opposite way.

As I read the thread, commenters raised most of the points I was considering. Other people answered those points, and then even more people chimed in with takes that I hadn’t considered at all. The overall effect was for a large amount of white noise and repetition, but also for a strikingly-diverse set of mindsets converging on the same problem. By the time I was done reading what everyone had to say, I felt that I had appreciated more intricacies in the problem than I would ever have discovered thinking about it alone, and I probably understood it better than I would have even if a single skilled author had written a long exposition. The challenge of interpreting each new voice’s arguments, incorporating them with the previous knowledge, and then parsing all of it for myself over and over, trying to find holes in everyone’s logic and patch together a firm understanding piece by piece, was absorbing because it’s so much more interactive than simply reading one single person’s explanation, no matter how clear, detailed, or precise.

It makes me want to argue about physics more often, but only in the good way where your ego doesn’t get too involved.

A Russian Teacher In America
Andre Toom, linked from God Plays Dice

A long essay that’s a borderline sob story about the woes of the American educational system. As a private tutor, I see exactly the sort of problems Toom is discussing on a daily basis – students, even (or perhaps especially) the “good” students, are so maniacally focused on their grade that learning becomes completely lost amidst a sea of test-cramming, and question-memorizing. Students are so wrapped up in the concrete performance markers visible to the world, that they don’t care at all for their true progress, visible chiefly to themselves.

That, at least, is the picture. I only partially buy it. It’s true, to varying degrees, for many students. But it’s not as if this entire nation has no one left interested in math. The sad part is that over two hundred or so students I’ve had, there have been a handful who are truly interested in math and physics, but they seldom have much guidance. Because these kids can gets A’s in math class, no one in public school is very concerned with pushing their limits when there are too many problem kids to worry about first. So I’m more interested in people with plans on how to reach interested young students with extra-curricular math opportunities than I am with people deriding a broken system.

Not everyone is going to love math. In fact, I doubt there’s ever been a society where a majority of people are interested. But the vast majority of our society has to take it in school. So yeah, it’s inevitable that there are lots of people taking math who don’t care about math. But I’ve done the same thing in a literature class before. Ultimately, math is cool enough that some people are going to discover it no matter what the educational system is like, so I’m not all that worried about the alarm bells being rung here.

Blow to Vitamins as Antidote to Ageing
James Randerson at The Guardian

We thought we understood, like, everything. Turns out not. But the next study that comes out will surely reveal the secrets to perfect health once and for all…

Swiss Approve Heroin Scheme but Vote Down Marijuana Law

Sounds like a pretty good plan to me. Administer heroin to addicts in a safe, controlled environment, thereby reducing health risks and driving down the general nastiness associated with black market activity. I can also understand why you wouldn’t want to legalize marijuana in just one small portion of Europe, since everyone would then go there just to smoke. The same argument doesn’t hold as much water for the US with its block-like geography, but I live in California, where marijuana is as good as legal anyway.

Tara Donovan

from Three Quarks Daily

The Not-So-Presidential Debate

The Not So Presidential Debate from aaron sedlak on Vimeo.
also from Three Quarks Daily

Why Punishment Is Worth It In The End
Ed Yong at Not Exactly Rocket Science

Read this article or else! Nah, honestly I would never be able to go through life as someone who tried to understand human interactions by designing toy experiments like this. But It’s nice to get little sixty-second summaries of their months of hard labor.

Over-budget Mars rover mission delayed until 2011
Rachel Courtland at New Scientist

Bad news, since I work at the place where they’re building this thing, and they owe me two months’ back pay already.

15 of the World’s Most Creative Papercraft Artists

You get to feeling a little bit sleazy when you realize all the exposure you’ve had to art in the last two years has come in the form of internet lists with titles like “The Top Ten Totally Badass Avant-Garde Experimental Playdoh Exhibitions of 2008!!” But on the other hand, some of this stuff actually is pretty badass, for being a paper sculpture of a cat.

A Happy/Unhappy New Pair of Studies
Stephen Black at Improbable Research

Among the headlines of news feeds I scanned through this week, there must have been at least ten stories referencing a recent paper purporting to show that happiness is “contagious”, that is, if I were to reach down and magically make your friends happy, you would become happy as well. When I first heard about this, I was intrigued, because I was wondering how you would establish this is a “contagious” effect, and not just correlation. It turns out: you don’t. The researchers, from what I can tell, simply found a correlation and announced that happiness is contagious. News stories are apparently contagious, too, because once word of this paper got out, most of the major science news outlets published something on the story.

But as the link describes, another study found that height was also “contagious”. That is, if your friends are tall, it’s likely you’re tall, too. Just as with happiness.

Sine of an Inscribed Angle
Brent Yorgey on The Math Less Traveled

A cute visualization of the law of sines.

New Problem: Transformation of Volumes

October 30, 2008

Here’s a real life problem that came up when I was looking for dark matter (I checked under my bed like six times, but I didn’t find any.  When I presented this research at group meeting, everyone got really quiet.  I think they were in awe.)

In the problem below, I use “volume” where you might think “area” makes more sense.  2D volume is area, so same thing.  But I use the term “volume” to suggest that you might want to generalize the problem to higher dimensions.

Suppose you have some 2-D volume in the plane.  You then do some sort of pointwise transformation, which maps this into a new volume, like so:

A super-spooky example of a smooth pointwise transformation from R2 to R2

A super-spooky example of a smooth pointwise transformation from R2 to R2

You can describe this transformation by

x' = f(x,y)

y' = g(x,y)

where (x',y') is the coordinate to which you map the point (x,y).  Assume that f and g are smooth and invertible.  Points inside the region stay inside the region, and things behave nicely, if weirdly.  Straight lines map onto curvy lines (or straight lines, if they want), but not broken up segments or points.  The neighborhood of a point transforms into the neighborhood of the transformed point.  Different points stay different (never wind up on top of each other).  Photographs of your head become distorted, but your eye (if you have one, this is an equal-opportunity blog) is still next to your nose.

Question: What is the area of the transformed region, in terms of the old region and the transformation equations?  (see tags for a hint or two)

Multiples Rule For 3, 9, and 27

October 23, 2008

I’m sorry I started writing this post. The point was to talk about some simple number theory, but I decided to “build into it” with a pointless anecdote about my pointless childhood. This anecdote happened to involve the TV show “Square One”. Thanks to my simian brain’s stupid ability to make connections between various stores of knowledge, I realized that although I haven’t seen an episode of the show since 1993, now we have YouTube, and therefore I can go watch people roller skating while tied to pickup trucks.  Also I can find that show. It’s probably the greatest thing since Spirograph.

And there’s plenty more where that came from.

But the actual impetus for this story was that I was tutoring some intelligent algebra students (x of them), in the prime factorization of numbers. I was surprised they hadn’t heard the following rules to check whether a number is divisible by three or nine without doing the division problem.

  • A number is divisible by three if and only if the sum of its digits is divisible by three.
  • Likewise for nine.

The reason I couldn’t imagine someone not familiar with this oh-so-basic fact is that I learned it at age six from a singing cowboy.

But these aren’t theorems about the numbers, exactly.  They’re theorems about numbers and the numbers’ digits.  The distinction is important because numbers themselves are pretty fundamental, while the digits are a consequence of the base of the numeral system you’re using.  We use base ten, which is where these theorems hold.  They clearly fail in base three, for example, where we can write three = 10.  Consequently, this quick-factoring trick is one little gem of knowledge unknown to the ancient Pythagoreans or modern Canadians.

Note that three goes into 9, to 99, to 999, etc.  So take a number with some digits in it, say 5832.  (The great thing about being a math dabbler rather than a math student is that proofs by example, which are totally easy, don’t bother you one bit).

\frac{5832}{3} = \frac{5*1000}{3} + \frac{8*100}{3} + \frac{3*10}{3} + \frac{2}{3}

Now we’ll write 1000 as 999+1, and pull the same trick for the other powers of ten.  Then break up the fractions using \frac{a+b}{c} = \frac{a}{c} + \frac{b}{c}.

\frac{5832}{3} = \frac{5*999}{3} + \frac{5*1}{3} + \frac{8*99}{3} + \frac{8}{3} + \frac{3*9}{3} + \frac{3}{3} + \frac{2}{3}

Since we only care whether this gives an integer, we can drop all those ones with the 9, 99, 999 etc. in the numerator.  They cleary do give integers.  This leaves us to evaluate whether

\frac{5}{3} + \frac{8}{3} + \frac{3}{3} + \frac{2}{3} = \frac{5+8+3+2}{3}

is an integer.   So to test whether a number is divisible by three, add its digits.  Likewise for nine, since nine also divides 9, 99, 999…

What got me looking at this was that my student, curious young mathematician that he is, asked if the same holds true for 27.  We can say right off the bat that because every multiple of 27 is also a multiple of nine, the digits of a multiple of 27 must sum to a multple of nine.  However, there is no requirement that the multiple of nine they sum to is 27.  For example, 54 is a multiple of 27, but its digits sum to 9.  2727 is a multiple of 27 (27*101), but its digits sum to 18.

But does a one-way version of the theorem still hold?  If the digits of a number sum to 27, is that number divisible by 27?  The first such number you’ll run into is 999 = 27 * 37.  I tried six or seven other examples.  They all worked.  So I set out to prove it and was running into trouble.  But the nice thing was that although I couldn’t prove it, my attempt to find a proof showed me an easy way to find a counterexample.  I won’t go into the details, but you can go searching for yourself.  Here’s a hint: \frac{818172}{27} = 30302 \frac{2}{3}.

Higher powers of three are an obvious generalization.

If you followed the proof closely, then two things:

  • wtf?  it’s not like it’s your homework or something.  or like i know what i’m talking about
  • you can find similar properties in base n

In base 7, for example. a number’s digits will sum to a multiple of six if and only if the number is itself a multiple of six.  For example, in base 7

213 = 2*7^2 + 1*7 + 3 = 2*(7^2 - 1) + 1*(7-1) + 2 + 1 + 3

So all the same stuff will work as long as 6 goes evenly into 7-1, 7^2-1, 7^3-1,...  It does, because \frac{7^5 - 1}{6} = \frac{66666}{6} = 11111 in base 7.  So if you want to see whether p divides q evenly, you could always just convert q to base p+1 and add the digits.  However this is quite a bit more work than just doing the straight up division problem.

Also note that the reason the theorem works for three is that it goes evenly into nine. In base 13 the trick works for 12, 6, 4, 3, and 2. And on a practical note, in hexadecimal it works for f (which is what you use for 15), 5, and 3. Hexadecimal is actually quite nice for factoring, because in addition to easy rules for those numbers, you also have easy rules for 2, 4, and 8 – you can just check the last digit of the number the same way you can to see if something is a multiple of 2 or 5 in base 10.