## Don’t Design for Reuse

July 14th, 2012

Last week one of my colleagues hit me with an idea that was so obvious when he pointed it out I wondered why I hadn’t realized it before:

If you’re designing for reuse, you’re doing it wrong.

In 2012 the only code you should be writing is what’s needed for the immediate task at hand. Don’t design for reuse. Don’t consider reuse. Don’t waste one minute of your day making code reusable.
Read the rest of this entry »

## Calculating Sines without Calculus

June 3rd, 2012

One of my better math teachers in high school was John Brumfield. He taught me Algebra I and Precalculus. He was also exceptional at calculation, a skill that got him into in the artillery core in World War II, where he had to calculate gunnery firings in real time. And he had a great sense of humor. But one of the things that stands out most clearly in my memory from one of his classes is something he may have gotten wrong (perhaps deliberately). At that point in the early 1980s scientific calculators existed, but were quite expensive and not yet integrated into the high school mathematics curriculum. We were probably one of the last classes to spend significant time learning about trig tables, and how to interpolate between values. (A surprisingly useful skill, by the way, even if the reason we learned it no longer applies.) I recall that someone in the class asked him how the numbers in the tables were calculated. E.g. how did the author know that the sine of 47.1 degrees was 0.0238875315 and not 0.0238875326 or some other value? And his answer still sticks with me to this day, and I quote it word for word: “Very accurate graphs”.
Read the rest of this entry »

## Why are the Integers a Cyclic Group?

May 27th, 2012

If we follow Wikipedia in defining a cyclic group as a group in which there exists an element g in G such that G = <g> = { gn | n is an integer }, then the integers under addition are clearly a cyclic group with the generator 1. But why do we define cyclic groups that way? Or, another way of putting it, why is the definition given the name cyclic when there’s nothing cyclic about it?
Read the rest of this entry »

## What is a Determinant?

February 12th, 2012

I was watching Gilbert Strang’s 18th lecture in 18.06 Linear Algebra a couple of days ago, and he laid out a theory of determinants that started from a few basic properties and derived all the usual results. However he provided essentially no motivation for what he was doing. Why these properties? How did any one ever think of these particular axioms? And more tellingly, what is a determinant, really? I don’t mean the official definition (here quoted from Wikipedia and similar to Strang’s):

If we write an n-by-n matrix in terms of its column vectors

$A = \begin{bmatrix} a_1, & a_2, & \ldots, & a_n \end{bmatrix}$

where the aj are vectors of size n, then the determinant of A is defined so that

$\det\begin{bmatrix} a_1, & \ldots, & b a_j + c v, & \ldots, a_n \end{bmatrix} = b \det(A) + c \det\begin{bmatrix} a_1, & \ldots, & v, & \ldots, a_n \end{bmatrix}$
$\det\begin{bmatrix} a_1, & \ldots, & a_j, & a_{j+1}, & \ldots, a_n \end{bmatrix} = -\det\begin{bmatrix} a_1, & \ldots, & a_{j+1}, & a_j, & \ldots, a_n \end{bmatrix}$
$\det(I) = 1 \,$

where b and c are scalars, v is any vector of size n and I is the identity matrix of size n. These properties state that the determinant is an alternating multilinear function of the columns, and they suffice to uniquely calculate the determinant of any square matrix. Provided the underlying scalars form a field (more generally, a commutative ring with unity), the definition below shows that such a function exists, and it can be shown to be unique.

I can follow the derivation from that, but it doesn’t really explain what a determinant is. And the only alternative I could find in Wikipedia or the readily available textbooks, was that it’s the volume of a parallelepiped of the matrix formed by the vectors representing the parallelepiped’s sides. Again, that feels like a derived property, not a true definition. However, Mathworld, did give me one big hint:

For example, eliminating x, y, and z from the equations
= 0
= 0
= 0
gives the expression

which is called the determinant for this system of equation.

So here’s the answer: the determinant is the condition under which a set of linear equations has a non-trivial null space. Or, more simply, the determinant is the condition on the coefficients a, b, c… of a set of n linear equations in n unknowns such that they can be solved for the right hand side (0, 0, 0, …0) where at least one of the unknowns (x, y, …) is not zero. Let me prove that:
Read the rest of this entry »

## An Open Letter to My Public Library

January 19th, 2012

Dear Librarians,

I’d like to thank you for the work you’ve done putting the library catalog online. The ability to reserve books online (and then renew them online when I don’t finish them on time) has been invaluable. It has dramatically increased my use of the library. Now when I need a book I routinely check the library first rather than ordering it from Amazon. It’s cheaper, the book gets to me faster; and when I’m done, the book no longer takes up space in my apartment. Excellent! Kudos all around.

And now you have eBooks so I don’t even have to go to the library to pick up my reservations! Regrettably the selection of eBooks is somewhat thinner and more oversubscribed; and yes, I know this is partially the publishers’ fault. Still, for the books that are available, it’s wonderful knowing that even the thickest physics text or mathematical tome isn’t going to weigh more than a small eReader or tablet. It makes reviewing calculus on the subway so much more practical.

I’d like to make a friendly suggestion for ramping this up a notch, making the library even more useful, expanding the collection, and increasing monetary donations to the library at the same time. Your circulating collection is large, probably one of the largest in the country, and certainly the largest one I’ve ever had the pleasure to use. Probably 90% of the time the book I’m looking for is available at one of your branches, and you helpfully bring it from wherever it is to my local library where I can pick it up off the reserve shelf. But there’s still that 10% of the time when you happen not to have the book I’m looking for. (And for eBooks that’s more like 90% of the time.) Sometimes that’s because it’s a relatively obscure technical book; but sometimes it just looks like a fluke. For instance, it’s the second book in a trilogy for which you have the first and the third, but somehow missed the middle (or it went missing). Or it’s a novel by an author, most of whose works you already have. It’s something that clearly fits in your collection but just doesn’t happen to be there yet. So off I surf to Amazon where I buy a book I only really want to read once, and that then is going to sit on my shelf untouched for years.

Here’s my idea: I’d rather buy the book for the library and than buy it for myself.
Read the rest of this entry »