February 28, 2012
A couple of months ago (already!) 0xjfdube produced an excellent piece on table-based trigonometric function computations. The basic idea was that you can look-up the value of a trigonometric function rather than actually computing it, on the premise that computing such functions directly is inherently slow. Turns out that’s actually the case, even on fancy CPUs. He discusses the precision of the estimate based on the size of the table and shows that you needn’t a terrible number of entries to get decent precision. He muses over the possibility of using interpolation to augment precision, speculating that it might be slow anyway.

I started thinking about how to interpolate efficiently between table entries but then I realized that it’s not fundamentally more complicated to compute a polynomial approximation of the functions than to search the table then use polynomial interpolation between entries.
Read the rest of this entry »
1 Comment |
algorithms, assembly language, C, C-plus-plus, C99, embedded programming, Mathematics, programming | Tagged: cos, cosine, MacLaurin Series, Polynomial, Polynomial Approximation, SIN, Sine, Taylor Series |
Permalink
Posted by Steven Pigeon
July 21, 2009
I once worked in a company specializing in embedded electronics for industrial applications. In one particular project, the device communicated through a RS-422 cable to the computer and seemed to return weird data once in a while, causing unwanted behavior in the control computer whose programming did not provide for this unexpected data. So I took upon myself to test the communication channel as it seemed that the on-board software was operating properly and did not contain serious bugs. I added a check-sum to the data packet and it turned out that some packets came in indeed corrupted despite the supposedly superior electrical characteristics of the RS-422 link.
After a few days’ work, I implemented the communication protocol that could detect and repair certain errors while reverting to a request to retransmit if the data was too damaged. I then started gathering statistics on error rate, number of retransmit, etc, and the spurious behavior on the controller’s side went away. My (metaphorically) pointy-haired boss opposed the modification because “we didn’t have any of these damn transmission errors until you put your fancy code in there“. Of course, this was an epic facepalm moment. I tried to explain that the errors have always been there, except that now they’re caught and repaired. Needless to say, it ended badly.

Notwithstanding this absurd episode, I kept using check-sum to validate data whenever no other layer of the protocol took care of transmission errors. So, this week, let us discuss check-sums and other error detection algorithms.
Read the rest of this entry »
1 Comment |
algorithms, bit twiddling, embedded programming, hacks, Life in the workplace, Mathematics, programming, theoretical computer science | Tagged: check-sum, check-sums, checksum, checksums, CRC, cyclical redundancy check, data packet, divisor polynomial, Don Knuth, error correction, error detection, ethernet, hash, ISBN, ISBN 10, ISBN 13, Knuth, Luhn, md5, mod, modulo, remainder, RS-232, RS-422, salt, searching, secure hashes, sha, SIN, social insurance number, sorting, sorting and sorting, The Art of Computer Programming, zip, zip file |
Permalink
Posted by Steven Pigeon