## Bringing Ustream and Justin.tv back to life

Tried to watch the Make: Live! webcast about the Arduino this evening, but was unable to view the video stream on my computer. All I got was a black screen. Tried viewing the webcast directly from the Ustream site, but still got nothing.

Marching through the standard troubleshooting steps, I removed all script blockers and ad-blockers, and shut down my software firewall. Still nothing.

To verify that I could still view video, I went to the TWiT Live page and confirmed that my computer handled the BitGravity stream without difficulty, but both the Ustream and Justin.tv streams failed to function properly. As a final check, I went to YouTube, where videos displayed without a problem. To see if this problem was limited to my preferred browser, I shut down Firefox and launched Internet Explorer. Same results. So something was acting on a system-wide basis.

After several rounds of searching on Google, I eventually stumbled upon the solution. It seems that you must tell the Flash browser plugin to permit third parties to store information on your system. I’m not happy about allowing Flash cookies, but if you don’t permit this, you won’t be watching Ustream or Justin.tv. I haven’t (intentionally) changed these settings in months (maybe years?), so I don’t know why I’m just now having problems. Anyhow, I thought I’d make this post just in case somebody else is experience the same difficulty.

If you are a Firefox user, you might want to install the Better Privacy add-on, just to simplify the process of removing Flash cookies, which are now going to be added to your system every time you view Ustream or Justin.tv videos. Be sure to “protect” the settings.sol folder in Better Privacy, or your settings will be forgotten every time you shut down Firefox.

