Author Archives: Peter Krautzberger

MathJax best practices: avoid display:none

At MathJax we often get questions about specific examples of content / web design. Most of the time, people will show up on the MathJax User Group (the preferred choice), StackOverflow (semi-officially supported), and through our contact form on mathjax.org (not the right choice but sometimes necessary for restricted users who can’t post to either of the above).

Almost always, the problems are easy to track down (e.g., the infamous 15s delay if a custom configuration/extension/etc has an incorrect loadComplete call), sometimes they are bugs (e.g., the recent Chrome/WebKit webfont loading bug), but of course every so often they hit on the subtleties that make what MathJax does so hard (ex/em matching, webfont detection etc.).

A surprising recent example for the latter revolves around the use of display:none. It usually comes up in reports of broken layout but the other day there was an interesting performance issue. To understand the second, it helps to understand the first.

The layout trouble with display:none

The rendering issues sometimes seen for content which starts off with CSS display:none and later made visible stem from a simple problem: browser engines won’t actually layout elements with display:none. MathJax on the other hand, needs to take a few vital measurements (basically widths and heights) to produce a correct layout — and these measurements are not available when the content wasn’t laid out by the browser.

To work around this predicament, we could just leave it to the author to work as if content with display:none was dynamically loaded content — and force them to trigger a manual typeset when the content is revealed. But that’s silly because the content is there, we should damn well use it.

So to work around display:none, MathJax does something quite simple: it moves the content into an invisible element that does get laid out — using visibility:hidden with zero dimensions. Then MathJax can take the measurements, produce good rendering and put the rendered output back to the original location.

Now there’s an obvious problem with that approach: where would you move the content to do the rendering? After all, just because something is display:none doesn’t mean it has no context. It might be in a completely different CSS context (think: hints to a homework problem, sidebar content, menus), or the context might change once it becomes visible (think: popup footnotes/references, knowls). In other words, MathJax output in some other context might get screwed up when put back into the original context (e.g., matching font sizes correctly, dealing with inherited CSS). Of course, more often than not, this will work well but it is a general problem and should be avoided.

(Another way might be to use mutation observers. Besides supported being limited, I think there’s an argument to be made that layout should happen right away if possible. But it should probably become an option via an extension.)

a surprising performance issue

Recently, we saw a sample where all this magic had a very different side effect: serious performance issues. In that sample, hundreds of equations were hidden away with display:none. This meant that MathJax had to shift those around in the DOM — and especially mobile browsers did not like that at all. What made matters worse was that the MathJax status messages gave no useful indication of what was going on, instead hanging at unrelated points — because MathJax currently doesn’t have a signal to catch a delay for such a “simple” action like laying out display:none. In the end, the sample (with 2000+ equations) left the user with the impression that their mobile browsers were hanging/crashing — just because of all these necessary layout shenanigans! Darn!

the moral

The moral of the story is: use visibility:hidden, e.g., position: absolute; top: 0, left:0; width:0, height:0, overflow: hidden; visibility: hidden;), or tell MathJax to skip the content and manually queue a typesetting call when you reveal hidden content. If you want to put in some extra work, use visibility:hidden, let MathJax skip the hidden content and then queue a typesetting call for the hidden content after MathJax is loaded; that way the hidden content will be typeset only after the visible content is done (on MathJax’s initial pass).

Any which way, don’t get caught in bad layout or performance issues related to display:none!

Carnival of Mathematics 111

The math blogosphere is a friendly and relaxed placed. But there is one rule, I believe, we should all abide by: when The Aperiodical calls, you answer.

And so I’m honored to join the un-secret society of Carnival of Mathematics hosts. Indeed, the list of former and future hosts over at The Aperiodical (who took over the organizational stress two years ago, stepping into the tremendously large footsteps of Mike Croucher of Walking Randomly), this list reads like a who-is-who of true math bloggers (the kind that cares for blogging as a community and art form). If you’re not on it, do yourself a favor and volunteer right now. I’ll wait. Honestly, I will. This post will still be here when you get back; I promise.

Step closer, dear friend. Excitement awaits!

