Inverse of a larger matrix and Power Series

Hits: 75

Most textbooks I have on Lin Alg discuss finding the inverse of a 2×2 matrix,and appear to have little to say about inverting 3×3 matrices and above. I was trying to invert a 5×5 matrix, but all I could find after looking through two linear algebra textbooks, and the internet was info for 2×2 matrices.

    \begin{equation*} \begin{bmatrix}a & b\\c & d\end{bmatrix}^{-1} = \frac{1}{ad-bc} \begin{bmatrix}d & -b\\-c & a\end{bmatrix} \end{equation*}

… except the web page I read used comic sans. Then there was this really good lin alg textbook I came across that had a technique that used a 3×3 example that could scale to any size. Bingo. The next problem will be presenting this to you as there appears to be no way (after an online lookup) to present the notation to you in a satisfying way. I will separate two matrices with a right arrow (\longrightarrow) instead of using a double matrix with a vertical bar in the middle. I also have to reckon with limitations in using Latex notation in a blog article. So, please excuse any makeshift notation used in this article.

    \begin{equation*} \begin{bmatrix} 1&0&0&0&0 \\ 1&1&0&0&0 \\ 1&2&1&0&0 \\ 1&3&3&1&0 \\ 1&4&6&4&1 \\ \end{bmatrix}\longrightarrow \begin{bmatrix} 1&0&0&0&0 \\ 0&1&0&0&0 \\ 0&0&1&0&0 \\ 0&0&0&1&0 \\ 0&0&0&0&1 \\ \end{bmatrix} \end{equation*}

The idea being, to turn the left matrix into the right matrix, applying the techniques of Gauss-Jordan elimination. Meanwhile, any operation I commit to the left matrix must be also done to the right matrix. It turns out that you don’t necessarily get the same matrix. First, I subtract the first row from the rows below:

    \begin{equation*} \begin{bmatrix} 1&0&0&0&0 \\ 0&1&0&0&0 \\ 0&2&1&0&0 \\ 0&3&3&1&0 \\ 0&4&6&4&1 \end{bmatrix}\longrightarrow \begin{bmatrix} 1&0&0&0&0 \\ -1&1&0&0&0 \\ -1&0&1&0&0 \\ -1&0&0&1&0 \\ -1&0&0&0&1 \\ \end{bmatrix} \end{equation*}

Then, I apply the same thinking with the second row to eliminate variables in the second column of the left matrix, and proceed similarly for subsequent columns of the left-hand matrix:

    \begin{equation*} \begin{bmatrix} 1&0&0&0&0 \\ 0&1&0&0&0 \\ 0&0&1&0&0 \\ 0&0&3&1&0 \\ 0&0&6&4&1 \\ \end{bmatrix} \longrightarrow \begin{bmatrix} 1&0&0&0&0 \\ -1&1&0&0&0 \\ 1&-2&1&0&0 \\ 2&-3&0&1&0 \\ 3&-4&0&0&1 \\ \end{bmatrix} \end{equation*}

    \begin{equation*} \begin{bmatrix} 1&0&0&0&0 \\ 0&1&0&0&0 \\ 0&0&1&0&0 \\ 0&0&0&1&0 \\ 0&0&0&4&1 \\ \end{bmatrix}\longrightarrow \begin{bmatrix} 1&0&0&0&0 \\ -1&1&0&0&0 \\ 1&-2&1&0&0 \\ -1&3&-3&1&0 \\ -3&8&-6&0&1 \\ \end{bmatrix} \end{equation*}

    \begin{equation*} \begin{bmatrix} 1&0&0&0&0 \\ 0&1&0&0&0 \\ 0&0&1&0&0 \\ 0&0&0&1&0 \\ 0&0&0&0&1 \\ \end{bmatrix}\longrightarrow \begin{bmatrix} 1&0&0&0&0 \\ -1&1&0&0&0 \\ 1&-2&1&0&0 \\ -1&3&-3&1&0 \\ 1&-4&6&-4&1 \\ \end{bmatrix} \end{equation*}


    \begin{equation*} \begin{bmatrix} 1&0&0&0&0 \\ 1&1&0&0&0 \\ 1&2&1&0&0 \\ 1&3&3&1&0 \\ 1&4&6&4&1 \\ \end{bmatrix}^{-1} = \begin{bmatrix} 1&0&0&0&0 \\ -1&1&0&0&0 \\ 1&-2&1&0&0 \\ -1&3&-3&1&0 \\ 1&-4&6&-4&1 \\ \end{bmatrix} \end{equation*}