[Update: After submitting this post, I went back and returned the Flash plugin settings to their original values. After deleting the other Flash cookies and restarting the browser, I had no problem viewing the Ustream and Justin.tv feeds on the TWiT page. Still don't know exactly what caused the problem, but allowing third-party data storage on a temporary basis seemed to clear the logjam.]

[Update 2: Nope, I had accidentally deleted the settings.sol folder cookie. Once I locked things down solidly, Justin.tv would no longer work. So ignore the prior update... you apparently must allow Flash cookies to watch certain webstreams.]

## Making Beamer Better

I use Beamer a lot for presentations, and I’ve gotten pretty good at the editing cycles that it requires. Unlike in PowerPoint, Beamer doesn’t allow me to simply click and drag an object to a new spot. Rather, to move something on the slide, I have to edit the LaTeX code, entering a command like \vskip0.2in to give me an additional bit of space between a couple of equations or text elements. It sometimes takes numerous iterations to get things right. This doesn’t both me, as I love being able to write entire presentations in LaTeX. What I want, however, is an ability to speed up the iterations.

If I could place the document preamble in one file, and the code for each slide in individual files, then it should be possible to create a script for compiling just one slide at a time. Then, I wouldn’t have to wait while Beamer compiled all 100+ slides in a presentation deck every time I make an edit. (Yes, that’s a lot of slides, but the count goes way up when I use multiple slides to reveal an equation one line at at time.) I can comment out code to limit compilation time, but it’s slow and cumbersome, and I once found myself in the middle of a presentation with missing slides because I forgot to uncomment about a third of my presentation file. So I want a supervisory program that will handle the individual code blocks, and allow me to compile the entire document when I’m finished.

If such a program exists, I’d sure like to know about it. If not, then maybe I’ll get around to writing it someday.

Posted in Research Tools | Tagged , , | 3 Responses

## When to introduce the matrix exponential?

In the study of linear systems, a familiar relationship is the homogeneous state-space equation $\dot{\mathbf{x}}(t) = A(t) \mathbf{x}(t)$, where $\mathbf{x}(t)$ is an $n$-vector, and $A$ is an $n \times n$ matrix. The time-invariant solution, (i.e., when $A$ is a constant matrix), is $\mathbf{x}(t) = e^{At} \mathbf{x}_0$. When this subject is first introduced, the solution is often assumed, rather than derived.

The thinking is that since the solution to the homogeneous scalar equation is $x(t) = e^{at} x(0)$, then students will willingly accept a matrix-friendly equivalent that solves the state-space differential equation. So the definition for the exponential matrix is given, and is shown to work for the homogeneous case:

\begin{aligned} \dot{\mathbf{x}}(t) & = \frac{d}{dt} \left( e^{At} \mathbf{x}_0 \right) \\ & = \frac{d}{dt} \left( e^{At} \right) \mathbf{x}_0 + e^{At} \frac{d}{dt} \left( \mathbf{x}_0 \right) \\ & = A e^{At} \mathbf{x}_0 + e^{At} \left( 0 \right) \\ & = A e^{At} \mathbf{x}_0 \\ & = A \mathbf{x}(t) \end{aligned}

It seems to me that this presentation sequence, however, masks what is really going on with the system; that there is an infinite recursion on the initial state, $\mathbf{x}_0$, that converges to a value for $\mathbf{x}(t)$:

\begin{aligned} \mathbf{x}(t) & = \mathbf{x}_0 + A \int_0^t \mathbf{x}(\tau)\, d\tau \\ & = \mathbf{x}_0 + A \int_0^t \left[ \mathbf{x}_0 + A \int_0^t\mathbf{x}(\tau)\, d\tau \right]\,d\tau \\ & = \mathbf{x}_0 + A \int_0^t \left[ \mathbf{x}_0 + A \int_0^t \left[ \mathbf{x}_0 + A \int_0^t\mathbf{x}(\tau)\, d\tau \right] d\tau \right]\,d\tau \end{aligned}

This recursion obviously repeats ad infinitum. However, the matrix exponential can now be defined by collecting terms on the right hand side, leading to:
\begin{aligned} \mathbf{x}(t) & = \left[ \mathbf{I}_n + At + \frac{1}{2!} \left( At \right)^2 + \dots \right] \mathbf{x}_0 \\ & = e^{At} \mathbf{x}_0 \end{aligned}

Presented in this order, the exponential matrix is developed based on system response, rather than the other way around. This strikes me as being easier to comprehend than “guessing” that some seemingly arbitrary function might solve the problem. Is this conceptually easier for anyone else?

Posted in Engineering Curriculum | | 2 Responses

## Getting Inkscape to play nicely with PSfrag

While browsing through some of the old TeXtip posts on Twitter, I was reminded of the possibility of using Inkscape to generate LaTeX-compatible illustrations. Given the vast amount of cruft that Illustrator includes in its EPS files, this sounded like it might be a good alternative.

However, Inkscape seems to be having some of the same problems as I was recently experiencing with Adobe Illustrator. Long story short, the only way I could find to make Inkscape play nicely with PSfrag was reverting to version 0.46. (The most recent Inkscape release is version 0.48.)

This problem is related to the use of the Cairo package from the GTK+ Project to export EPS files. Rather than store strings directly, references are made to a structure of characters actually used in the file. This is done to reduce file size, and improve performance. However, this is a real problem for those of us that use PSfrag. Specifically, string “abc” is no longer identified in the EPS file as (abc)Tj, but rather <01020304>Tj . This makes it impossible for PSfrag to find a matching string. There is some indication that a newer release of Cairo will fix this problem, but it hasn’t yet worked its way into the public release.

While some nice LaTeX-rending features are being introduced into the more recent releases of Inkscape, the benefit of PSfrag was nicely expressed by commenter emw on a Inkspace forum:

The reason for using psfrag is a kind of “coding style”, because I use a lot of complex symbols/equations defined by \newcommand statements in the latex document. For a consistent layout, I’d highly prefer to reuse these commands via psfrag in the figures.

I heartily concur.

## Getting Illustrator to play nicely with PSfrag

When creating diagrams for inclusion in a Beamer presentation, I used to use the drawing package in Open Office. Then I could use PSfrag to replace drawing text with text rendered in in $\LaTeX$. This made all the symbols in the presentation match symbols on the diagram. Alas, I am no longer able to make Open Office work with PSfrag. (My old trick of modifying the EPS “textmode” value in the OO configuration file no longer works.)

No problem, I thought. I’ll use Adobe Illustrator instead. However, I could only get this arrangement to work if the drawing text consisted of single letters. Not a huge problem, I suppose, as there are 52 possible identifiers just using upper and lower case letters in the English alphabet. However, it is sometimes a bit difficult to remember if $x_3$ is being represented by “p,” or “q,” or some other letter.

So here’s a solution to the problem, that I found on Giovanni Lanzani’s blog. When saving the EPS file in Illustrator, select “Illustrator 3 EPS” in the “version” pulldown. Don’t use “Illustrator CS3 EPS.” The newer versions write out the text one letter at a time, thus preventing the PSfrag routine from finding a matching string. Apparently the older EPS export routine doesn’t mangle the drawing text in this manner.

If your blog is hosted on WordPress.com, you can already render mathematical equations using LaTeX code (at least, that is my understanding). However, since I run WordPress on my own server, I would have to add a bit of software to produce similar results. A long time ago I tried using jsMath to generate math equations, but I tired of all the warning messages it produced if a user didn’t have the proper fonts installed. However, after seeing Robert Talbert mention MathJax on Twitter this morning, I decided to see if I could add it to this site. MathJax is apparently the successor to jsMath, and appears to be gaining some momentum in the mathematics community.

MathJax and WordPress have obviously been joined together before, as I quickly found the MathJax-LaTeX plugin for WordPress. While I could have installed MathJax on its own, I decided to install the plugin also, as it promised to inject MathJax javascript only on those pages that require it. Here is evidence (hopefully) that everything works: [mathjax] $$df(X_t)= \sum_{i=1}^d f_{,i}(X_t)\,dX^i_t + \frac{1}{2}\sum_{i,j=1}^d f_{,ij}(X_{t})\,d[X^i,X^j]_t$$

My knowledge of Linux is pretty limited, but I’ll share how I got my WP blog working. Be forewarned, however, that I likely won’t be able to answer questions about other installations; I’m barely capable of getting things working on my own system.

To begin, I used the WP plugin manager to add the MathJax-LaTeX plugin. I noted that it created a folder labeled mathjax-latex in my WP plugins directory, which I reference below. I next needed to install the MathJax files onto my WordPress server. My first approach was to download the files to my desktop, unzip them, and then FTP them back to my server. Bad idea! The MathJax folder is 16MB when compressed, much larger than that when uncompressed, and contains over 30,000 files! It would have taken hours to upload them via FTP.

So I launched Putty, logged into my webhost via SSH, and went to site-folder/wp-content/plugins/mathjax-latex/. From there, I issued the command wget http://sourceforge.net/projects/mathjax/files/MathJax/v1.0.1/MathJax-v1.0.1a.zip/download to download the MathJax files directly onto the server. Then, to unzip the downloaded file, I used the command unzip MathJax-v1.0.1a.zip. This put all the needed files into the directory .../plugins/mathjax-latex/MathJax, just as required by the MathJax-LaTeX plugin.

Next, to accommodate recent Firefox releases, it was necessary to download some updated font files. First, I went to directory .../MathJax/fonts/HTML-CSS/TeX and deleted the otf folder with rm -rf otf. Then I sucked down the new fonts with wget http://www.mathjax.org/dl/MathJax-Font-Update.zip, using unzip MathJax-Font-Update.zip to inflate the files. Unfortunately, this created an unwanted MathJax-Font-Update folder containing the needed otf subfolder. So I moved into the MathJax-Font-Update directory, then shoved the otf folder up a level with mv otf ../otf. Finally, I moved back up a level into the TeX directory, and removed what was left of the unneeded folder with rm -rf MathJax-Font-Update.

Lastly, I went back to the WP plugin page and activated the MathJax-LaTeX plugin. To put $\LaTeX$ code on a page, enclose your equation inside the tags $and$. So $e=mc^2$ produces $e=mc^2$. If you want to use dollar sign notation, simply include the tag [mathjax] somewhere on your page. Then $$e^{j\pi} = -1$$ generates $$e^{j\pi} = -1$$

When I first installed everything, Firefox would waste about 45 seconds trying to load web fonts, before rendering equations with image files. Reading through the MathJax documentation, this appeared to be a permission problem, and I created a suitable .htaccess file as suggested. However, the problem went away after I cleared the browser cache, and didn’t come back when I deleted the .htaccess file. So if you run into this problem, try clearing your browser cache first!

Posted in Mathematics | Tagged , , , | 6 Responses

## Mathematicians write like novelists

As I attempt to teach myself something about stochastic calculus, I have been reading a great many articles, and several textbooks, on the subject. It has left me with the distinct notion that mathematicians hate to spill the plot too early in the story. Each proof builds upon clues that have been scattered throughout the text, just as a writer might have the butler passing down a hallway in the second chapter for no apparent reason. Lemmas and sub-theorems that, to all outward appearances, are wholly unrelated to the general theme begin to appear. Then slowly, sometimes painfully, these logical manipulations are pulled together as the proof draws to a conclusion. But even so, the mathematician is reluctant to come out and say, “the butler did it.” Rather, phrases like “it is clearly obvious,” and “it is easily proven” are used to inform the reader that the point of mathematics is the mental challenge of figuring out how the pieces fit together.

There is no enjoyment in reading a novel that lays out the entire plot in the first paragraph. So a plot is simply a literary construct used by authors to evoke emotion, just as sculptors do with statues, and dancers with physical movement. Likewise, spelling out every mathematical truism and trick would make a proof lengthy and boring, with no pleasure left to be savored, right? So I think that mathematicians must write proofs (whether intentionally or not) in a manner intended to allow other mathematicians to sense the thrill of unraveling a logistic knot.

Sometimes I enjoy this artistry. Today I do not.

## Career, Teaming, and Entrepreneurial Methods

Well, now that the fall semester has started at Purdue, I’m going to make an effort to post more regularly. Of course, just one post a month would be more regular than my recent performance. Anyhow, today’s e-mail brought a brochure for a course (IE 590 & ChE 597) titled, “Career, Teaming & Entrepreneurial Methods for Engineers.” It promises to teach engineers how to:

• Be proactive in career development
• Develop interpresonal and professional communications skills
• Understand large technical project management
• Develop an awareness of the technical marketplace and the supply of technology
• Learn entrepreneurial methods

It sounds interesting. Why isn’t this type of class required for all engineering students?

I might be tempted to take it if I could afford more time away from my dissertation. However, I can’t graduate without defending, and I can’t defend without a dissertation. And it’s difficult to teach at a leading engineering school without a PhD. So more of my future blog entries may be more related to my research (and less devoted to engineering education in general). At least until I clear the hurdle of completing my final defense.

## The Marshmallow Challenge

Ever hear of the “Marshmallow Challenge?” Small teams of individuals are given the following assignment: use twenty sticks of uncooked spaghetti, one yard of masking tape, and one yard of string to construct the tallest possible free-standing structure that supports the weight of a marshmallow. Most people assume that since a marshmallow doesn’t weigh much, it shouldn’t significantly affect the support structure. Of course, even a small mass can produce structural failure when placed atop a long unsupported column.

So what profession does best at this task? According to Tom Wujec, a Fellow at software company Autodesk, the tallest structures are built by engineers and architects. They consistently outperform similar teams of lawyers, business school students, or corporate managers. This is not an unanticipated result, as we expect our engineers to know something about static structures. However, it is rather surprising to learn that youngsters, even kindergarten students, do far better than most adults—kids are simply not afraid to repeatedly fail as they search for an approach that works. (You may discover more about this learning exercise at MarshmallowChallenge.com).

Two insights come from this anecdotal report of group behavior. First, that engineers have been trained to think in a manner that is distinctly different from those in other professions. Second, that repeated rounds of prototyping and evaluation may be an effective means for dealing with the messy, unstructured, uncertain problems that engineers frequently encounter.

## Secret Tools of the Engineering Grad Student, Part 4: BibConverter

As you begin writing academic papers, you will need to cite the work of other researchers. From the prior two posts in this series, you know about using LaTeX to typeset your paper, and using JabRef to store your bibliographic references. However, typing in all the citation information by hand is rather tedious. Your ability to search the research literature is greatly enhanced if your academic institution provides you with access to databases of the engineering literature (Engineering Village, IEEE Xplore, Web of Science). All of these services allow you to export bibliographic data to a file on your computer, which you can then import into JabRef. However, there is a better way: BibConverter.

The brainchild of Kjell Magne Fauske, BibConverter is a free online service that converts a web page of information into a BibTex reference. While you are browsing through one of the article databases, you will likely find a paper you want to reference. Instead of downloading a citation file, simply copy the entire web page to your desktop, go to BibConverter, and paste the clipboard contents into the provided box. Click on the “Convert” button, and now you have a valid BibTex reference, that will look something like this:

@ARTICLE{Kalman1960,
title = {New approach to linear filtering and prediction problems},
author = {Kalman, R. E.},
year = {1960},
volume = {82},
number = {1},
pages = {35--45},
month = mar,
abstract = {Classical Wiener problem (filtering and prediction) is re-examined in
discrete case using author's new ("state transition") method of
analysis of dynamic systems; general solution is developed in
terms of conditional expectations; this gives result of
greatest possible generality when only first and second-order
statistical averages are used; basic concepts of theory of
random processes reviewed.},
}

Copy this data to the clipboard, and go to JabRef. Create a new BibTex entry with “Ctrl+N”, select the “Article” entry type, and then replace the “BibTex Source” entry with your clipboard contents. Once you’ve done this once or twice, it will seem quite natural, and it saves you the time and mess of having to clean up all the citation files that will start to litter your system. You can even download a bookmarklet from the BibConverter site to save you the trouble of surfing to the BibConverter site and selecting the proper database format. This service has saved me hours of time over the past several years.

[Note: IEEE Xplore recently changed it's online format, and it looks like BibConverter is currently unable to process data from that service.]