In the time-honored tradition, let us remember that 111 has many marvellous properties. However, if I were forced to name a favorite, I could not decide between the fact that the smallest magic square containing 1 and otherwise prime numbers, has a magical constant of 111, as well as the simple beauty of being a palindromic number.

  • When you enter our attractions, you are almost unnaturally drawn to an oldie-but-goldie, an attraction worth a visit every time the carnival is in town: John Baez’s Beauty of Roots. As with Vincent Pantaloni (@panlepan) put it: “The best math I stumbled upon this month is this visualisation of polynonmial roots”.

  • Then stop by Antonio Sanchez Chinchon since he shares with us his mnemoneitoR, to translate numbers into easy-to-remember phrases inspired by books to generate funny mnemonic rules.

  • But don’t stop there, wonders await as AP Goucher gives us the elliptic curve calculator, a fixed page paper slide rule using elliptic curves.

  • And while you take a break, make sure to sit down and listen in on Alexandre Borovik’s Math under the Microscope pointing us to this New York Times article on a simple one-time exercise that might prevent community college students from dropping out of math classes.

  • But throw yourself back into the crowds of the carnival because when Colin Beveridge (of Flying Colours Math) was asked why he loves math, he wrote a short and sweet post to make his answer public. As luck will have it, a student asked Stephen Cavadino of cavmaths the very same, and so we can enjoy another answer that might inspire future students to grow their own and personal passion for mathematics.

  • By now you’re hungry and rightfully so. However, if you ever wondered where to place a hot dog stand, and how to adapt when the best customer moves into a motorhome, then fear not — David Orden at Mapping Ignorance will fill your stomach with a great post, taking you from Sylvester’s original question back in 1857 all the way to today’s cutting edge research.

  • With a full belly, let’s head over to the Aperiodical, where Paul Taylor tackled the mind-bending and subtle hidden maths of the Eurovision song contest while Katie Steckles provides us with a recap of Matt Parker’s appearance on the BBC’s consumer moanfest, Watchdog, where Matt helped everyone get their percentages right.

  • And while you leave, why not trust him when the Aperiodical’s Christian Perfect points you in the direction of Nick Berry’s excellent blog DataGenetics, with a post that will introduce you to the wonders of Amidakuji, bringing together braid theory and a very old arcade game.

  • Then go on and follow Katie Steckle to visit Goading the IT geek‘s post on the deceivingly simple problem of calculating averages.

  • And if you find yourself in a part of the Carnival you have already visited, why not take a chance and run into Stephen Cavadino’s posts on mathematics on children’s playgrounds and small puzzle on the number 71?

  • Back on the main road through the carnival, you’ll see in the far end Alex’s adventures in numberland, where Alex Bellos has learned from Joseph Mazur how surprisingly new mathematical notation is.

  • And if you like to gamble, dear friend, worry not. The BBC’s Janet Ball can tell you a story that might encourage you, how the (in)famous MIT blackjack team won enormous amounts of money tackling the odds with their mathematical prowess.

  • Behold, the Mechanical Turk is nothing against our next mind-bending adventure as Andrea Hawksley takes you on a dive into Non-Euclidean Chess!

  • After his shocker, cool down a little and enjoy the talented Shecky Riemann sharing with us his interview with passionate math-ed blogger Fawn Nguyen.

  • Nest step into the ghost house at Google+, where Richard Green took everyone on a journey from simply squaring prime numbers to monsters and moonshine and some of the most complex and arduous mathematics of the 20th century.

  • In our version of the house of mirros, behold: Nim and Fractals — what could go better together? The amazing Tany Khovanova provides us with the background on her latest paper with one of her high school students in MIT’s PRIMES project

  • But you obviously cannot get enough! Well, then, we dare you to follow The Aperiodical’s Peter Rowlett into the long, long list of podcasts for university math students. Only the bravest have listened to them all!

  • As immortal challenges go, Chris Burke of (x,why?) celebrates overcoming one: the 30 posts in 30 days blogging challenge with a fine post on the struggle students face with piecewise functions.

  • For the craziest ride of this carnival, be sure to stop by Matifutbol where, just in time for the start of the World Cup 2014 in Brazil, Herminio’s post on trees and googols at the World Cup will take you on a wild trip to all possible competitions, the Wedderburn-Etherington number and the very edge of the known universe, making you appreciate how simple life will be over the next 4 weeks.

  • If this is too wild, get your dose of World Cup math blogging at Matt Scroggs‘s who will tell you how many Panini packages you really need to buy to complete that Panini book you’ve been hiding under your bed all these years.

  • The strongest man in the world cannot resist the powers of set theoretical forcing. And Asaf Karagila will make sure you won’t wrongly use the analogy of field extensions to explain forcing.

  • And as you leave this Carnival behind, excited, exhausted, and content, you might still turn back for that one last ride, that one last attraction. So head over to Patrick Honner / Mr Honner as he takes on the The Grant Wiggins Conceptual Understanding Challenge, allowing us, through his response, a peek into that insightful brain of his.

And so the Carnival comes to an end and we move on. As we must. Always.

Just when I thought I was out

I recently pondered whether I should stop reading the few remaining mathoverflow and math.stackexchange feeds I keep in my feed reader (remember that archaic technology? I still use it heavily). Ever since I left research, I had dialed down the number of tags I was following on those wonderful sites, both because it was painful and because I lost interest (as contradictory as that may sound); in the end, all I kept were the [ultrafilter] tag on MO and the [set theory] tag on math.SE.

