Thursday, May 24, 2007

Combinatorics

So now SpeedCrunch has got combinatorics support. Ariya had already implemented the famous nCr function, so I decided to code its cousin nPr.
I'd realized a nice optimization in Ariya's code. The general definition of nCr is given by
nCr = n! / ((n-r)! r!)
n, r ∈ N0 , r ≤ n (applies all bellow)

But we can indeed reduce very much the number of integer multiplications with the derivation
r ∈ {0, n} ⇒ nCr = 1
r = 1 ⇒ nCr = n
r ∈ ]0, n/2] \ {1} ⇒ nCr = (r+1)n / (n-r)!
r ∈ ]n/2, n[ \ {1} ⇒ nCr = (n-r+1)n / r!

Note that (r+1)n, for instance, is a modern factorial notation equivalent to (n)(n-1)...(r+1). I didn't know about this myself until now. This fasts computation a lot, else the very same calculations would be uselessly repeated.
In the very same way, I found a nice simplification for nPr. The general definition of nPr is given by
nPr = n! / (n-r)!

And again we can do some magic
r = 0 ⇒ nPr = 1
r = 1 ⇒ nPr = n
r = n ⇒ nPr = n!
r ∈ ]1, n[ ⇒ nPr = (n-r+1)n

I spent some minutes getting to this conclusion and then I read it somewhere right after. First I felt a bit frustrated, then I smiled. It's funny to develop this program, it's funny to play maths.

I then realized my old Casio FX-880P can compute up to 69! and SpeedCrunch currently up to 96!, that's good enough (150-digit long integer). Nevertheless, when the user tries to calculate factorials, combinations or permutations with huge parameters the program freezes (even by the calc-as-you-type feature). Maybe it's really a good idea to define an upper limit for those functions input.

How to request a feature

So, you really really like SpeedCrunch but in order to really "leave" the other calculator, you need a feature or two. For example, say you need to have hexadecimal and binary support. Then, perhaps you want to request a feature to be implemented in the next version. How to do this effectively?

First of all, make sure you use the latest version of SpeedCrunch. This is important because SpeedCrunch is constantly improved and often features requested by our users have made it into the release quite fast. You can get the version by choosing menu Help, About. You can compare it against what is shown in the download page (of the website).

Now go to issue list, click on New Issue. Enter a short summary (this is very important!) and type in the description of the feature that you'd like to have. Because this is going to be a feature, not a defect, you should change the label "Type:Defect". Just click on it and choose "Type:Enhancement" from the pop-up menu. Review again your description and if everything is fine, click the Submit button. Your feature request should appear on the issue list now.

It is equally important to search first for existing issues before requesting a feature. Perhaps it is already filed by someone, so you wouldn't want to duplicate. You can always add your own comment to someone's else feature request, perhaps to add your own opinion about it. To search for issue is very simple. From the issue list, enter keyword in the search box and click Search button. You may also want to change Open Issues to All Issues to be able to search resolved issues, in case your feature is already implemented. For example, don't ask for hex and binary support anymore because work on this has been started, as evidenced from issue #13.


And, we're waiting! Your wish is our command....

Wednesday, May 23, 2007

Take-off

From now on, here you can follow what SpeedCrunch developers are working on or even just wondering about the direction it should take. Everybody can leave comments as well, this way providing useful feedback. Please help making this project become the best free multi-platform desktop calculator available by sharing your thoughts. Thank you and enjoy it.