Is there any math I can run to calculate the most efficient output for an N difficulty?
An output of size 2N will stake about as often as two outputs each of size N, and so in terms of how often your outputs stake it really doesn't matter what size they are.
The only important consideration is that when the output of size 2N stakes, the whole 2N+1 value sits idle for 500 blocks (8 hours) while it matures. When one of the two separate outputs of size N stakes, the other one continues trying to stake while the first one waits to mature. So splitting the output is more efficient for that reason only.
The more outputs you split your coins into, the less percentage of your coins are sitting idle waiting to mature at any time. So the "most efficient output" size is, I guess, 1 satoshi.
The problem with splitting that small is that it takes a finite amount of time to check each output for staking, and it costs a finite amount of transaction fee per output to spend it. So you need to balance splitting to minimize loss due to the 500 block maturity delay with loss due to transaction fees when you finally come to spend your outputs and CPU time burned to check for staking.
I find that making my outputs somewhere in the 20 to 40 CLAM range works fine.
If 1000 CLAMs stakes about once per day, then 3000 CLAMs stakes about once per 500 blocks, so if my outputs are 30 CLAMs each then about 1% of them are idle waiting to mature at any point in time.
Right now the Just-Dice staking wallet has 1,195,215 CLAMs. 1,179,875 are actively trying to stake and 15,340 are waiting to mature. That's around 1.28% of them that was sitting idle. Probably it's over 1% because on average they are over 30 CLAMs each. Counting the number of immature outputs of each size:
$ clamd listunspent 0 500 '[]' 0 | grep amount | awk '{print $3}' | tr -d , | cut -d. -f1 | sort | uniq -c
23 20
1 23
1 28
6 31
31 32
14 33
2 34
158 35
65 36
18 37
74 38
32 39
ie. there are 23 immature outputs of size 20 CLAM, etc.
Counting all outputs, whether mature or not we see that I have quite a range of sizes, from 17 CLAMs all the way up to 70 CLAMs:
$ clamd listunspent 0 9999999 '[]' 0 | grep amount | awk '{print $3}' | tr -d , | cut -d. -f1 | sort | uniq -c
39822 17
2856 18
86 19
26 20
28 22
60 23
40 24
5 25
3 26
1 27
39 28
6 29
5 30
2055 31
892 32
182 33
31 34
4418 35
1331 36
266 37
1926 38
476 39
75 41
49 42
6 43
2 44
3 54
1 57
45 67
10 68
343 70
Those 70 CLAM outputs are probably too big to be efficient, but it's not clear whether it's better to manually split them (wasting 4 hours of staking time per transaction) or leave them staking and let them split themselves when they next stake.