But I found myself brushing past even those few postings, so that yesterday I thought it was time to move on and remove them from my feed reader, de fact closing the “math” section of my feed reader, where all my research related feeds ended up. And then just as I am about to, I see this question and answer which, while neither spectacular or particular, reminded me why I once fell in love with set theory.

So, Asaf, I will call you Joey Zasa from now on.

HEAR YE, HEAR YE! The Carnival of Math is in town

Gee, it’s been quiet around here! Between MathJax release work and diaper wrangling, blogging has been neglected. Inconceivable?

INCONCEIVABLE!

The kind overlords of the math blogosphere to whom we are all but humble servants, yes, the one true and ever-so-periodical team at The Aperiodical have called upon yours truly to host a carnival. Not any carnival, but a blogging carnival of math.

So I invite to step into our tiny realm of mathblogging and help me host a grand show for all the world to see.

Bring me your posts, your rants, your poems.

Share idle idiosyncrasies, deranged derivations, cool calculations, and rash remarks.

Give it your best and your worst and your all. For the Carnival of Math is here and all creatures are welcome on its arena’s floor.

Red workbook, p15

Source

red workbook, p15-1

red workbook, p15-2

Transcript

Left page

  • Forcing moeglich?
  • Fuer strongly summable? kaputtmachen???????
  • Bem (* [[circled]]) [[boxed]]

Right page

  • [4.] Eine “elementare” Charakterisierung von “zentral”
  • 4.1 Def. $A\subseteq S$ Setze
    • (a) $T_A = \{ (a_o, \ldots, a_{n-1} ) \in S^{< \omega} : FP(a_i)_{i=0}^{n-1} \subseteq A \}$
    • $T_A$ Teilbaum von $S^{< \omega}$.
    • Notiz:
      • $A$ IP <=> $T_A$ hat unendlichen Zweig
      • tatsaechlich bei konstruktion von IP-Menge zeigt man,
      • dass es sehr viele unendliche Zweige gibt
      • SK: sogar perfekter Baum
    • (b) Fuer $R \subseteq S^{<\omega}$ Teilbaum, $r \in R$ setze
      • $N_r := N_r^R := \{ a \in S : r^a \in R \} (\subseteq S)$ [[a diagram: the tree $R$ and the set of successors $N_r$]]
  • 4.2 Satz [14.25 in HS]
    • Fuer $A\subseteq S$ aequivalent: (a) $A$ zentral
      • (b) $\exists R \subseteq T(A)$ Teilbaum mit (2) $\{ N_r^R: r \in R\}$ cwpws
        • (1) $r\in R, a \in N_r \Rightarrow a\cdot N_{r \hat{} a} \subseteq N_r$
      • Solches $R$ heisst $\star$-tree [in HS].

partial Translation

Left page

  • Forcing possible?
  • For strongly summable? destroying???????

Right page

  • [4.] An “elementary” Characterization of “central”
  • 4.1 Definition. For $A\subseteq S$ define:
    • (a) $T_A = \{ (a_o, \ldots, a_{n-1} ) \in S^{< \omega} : FP(a_i)_{i=0}^{n-1} \subseteq A \}$
    • $T_A$ subtree of $S^{< \omega}$.
    • Note:
      • $A$ IP <=> $T_A$ includes an infinite branch
      • in fact, in the construction of IP-set one shows that there are many infinite branches
      • Sabine Koppelberg: in fact, a perfect subtree.
    • (b) For $R \subseteq S^{<\omega}$ subtree, $r \in R$ define
      • $N_r := N_r^R := \{ a \in S : r^a \in R \} (\subseteq S)$ [[the successor set]]
  • 4.2 Theorem [14.25 in HS]
    • For $A\subseteq S$ TFAE:
      • (a) $A$ central
      • (b) $\exists R \subseteq T(A)$ subtree with
        • (2) $\{ N_r^R: r \in R\}$ cwpws (collectionwise piecewise syndetic)
        • (1) $r\in R, a \in N_r \Rightarrow a\cdot N_{r \hat{} a} \subseteq N_r$
      • Such $R$ is called $\star$-tree [in HS].

Notes

We’re getting to some serious results here. The “tree characterization” of centrality is, I think, not known (or not appreciated) widely enough. It might be a lot to wrap your mind around as a student but this might be one of the better ways of providing some insights into the notion of cwpws sets.

This page is very amusing. The random note on destroying strongly summable ultrafilters is what occupied a large part of my postdoctoral research. Apparently it took me a while to realize this is an interesting question. Come to think of it, Francois and I also spent quite a bit of time on the tree characterization; makes me want to skip ahead to a postdoc notebook…