LaTeX: A Slice Of Awesome Pie

Being a relative newbie to the world of WordPress blogging, I am discovering new things every day that represent to me a small slice of awesome pie.  These discoveries provide me the (unnecessary, but freely accepted) justification to continue exploring this particular blogging environment.  It seems that with every slice of awesome pie that I discover, my nerd centre grows 2.1 sizes.

Today was no exception, although – full disclosure – I would rewrite my phrase above by replacing the word ‘small’ with ‘huge’.  That is correct, I would be willing to put myself out there and say that today’s discovery represents a huge slice of awesome pie.  What is this discovery?

WordPress can typeset \LaTeX!

!!!\LaTeX!!!

That may come as a surprise to no one but me, but I found this information earth shattering.  Earth. Shattering.  Okay, clearly I exaggerate the impact, but for me this discovery is still rather amazing.  I’d be lying if I were to say that this discovery didn’t give me a pretty serious nerd-on.

For the uninitiated, \LaTeX is a freeware document markup language used for typesetting scientific (read mathy) documents.  It is the program that I used to write my Masters thesis, and my more recent Ph.D. dissertation.  It allows one to write mathematical equations like this:

\begin{array}{ll}  \ln{p({\Theta,\Pi,\Omega}|Y,Z,X)} & \propto \displaystyle{\sum_{i,j,k=1}^{2,18,n}}\left\{z_{ijk}y_{ijk}(\gamma_{1}+\beta_{1}x_{ijk}+\Lambda_{1}u_{1j}+\Lambda_{2}u_{2j})\right.\\  {} & - z_{ijk}N_{ijk}\exp{(\gamma_{1}+\beta_{1}x_{ijk}+\Lambda_{1}u_{1j}+\Lambda_{2}u_{2j})}\\  {} & +(1-z_{ijk})y_{ijk}(\gamma_{2}+\beta_{2}x_{ijk}+\Lambda_{3}u_{2j})\\  {} & - (1-z_{ijk})N_{ijk}\exp{(\gamma_{2}+\beta_{2}x_{ijk}+\Lambda_{3}u_{2j})}\\  {} & \left.+ z_{ijk}\ln{\pi_{1}} + (1-z_{ijk})\ln{(1-\pi_{1})}\right\}\\  {} & -\frac{1}{2}\ln{\left|{\Sigma}_{\gamma}\right|}-\frac{1}{2}({\gamma}-{\mu}_{\gamma})^{t}{\Sigma}_{\gamma}^{-1}({\gamma}-{\mu}_{\gamma})\\  {} & -\frac{1}{2}\ln{\left|{\Sigma}_{\beta}\right|}-\frac{1}{2}({\beta}-{\mu}_{\beta})^{t}{\Sigma}_{\beta}^{-1}({\beta}-{\mu}_{\beta})\\  {} & -\frac{1}{2}\displaystyle{\sum_{i=1}^{2}\sum_{j=1}^{18}}\ln{(1-\zeta_{i}\xi_{j})}\\  {} & +\frac{1}{2}\displaystyle{\sum_{j,j^{\prime}}^{18}}(g_{1}^{2}+g_{2}^{2})u_{1,j}u_{1,j^{\prime}}{W}_{j,j^{\prime}}\\  {} & +\displaystyle{\sum_{j,j^{\prime}}^{18}}g_{2}g_{3}u_{1,j}u_{2,j^{\prime}}{W}_{j,j^{\prime}}\\  {} & +\frac{1}{2}\displaystyle{\sum_{j,j^{\prime}}^{18}}g_{3}^{2}u_{2,j}u_{2,j^{\prime}}{W}_{j,j^{\prime}}+2\ln{g_{3}}+\ln{g_{1}}\\  {} & -(\nu+3)\ln{(g_{1}g_{3})}-\frac{\nu}{20}\left(\frac{g_{1}^{2}+g_{2}^{2}+g_{3}^{2}}{g_{1}^{2}g_{3}^{2}}\right)+2\ln{g_{3}}\\  {} & -(\nu+3)\ln{(\Lambda_{1}\Lambda_{3})}-\frac{\nu}{20}\left(\frac{\Lambda_{1}^{2}+ \Lambda_{2}^{2}+ \Lambda_{3}^{2}}{\Lambda_{1}^{2} \Lambda_{3}^{2}}\right)+2\ln{\Lambda_{3}}\\  {} & +\ln{g_{1}}+\ln{\Lambda_{1}}.  \end{array},

(sexy, isn’t it?), or like this:

\begin{array}{rcl}  r:\left[\begin{array}{c} x_{r}(t) \\ y_{r}(t) \end{array}\right] & = & \left[\begin{array}{c} \frac{2}{3}(4\pi-t)\sin{(t)} \\ \frac{2}{3}(4\pi-t)\cos{(t)}\end{array}\right],\\f:\left[\begin{array}{c} x_{f}(t) \\ y_{f}(t) \end{array}\right] & = & \left[\begin{array}{c} (4\pi-t)\cos{(t)} \\ (4\pi-t)\sin{(t)}\end{array}\right].\end{array}

