The binomial coefficients find great many uses in combinatorics, but also in calculus. The usual way we understand the binomial coefficients is
,
where and
are integers. But what do you do with
?! Is it even defined?
The binomial coefficients find great many uses in combinatorics, but also in calculus. The usual way we understand the binomial coefficients is
,
where and
are integers. But what do you do with
?! Is it even defined?
Sometimes, you need to compute a function that’s complex, cumbersome, or which your favorite language doesn’t quite provide for. We may be interested in an exact implementation, or in a sufficiently good approximation. For the later, I often turn to Abramovitz and Stegun’s Handbook of Mathematical Function, a treasure trove of tables and approximations to hard functions. But how do they get all these approximations? The rational function approximations seemed the most mysterious of them all. Indeed, how can one come up with
for , for
?
Well, turns out, it’s hard work, but there’s a twist to it. Let’s see how it’s done!
We’re so used to our positional notation system that we can’t really figure out how to write numbers in other systems. Most of the ancient systems are either tedious, complicated, or both. Zero, of course, plays a central role within that positional system. But is it indispensable?
In one of my classes, I discuss a lot of different numeration systems (like Egyptian, Babylonian, Roman and Greek) to explain why the positional system solves all, or at least most, of these systems’ problems. I even give the example of Shadok counting (in french) to show that the basis used isn’t that important (it still has to be greater than one, and, while not strictly necessary, preferably a positive integer). But can we write numbers in a positional system without zero?
Quite a while ago I discussed using flat arrays and address calculations to store a tree in a simple array. The trick wasn’t new (I think it’s due to Williams, 1964 [1]), but is only really practical when we consider heaps, or otherwise very well balanced trees. If you have a misshapen tree, that trick doesn’t help you. It doesn’t help you either if you try to serialize a misshapen tree to disk.
But what if we do want to serialize arbitrarily-shaped trees to disk? Is it painful? Fortunately, no! Let’s see how.
It’s that time again. The semester’s almost over, only a few assignments and exams to mark; everybody’s busy at their own stuff. Like the last few summers, I’ll kind of close the blog until September. I said “kind of” because maybe I’ll post a few things anyway. Especially that this summer will be interesting: more time for research, 7ECM, which I will attend, and a few other things. Seeya in September!
The two seemingly trivial and unimportant problems of what kind of whitespaces and how to use them are still not solved. Some still use hard-coded tabs in their source code, and because they set tabs to be two spaces wide in their favorite editor, they expect the rest of the planet to have done so. The result is that spacing will break in another person’s editor, and the code will look like it’s been written by a four years old. Also, when tabs and spaces are mixed, and randomly interpreted, the indentation, the general aspect of how the code is presented, is broken.
While marking assignments, I encountered a number of such pieces of code. So I decided to fix that with a simple Emacs command.
This week, as you might have guessed, was pretty busy as the semester is coming to a close. Among many things, I prepared lecture notes, marked assignments, and all that, but I also got to launch the café des sciences de l’UQAR.
A university is a place where we are supposed to transmit knowledge, but more importantly transmit a love of knowledge and keep alive the joy of discovery. The café des sciences is about that transmission: once a month a guest comes to talk about what his point of view on science is, what research he (or she) is conducting, and everybody is invited. Not only professors. Not only students. Everyone. That’s why the café des sciences will not always be held within the university walls, but will visit café in the general Rimouski area.
You can read more about the café des sciences here. You’re all invited!
You can follow us on twitter at https://twitter.com/CafeScienceUQAR
I am still experimenting with hash functions, and I was toying with the Zobrist hash function[1] that is best known for its use in chess engines. The hash function is conceptually simple: you need a large table of random numbers, indexed, in a chess application, by the position on the board of the piece and by the piece itself. To compute a hash for a whole board configuration, you simply xor all the random numbers together. The hard part is choosing the random numbers.
Last week, we had a look at the computation of Log2 using templates and constexpr. Of course, I had ulterior motives. In particular, I was interested in allocating just the right number of bits for a field in a bit field, but rather than hard-coding it, having it deduced from a template argument. Let’s see how we can do that.
C++ meta-programming a powerful tool. Not only can you use it to build generic types (such as the STL’s std::list), you can also use it to have compile-time evaluation. Let’s have a look at a simple problem that can be solved in two very different ways: computing the Log base 2 of an integer.