You might recognize number pattern in the very first matrix to resemble part of Pascal’s Triangle:

    \begin{equation*} \begin{bmatrix} 1& 0& 0& 0& 0 \\ 1& 1& 0& 0& 0 \\ 1& 2& 1& 0& 0 \\ 1& 3& 3& 1& 0 \\ 1& 4& 6& 4& 1 \\ \end{bmatrix} \end{equation}

There was a Mathologer video on YouTube which I saw recently which modified this Pascal-triangle based matrix. First, it changed the main diagonal from 1 to 0; then removed the top row; then moved all rows up and added a new row. Then every second diagonal is “decorated” (Burkhard Polster’s words, not mine) with minus signs in the following manner:

    \begin{equation*} \begin{bmatrix} 1& 0& 0& 0& 0 \\ -1& 2& 0& 0& 0 \\ 1& -3& 3& 0& 0 \\ -1& 4& -6& 4& 0 \\ 1& -5&10&-10& 5 \\ \end{bmatrix} \end{equation}

This weird concoction of Pascal’s triangle is based on the coefficients of the expansion of -(1-x)^k, where k is the row number of the matrix counting from 0. Also, the last term, 1, is omitted as stated before. The inverse of this matrix is a fair bit different, but has a special property. When you find the inverse, then multiply by a 5 by 1 matrix consisting of successive powers of n, you get:

    \begin{equation*} \begin{bmatrix} 1& 0& 0& 0& 0 \\ -1& 2& 0& 0& 0 \\ 1& -3& 3& 0& 0 \\ -1& 4& -6& 4& 0 \\ 1& -5&10&-10& 5 \\ \end{bmatrix}^{-1} \times \begin{bmatrix} n \\ n^2 \\ n^3 \\ n^4 \\ n^5 \end{bmatrix} = \begin{bmatrix} 1& 0& 0& 0& 0 \\ \frac{1}{2}& \frac{1}{2}& 0& 0& 0 \\ \frac{1}{6}& \frac{1}{2}& \frac{1}{3}& 0& 0 \\ 0& \frac{1}{4}& \frac{1}{2}& \frac{1}{4}& 0 \\ -\frac{1}{30}& 0& \frac{1}{3}& \frac{1}{2}& \frac{1}{5} \\ \end{bmatrix} \times \begin{bmatrix} n \\ n^2 \\ n^3 \\ n^4 \\ n^5 \end{bmatrix} \end{equation*}

We multiply by the n^r series in order to lead us to the next step, which is to reveal that each row in this matrix make up the coefficients of the sum of a power series after multiplication:

    \begin{align*} S_0 &= \sum_{n=1}^{\infty} 1 = n \\ S_1 &= \sum_{n=1}^{\infty} n = \frac{n}{2} + \frac{n^2}{2} \\ S_2 &= \sum_{n=1}^{\infty} n^2 = \frac{n}{6} + \frac{n^2}{2} + \frac{n^3}{3} \\ S_3 &= \sum_{n=1}^{\infty} n^3 = \frac{n^2}{4} + \frac{n^3}{2} + \frac{n^4}{4} \\ S_4 &= \sum_{n=1}^{\infty} n^4 = -\frac{n}{30} + \frac{n^3}{3} + \frac{n^4}{2} + \frac{n^5}{5} \end{align*}

The payoff here is that you can make a matrix as large as you want to find the summation formulae for all power series ad infinitum. The power series would utilize a 10\times 10 matrix to obtain the power series for S_9:

    \begin{align*} S_9 = \sum_{n=1}^{\infty} n^9 &= 1^9 + 2^9 + 3^9 + 4^9 + ... \\ &= -\frac{3n^2}{20} + \frac{n^4}{2} - \frac{7n^6}{10} + \frac{3n^8}{4} + \frac{n^9}{2} + \frac{n^{10}}{10} \end{align*}

More generally:

    \[ S_m = \sum_{n=1}^{\infty} n^m \]

for any m in the set of integers.

Google Reviews of the Quality of Service at Mount Everest Base Camp IV

Hits: 116

A screenshot of what I saw when I looked up Mount Everest. It seems to have a new set of pictures, and gave me the left panel when I clicked on “Everest Base Camp IV” on the map. This is in Sattelite View.

Base Camp IV is the camp nearest to the summit of the tallest mountain in the world. It is situated at 26,000 feet above sea level, in the oxygen-deprived region of the mountain called the “death zone”. It gets its name from the fact that at that altitude your body is consuming oxygen faster than you can breathe it in. When you surf there on Google Maps, you get a map of the summit, and depending on how much screen you have, the snow-encrusted Base Camps III and IV. If you went there on a search, Google likes to present you with a panel with hopefully useful information on the left-hand side.

