Latex in WordPress


So I love using Overleaf for writing latex documents, but I can’t publish them as html :( I’ve investigated this before, but decided to take the plunge today and see how publishing latex on WordPress works.

First example is the venerable 2 + 2 = 4:

2 + 2 = 4

So that worked, but it’s not dark and I’d like it bigger….

2+2 = 4

Now let’s give it something harder like the quadratic formula…

m_{1,2} = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}

Okay, not bad…. let’s step it up 🙂

y'' + P(x)y' + Q(x)y = f(x)

y_2 = y_1\int \frac{e^{-\int P(x)dx}}{y_1^2}dx

Again, not bad… now I like to write about quantum computing… let’s see how it does here…

\ket{\psi'} = U\ket{\psi}

Now that will not do… for reference I was using the out-of-box wordpress.com support which they kind of just throw out there… now more research…

Quantum Endianess


This is one of my favorite shirts, it’s basically a bunch of binary in a Microsoft logo…

My children love to ask, what does this mean? And as I think of an answer, my old consultant answer always come back: “It depends” 🙂 It depends on how you told the computer to interpret the binary. Looking at the binary below:

01010101010011000000000110010100000000011100100000000001100101000000000110111000000000011010010000000001110100000000000111100100000000

You could tell a computer, “Hey this is UTF-16” and suddenly that becomes the word “Serenity” to the computer. By default, UTF-16 encoding uses little endian on Windows.

If I change this to UTF-16 big endian, suddenly the binary is interpreted as “匀攀爀攀渀椀琀礀”. Quite a difference!

What is Most Significant?

The best example to start with is the familiar decimal numbers. For these numbers, the most significant digit is the one with the greatest value in the number. For the number 238, the number two is the most significant as it stands for 200. The least significant digit is the one with the least value in the number. For 238, this would be the number 8.

These definitions are the same in binary. The most significant bit (MSB) represents the greatest value of a binary string and the least significant bit (LSB) the least value. Let’s look at the number nine in binary:

\displaystyle {{1001}_{{binary}}}=1\times {{2}^{3}}+0\times {{2}^{2}}+0\times {{2}^{1}}+1\times {{2}^{0}}=8+0+0+1={{9}_{{decimal}}}

As you can see the left most one is the MSB as it represents 8 and the right most one is the LSB as it represents one.

Big-Endian vs Little-Endian

Endianness in our context has to do with how qubits are stored in memory. For this, qubits are analogous to bits and we will use the terms MSB and LSB. Big-Endian (BE) stores the MSB at the smallest memory address and the LSB at the biggest memory address. Little-Endian (LE) does the exact opposite in that the MSB is at the largest memory address and the LSB is at the smallest address.

The next question becomes, what is the smallest and biggest memory address? Well in Q#, qubits are stored in arrays called registers as shown in this code:

// allocate a register of n qubits in |0>
use qubits = Qubit[n]; 

Most of the time endianness does not matter because you can specify which qubits in the register to operate on such as:

CNOT(qubits[0], qubits[1]);

But for certain operations, it matters a lot! One of these is the Quantum Fourier Transform (QFT). The Q# operation QFT expects a quantum register in Big-Endian format. If however you want to call it on a Little-Endian register, you can use the operation QFTLE (the LE at the end is for Little-Endian). There are a number of these operations in Q# such as ApplyReversedOpBE and ApplyReversedOpLE.

Now to the big reveal, what is endianness in quantum computing, specifically Q#? Well, let’s think about it. If a register is nothing more than an array, then its lowest memory address will be at the index 0 and its highest index will be at the number n – 1. Using our definitions above, this means that BE implies that the MSB is stored at index 0 and the LSB is stored at index n – 1. Indeed, this is what the documentation says for the BigEndian type in Q#:

BigEndian user defined type

Register that encodes an unsigned integer in big-endian order. The qubit with index 0 encodes the highest bit of an unsigned integer.

newtype BigEndian = (Qubit[]);

The documentation for LittleEndian says the exact opposite.

Using these definitions, let’s look at the number |8> which in quantum is:

\displaystyle |8\rangle =|1\rangle \otimes |0\rangle \otimes |0\rangle \otimes |0\rangle =|1000\rangle

So |1⟩ is the MSB and the rightmost |0⟩ is the LSB. In an array or register it would look like this for BE:

\displaystyle \begin{array}{*{20}{c}} {Index} & 3 & 2 & 1 & 0 \\ {Qubit} & {|0\rangle } & {|0\rangle } & {|0\rangle } & {|1\rangle } \end{array}

And in LE like this:

\displaystyle \begin{array}{*{20}{c}} {Index} & 3 & 2 & 1 & 0 \\ {Qubit} & {|1\rangle } & {|0\rangle } & {|0\rangle } & {|0\rangle } \end{array}

I hope this has answered any questions you had about quantum endianness!

Software is everywhere – especially in cars


Amazing article in NY Times talks about how software is taking over everything, even our cars!  We can’t see this software and it’s been exposed to hacking (Jeep being driven off the road by remote hacker) and manipulations of emissions tests at Volkswagen.  People in the article argue cogently that this code should be made open-source so that we can examine it and know what we are buying as consumers.  At the very least, it should go through some of the strict reviews and audits that airplane software goes through.  Congress and the federal government should act before something bigger happens than the two examples above forces them to.

A Historic Bug


The recent “bug” that afflicted the BATS trading system will probably be one for the ages and go along with other famous bugs like the Ariane 5 rocket and Y2K problem.  Of course BATS is calling it a “freak one-time event”, but this bug caused massive losses of money.  Fortunately there was no loss of life, but past bugs have caused this  like the Therac-25 radiation therapy bug.

I am a huge advocate for Software Engineering and the growth of this profession.  When I study the growth of similar professions, such as Civil Engineering, the government did not get involved and create certifications like the PE until there were massive loss of life due to bridges crumbling.  It is unfortunate that a similar type of software bug will cause the public to take notice of the pervasive influence of software in our society and needs to be recognized as a profession in its own right.  There have been close calls like the Toyota brakes problem which had a lot of software in it, but was ultimately the software was not found to be at fault.  Here’s to hoping that the government and public don’t wait to recognize Software Engineering as a profession.