The former equation comes directly from my Ph.D. thesis, while the latter just happens to be part of a question involving parametric equations that I will be giving my students either on their next assignment, or the one after that1. They are going to love me so much :).

Now what makes \LaTeX so awesome is that it can produce equations as beautiful and sexy as these, but without the headache associated with conventional typesetting programs (um, can we say Microsoft Equation Editor – GAH).

Hmm, maybe ‘without the headache associated with conventional typesetting programs…‘ should be explained a bit. Personally, I find programs like Microsoft Equation Editor clunky and not altogether aesthetically pleasing. In fact, when forced to use them, I find that my patience wears thin very, very quickly. This is neither good for my blood pressure, nor for the computer which I overwhelmingly want to punch.   There are however headaches associated with \LaTeX; the learning curve can be a bit steep for those who have never dealt with a markup language; it’s not always the prettiest thing to view (and thus keep organized) prior to compiling; and then there are the typos and errors that will completely stop the compilation.  Searching through hundreds, even thousands of lines of code for a forgotten bracket or a missing environment tag can be, well, exhausting and infuriating.  Regardless, the trouble it takes to learn the program is well worth it, in my humble opinion, as the end results are beautiful.  For your viewing pleasure, I offer the first line of the equation from my Ph.D. that is listed above, prior to compilation (a.k.a., typesetting):

\begin{array}{ll}\ln{p({\Theta,\Pi,\Omega}|Y,Z,X)} & \propto & \displaystyle{\sum_{i,j,k=1}^{2,18,n}}\left\{z_{ijk}y_{ijk}(\gamma_{1}+\beta_{1}x_{ijk}+\Lambda_{1}u_{1j}+\Lambda_{2}u_{2j})\right.\\

The nice thing is that once you have it, \LaTeX becomes very powerful.  I tend to write all of my documents using \LaTeX now.

Anyway, if I had known that this functionality was available yesterday, I would have written the polar equations2 described in Mathy Valen-time’s Day as:

r =1-\sin{(\theta)},\\ \theta=0,\ldots, 2\pi,

instead of inserting the equations in the chump manner I did (i.e., producing the equations in \LaTeX, exporting them to jpeg format, then uploading them to WordPress – clearly the work of a chump).

Now that I am aware of this functionality, you should fully expect a higher concentration of mathematical and statistical nerdery here at Consumed By Wanderlust.  I know, I’m excited about it too!

A few final notes

\LaTeX is usually pronounced LAY-TEK, and not like LAY-TECKS.  As described by the great and all-knowing wiki:

“The characters T, E, X in the name come from capital Greek letters tauepsilon, and chi, as the name of TeX derives from the Greek: τέχνη (skill, art, technique).”

\LaTeX can be downloaded for free here for Windows users, and here for Mac users.

And now you know.


1 For those of you that might be curious, the question (in its current draft form) will read something like this:

Consider the following parametric equations r and f, where r represents the path of a rabbit and f represents the path of a very hungry fox. Assume these paths are traced at times t=0\ldots4\pi.

\begin{array}{rcl}  r:\left[\begin{array}{c} x_{r}(t) \\ y_{r}(t) \end{array}\right] & = & \left[\begin{array}{c} \frac{2}{3}(4\pi-t)\sin{(t)} \\ \frac{2}{3}(4\pi-t)\cos{(t)}\end{array}\right],\\f:\left[\begin{array}{c} x_{f}(t) \\ y_{f}(t) \end{array}\right] & = & \left[\begin{array}{c} (4\pi-t)\cos{(t)} \\ (4\pi-t)\sin{(t)}\end{array}\right],\end{array}

[i] Determine when the path travelled by the fox crosses the path travelled by the rabbit (i.e., not necessarily where the animals meet).

[ii] Determine if the animals ever meet? That is, should the rabbit fear for its life?

2 which use the polar coordinates r and \theta: r to represent the length of a line that has one end firmly planted at the origin (0,0), and \theta the angle measured between the line and the positive x-axis (where positive \theta are measured in a counter-clockwise manner from the axis).

Advertisements

5 Comments Add yours

  1. Rick says:

    Oh mother of pearl, this posting is nerdy to the core. I don’t remember how to use Latex at all :(. You almost convinced me to learn it again until I saw the first line of your Ph.D. That ain’t pretty. And the fox crosses the rabbit when you ugly! Zing!

  2. dangillis says:

    Zing indeed! I guess that just means the fox and the rabbit never cross. w00t!

  3. Rick says:

    Well played Gillis. Well played.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s