With that, some rather questionable user options that seem out of place here. One of them is a phone number (do they really have phone service?), and a checkbox to “Claim this business”, making assumptions that are really unsuitable.

But the least suitable of all is that Google Maps offers a “Review” section, as if this is some kind of swanky hotel or neighbourhood restaurant. The people who climb Everest aren’t going there for room service or good food, and are probably assuming that Base Camp IV doesn’t have any kind of entertainment or any other reference to normal urban civilization that most of us are used to. To anyone not in the know: that isn’t why you climb Everest.

The truth is, one-third of climbers never make it to the summit, and 2% never make it back alive. If the weather is unfavourable to climb the rest of the way up after 48 hours at Camp IV, climbers are forced to return, effectively giving up their bid to make it to the top.

Then came the reviews. The authors of the reviews knew that the review section was out of place, and decided to put absurd, obviously fake, reviews which may be found here, and some zingers are given below:

From David Bell: The pool was closed when I checked in and they didn’t know when it would re-open, which was very disappointing. I also found it concerning that there was no bellhop available to help with my luggage and i had to carry it all myself. As for my accommodations Camp IV was rather cold and had a horrible draft. I was also told I would be given sherbet each day, orange is my favorite, yet when I arrived I was assigned a Sherpa who wasn’t sure what I was inquiring about. Pro tip: Don’t bother bringing ice for cocktail hour, there is plenty to be had. Overall I have to rate the local 5 stars for its location and scenery alone., simply majestic views and wildlife. The Yeti were very welcoming!

From Cheyenne Nicole Philips: Broke a nail on the way up! Very long walk from the parking lot! No cell service, wore the wrong shoes. Was told I would get a king size bed. When I showed up they only had sleeping bags. Didn’t pack a colorful enough outfit. Wind messed up my hair. Starbucks was closed! Will have to try again in the summer. Hopefully pool will be open, the views were average too.

From Shawn Speller: It was, well, alright I guess. Complimentary breakfast was alright: toast, jam, various fruits. Played bingo at the pavilion in the afternoon which was fun, although I have to say the sherpa caller was a little hard to hear so it made for a couple false bingos which was a little annoying. As far as the views, I mean, you get what you get. It’s a little cloudy in the mornings by mid day it clears up a bit but all you’re seeing is a rock and yeah I guess it’s a big rock but as other reviewers said too the brochure makes it look a lot bigger (false advertising). I’m giving a 3 star review simply because cell service was not an issue, I got 3 bars at the top of the mountain and was able to chill for a bit and binge watch Game of Thrones.

From Nick Randall-Smith: This is the 21st century and there is absolutely no provision for the disabled at this camp, there was no place to charge the battery on my wheelchair. All was not lost as I persuaded a Sherpa to carry me up to the viewing point at the top of the mountain, thank goodness I remembered my American Express card because the Sherpa charged a fortune with the feeble excuse that he was risking his life to get me up to the summit, and he had a problem getting the card machine to work too. The view was pretty good but I was hoping to see the sea from the top but you can’t so that was a disappointment. When we got down I offered the Sherpa a $5 tip but he rudely told me where to shove my good American dollars, ungrateful brute.

From Justin Mehoni: Bit rocky for sunbathing. I could feel the stones below my beach towel. And when I got up some darned yeti stole all my clothes!

From Martino Keates: No proper rooms, just TENTS!!! Food very boring. Asked for an omelette and salmon, received a biscuit. Worth noting that evenings can get very cold. Bring a cardigan.

From Kelly Zitterkopf: It was pretty cool, but the mountain wasn’t as tall as the brochure made it look. The camp didn’t provide wifi and cell reception was terrible. I was able to get one bar at the top of the mountain, but I found it tedious to walk up to the summit every time I wanted to update my twitter.

A composite of some reviews: No pets allowed. The wi-fi was pretty bad. Also the local CVS said they didn’t sell cigarettes anymore. Poor sea view. You have to go through Everest to the nearest TESCO. Also – I was under the impression that there was to be a “wise man” or some such personage at the summit. There wasn’t; instead I was subjected to the inane yammering of a veterinarian from Brisbane who kept calling me a “tough little sheila” whatever the heck that’s supposed to mean.

