note
QM
<blockquote><i>
So, now I've got my "schoolboy approach" working, care to point me at the methods clever people would use?
</i></blockquote>
I was too lazy to look before, but now that I have, I was a bit off. On the other hand, I snuck in something similar in step 5 anyway. Here's what I remembered when I said that:
<p>
In [http://perl.plover.com/qotw/e/solution/002|QOTW #2] [Dominus|MJD] considers the n_choose_k function that computes:
<blockquote><code>
sub n_choose_k {
my ($n, $k) = @_;
# f($n) = $n!
return f($n)/f($k)/f($n-$k);
}
</code></blockquote>
He notes that the intermediate values are very large, even though the final result is not. He submits this replacement:
<blockquote><code>
sub n_choose_k {
my ($n, $k) = @_;
my $t = 1;
for my $i (1 .. $k) {
$t *= $n - $k + $i;
$t /= $i;
}
return $t;
}
</code></blockquote>
and he notes:
<blockquote><i>
$t here is always an integer, and never gets bigger than necessary.
</i></blockquote>
For your formula, this only applies to a small portion of the terms. You may be better off just ignoring MJD's improvement and proceeding as I outlined before.
<div class="pmsig"><div class="pmsig-294463">
<p>-QM<br />
--<br />
Quantum Mechanics: The dreams stuff is made of
</div></div>
481987
482145