With thanks to Prof Bindel of the Big Red.
I am putting this up because the wikipedia example on this is divinely lacking in what normal people consider “correct”ness or clarity of exposition.
Source - qrdecomp
Working implementation - qrdecomp
It uses a slightly modified version of my Newton v1.10 library – all modifications will be incorporated in the next revision of Newton.
I put in a nifty thing I have been learning about for numerical precision (first time I actually used the concept of a machine epsilon), wrestled with some SUPREMELY annoying bugs in Excel’s inbuilt MMult function (I have had to build my own replacement), and wrote out some little functions we take for granted in Matlab like Eye and Norm (or, for that matter, qr…). I left the code uncleaned for the time being in case there are still minor bugs I haven’t found.
I have a sneaking suspicion that all this work could have been avoided if I could figure out a way to derive the Q and R matrices from the results of OLS regression, as Excel actually does their LINEST function WITH an inbuilt QR algorithm (and OF COURSE they choose NOT to let users access the QR algo). However I couldn’t derive any sort of backward inductive relationship.

.