More reviews: Too far from the nearest parking lot, and no beer store. Starbucks was open when I came, but they couldn’t fill my order for “Double Ristretto Venti Half-Soy Nonfat Decaf Organic Chocolate Brownie Iced Vanilla Double-Shot Gingerbread Frappuccino Extra Hot With Foam Whipped Cream Upside Down Double Blended, One Sweet’N Low and One Nutrasweet, and Ice”. Oh and there is no cell service or wi-fi. This is the 21st century, how can there be no wi-fi? Won’t go back any time soon.

Still more: OK, I suppose, but the views were ruined by a great big mountain in the way. Also, there is poor signage and no ski lift. When I complained, they said they expected me to walk to the top of Everest! Do you know how freakin’ high Everest is? Apart from that, the toilets smelled and there were no antibacterial wipes either. I misread the equipment manifest and as a result brought tanks of helium rather than oxygen. As a result, the sherpas never took my commands seriously due to my now high-pitched voice. I had to put up with the sherpas, since they wouldn’t let me drive my camper to the summit.

Remarks on LaTeX editors

Hits: 123

Nearly three years ago on another blog, I wrote about a comparison of LaTeX editors. Soon after, I began to use a third editor which, if you are a latex expert, you almost certaintly would have heard about, and are probably in fact using TeXStudio, an editor that has been around for close to a decade, but never appeared to show up on Linux installation packages. The editors that showed up, at least for me, were LyX and TeXmacs.

TeXstudio, once I discovered it, I installed it everywhere I could: on my Windows 10 and 7 machines, on my Linux installations, and even on Cygwin, even though they already had a Windows installation. To this day I have not seen any difference in output or functionality. All invocations of TeXstudio require a lot of time and packages for an installation of enough features.

This is TeXstudio, with the horizontal toolbars shown, along with part of the workspace. There are two vertical toolbars there, also partially shown.

First thing’s first: the editor. In LyX and TeXmacs, I needed to bail out of the editor, and export the code to LaTeX whenever I needed to do any serious equation editing or table editing or the like. In contrast, TeXstudio leaves me with no reason to ever leave the editor. First of all, the editor allows for native latex code to be entered. If there are pieces of Latex code that you don’t know, or have a fuzzy knowledge about, there is probably an icon or menu item that covers it. For document formatting, a menu item leads to a form dialog where you can fill in the form with sensible information pertaining to your particular document, default font size, paper size, margins, and so on. The ouput of this dialog is the preamble section to the LaTeX source file. To the rest of that source file, you add your document and formatting codes.  It is a kind of “notepad” for LaTeX, with syntax highlighting and shortcut buttons, menus and dialogs. It comes close to being WYSIWYG, in that “compiling” the code and pressing  the green “play” button brings up a window with the output of the existing code you are editing. It is not a live update, but it saves you the agony of saving, going on the command line compiling the code, and viewing in seeminly endless cycles. Now you can view the formatted document at the press of the play button.

Compiling The Linux Kernel Docs

Hits: 100

In the last article, I said that compiling and installing source versions of software was akin to “going rogue”. I must confess that I have compiled from source and installed software that wasn’t in my distribution, most recently TexStudio, as being one of the larger projects, requiring tons of other libraries and whatnot to also be installed (or quite often, compiled from source on the side), since it wasn’t a part of the linux distro I was using at the time. It also wasn’t a part of Cygwin, and I compiled for that too. It was a great way to kill an afternoon.

But there was a time that I had compiled the kernel from source. It was necessary for me, as speed was an issue and I had slow hardware at the time. What I also had was a mixture of hardware pulled from different computers at different times. I researched specs on sound cards, network cards, video cards and the motherboard chipsets, and knew what specs to tweak on the kernel compilation dialogs, so I could get the kernel to do the right thing: which is to be fast and recognize all my hardware. I was doing this before the days of modules, with the version 1.x kernel. It worked, and it was noticeably faster than the stock kernels. X-Windows on my 80486 PC ran quite well with these compiled kernels, but was sluggish to the point of un-useable with a stock kernel running. Every few versions of the kernel, I would re-compile a new kernel for my PC, and pretty soon using the tcl/tk dialogs they had made things pretty easy, and I could answer all the questions from memory.

But then that all ended with version 2. Yes, I compiled a version 2 kernel from source, and yes, it ran OK. But it also had modules. The precompiled kernels were now stripped down and lean, and the modules would only be added as needed when the kernel auto-detected the presence of the appropriate hardware. After compiling a few times, I no longer saw the point from a performance standpoint, and today we are well into kernel version 5.3, and I haven’t compiled my own kernel for a very long time.

For the heck of it, I downloaded the 5.3 kernel, which uncompressed into nearly 1 gigabyte of source code. I studied the config options and the Makefile options, and saw that I could just run “make” to create only the documentation. So that’s what I did.

It created over 8,500 pages of documentation across dozens of PDF files. And 24 of them are zero-length PDFs, which presumably didn’t compile properly, otherwise the pagecount would have easily tipped the scales at 10,000. The pages were generated quickly, the 8,500 or more pages were generated with errors in about 3 minutes. The errors seemed to be manifest in the associated PDFs not showing up under the Documentation directory. I have a fast-ish processor, an Intel 4770k (a 4th generation i7 processor), which I never overclocked, running on what is now a fast-ish gaming motherboard (an ASUS Hero Maximus VI) with 32 gigs of fast-ish RAM. The compilation, even though it was only documentation, seemed to go screamingly fast on this computer, much faster than I was accustomed to (although I guess if I am using 80486’s and early Pentiums as a comparison …). The generated output to standard error of the LaTeX compilation was a veritable blur of underfull hbox’es and page numbers.

For the record, the pagecount was generated using the following code:

#! /bin/bash
list=`ls *.pdf`
for i in $list ; do
        # if the PDF is of non-zero length then ...
        if [ -s "${i}" ] ; then 
                j=`pdfinfo ${i} | grep ^Pages`
                j=`awk '{gsub("Pages:", "");print}' <<< ${j}`
                # give a pagecount/filename/running total
                echo ${j}	    ${i}    ${tot}
                # tally up the total so far
                tot=$(($tot + $j))

echo Total page count: ${tot}

Relitivistic Pedantry

Hits: 98

I must say first off, that I teach math and computer science, and was never qualified to teach physics. But I am interested in physics, and got drawn into in a physics discussion about how time does not stretch or compress in the visible world, and this is why in most of science, time is always the independent variable, stuck for most practical purposes on the x axis.

In the macroscopic world, time and mass are pretty reliable and so close to Einstein’s formulas (or those associated with the Special and General Theories of Relativity) at the macroscopic level that we prefer to stick to simpler formulas from classical mechanics, since they are great approximations, so long as things move well below the speed of light.

I am not sure (is anyone?) about how time is influenced by things like gravity and velocity (in particluar, the formulas stating how time is a dependent varable with respect to these things), but I remember an equation for relative mass, which doesn’t use time that would provide some insight into relativity:

    \[ \displaystyle{m(v) = lim_{v \to c^-} \frac{m_0}{\sqrt{1 - \frac{v^2}{c^2}}} = \infty} \]

Here, the independent variable is velocity, and it is evident that even for bodies that appear to move fast (on the scale of 10 to 20,000 km/h), it doesn’t have much impact on this equation. Rest mass and relative mass are essentially the same, and a body would have to move at nearly the speed of light for the mass of the moving body to change significantly. Indeed, as velocity v gets closer to the speed of light c, mass shoots up to infinity. I understand that Einstein stated that nothing can move faster than light, and this is supported by the above equation, since that would make it negative under the radical.

It does not escape my notice that velocity is supposed to depend on time, making the function m(v(t)), but time warps under things like high velocity also (as well as high gravity), so that time depends on … ? This is where I tell people to “go ask your physics prof” about anything more involved.

Sattelites move within the range of 10,000 to 20,000 km/h, hundreds of kilometres above the Earth’s surface. My assertion that there is not much change here in relativity terms. But this is still is large enough to keep makers of cell phones up at night, since not considering Einstein equations in time calcluations can cause GPS systems to register errors in a person’s position on the globe on the order of several kilometres, rendering the GPS functions on cell phones essentially useless.

My companion was trying to make the latter point, where I was thinking much more generally. We stick to classical mechanics, not because the equations are necessarily the correct ones, but instead because they are simple and lend a great deal of predictive power to the macroscopic world around us.

While you are quarantining and social distancing …

Hits: 136

Sir Isaac Newton, along with some personal notes written in Greek.

Other, greater people have done great things in quarantine way before you were born. I already knew that the late Sir Isaac Newton discovered things like optics, gravity, and the rules for Calculus, which he called the study of “fluxions”. But what I didn’t know is that in the two years he did so, he was in his early 20’s, and England suffered an epidemic of The Bubonic Plague, known as The Great Plague, in the years 1665-1666, long before infectious disease were known and understood. It is even worthy of remarking that so little was known of medicine generally that even Sir Isaac believed in alchemy until the day he died.

Prior to his quarantine he was thought of as an unremarkable undergraduate student, according to Wikipedia. But given two years cooped up where he lived and avoiding the Plague gave him time alone to come up with his brilliant theories on classical mechanics, using calculus to explain it mathematically.