Sometimes we’re disappointed with a simple solution because, although we don’t realize it yet, we didn’t properly frame the problem it solves.

I’ve been in numerous conversations where someone says effectively, “I understand that 2+3 = 5, but what if we made it 5.1?” They really want an answer of 5.1, or maybe larger, for reasons they can’t articulate. They formulated a problem whose solution is to add 2 and 3, but that formulation left out something they care about. In this situation, the easy response to say is “No, 2+3 = 5. There’s nothing we can do about that.” The more difficult response is to find out why “5” is an unsatisfactory result.

Sometimes we’re uncomfortable with a simple solution even though it does solve the right problem.

If you work hard and come up with a simple solution, it may look like you didn’t put in much effort. And if someone else comes up with the simple solution, you may look foolish.

Sometimes simplicity is disturbing. Maybe it has implications we have to get used to.

**Update**: A couple people have replied via Twitter saying that we resist simplicity because it’s boring. I think beneath that is that we’re not ready to move on to a new problem.

When you’re invested in a problem, it can be hard to see it solved. If the solution is complicated, you can keep working for a simpler solution. But once someone finds a really simple solution, it’s hard to justify continuing work in that direction.

A simple solution is not something to dwell on but to build on. We want some things to be boringly simple so we can do exciting things with them. But it’s hard to shift from producer to consumer: Now that I’ve produced this simple solution, and still a little sad that it’s wrapped up, how can I use it to solve something else?

**Related posts**:

The holes are all rectangular, so it’s surprising that the geometry is so varied when you slice open a Menger sponge. For example, when you cut it on the diagonal, you can see stars! (I wrote about this here.)

I mentioned this blog post to a friend at Go 3D Now, a company that does 3D scanning and animation, and he created the video below. The video starts out by taking you through the sponge, then at about the half way part the sponge splits apart.

]]>Harmonic numbers are sort of a discrete analog of logarithms since

As *n* goes to infinity, the difference between *H _{n}* and log

How would you compute *H _{n}*? For small

Since in the limit *H _{n}* – log

But we could do much better by adding a couple terms to the approximation above. [2] That is,

The error in the approximation above is between 0 and 1/120*n*^{4}.

So if you used this to compute the 1000th harmonic number, the error would be less than one part in 120,000,000,000,000. Said another way, for *n* = 1000 the approximation differs from the exact value in the 15th significant digit, approximately the resolution of floating point numbers (i.e. IEEE 754 double precision).

And the formula is even more accurate for larger *n*. If we wanted to compute the millionth harmonic number, the error in our approximation would be somewhere around the 26th decimal place.

* * *

[1] See Julian Havil’s excellent Gamma: Exploring Euler’s Constant. It’s popular-level book, but more sophisticated than most such books.

[2] There’s a sequence of increasingly accurate approximations that keep adding reciprocals of even powers of *n, *based on truncating an asymptotic series. See Concrete Mathematics for details.

- Math diagrams
- Numerical computing
- Probability and approximations
- Differential equations
- Python
- Regular expressions
- C++
- Special functions
- Typesetting: TeX, HTML, Unicode
- Emacs
- R
- Miscellaneous math

You can find an index of all these notes here.

Some of the most popular notes:

- Diagram of probability distribution relationships
- Stand-alone code for numerical computing
- R for programmers

And here is some more relatively hidden content:

- How to subscribe by RSS or email
- Online calculators
- Journal articles and presentations

The study of the planet Mercury provides two examples of the bandwagon effect. In her new book Worlds Fantastic, Worlds Familiar, planetary astronomer Bonnie Buratti writes

The study of Mercury … illustrates one of the most confounding bugaboos of the scientific method: the bandwagon effect. Scientists are only human, and they impose their own prejudices and foregone conclusions on their experiments.

Around 1800, Johann Schroeter determined that Mercury had a rotational period of 24 hours. This view held for eight decades.

In the 1880’s, Giovanni Schiaparelli determined that Mercury was tidally locked, making one rotation on its axis for every orbits around the sun. This view also held for eight decades.

In 1965, radar measurements of Mercury showed that Mercury completes 3 rotations in every 2 orbits around the sun.

Studying Mercury is difficult since it is only visible near the horizon and around sunrise and sunset, i.e. when the sun’s light interferes. And it is understandable that someone would confuse a 3:2 resonance with tidal locking. Still, for two periods of eight decades each, astronomers looked at Mercury and concluded what they expected.

The difficulty of seeing Mercury objectively was compounded by two incorrect but satisfying metaphors. First that Mercury was like Earth, rotating every 24 hours, then that Mercury was like the moon, orbiting the sun the same way the moon orbits Earth.

Buratti mentions the famous Millikan oil drop experiment as another example of the bandwagon effect.

… Millikan’s value for the electron’s charge was slightly in error—he had used a wrong value for the viscosity of air. But future experimenters all seemed to get Millikan’s number. Having done the experiment myself I can see that they just picked those values that agreed with previous results.

Buratti explains that Millikan’s experiment is hard to do and “it is impossible to successfully do it without abandoning most data.” This is what I like to call acceptance-rejection modeling.

Acceptance-rejection modeling: Throw out data that don’t fit with your model, and what’s left will.

— Data Science Fact (@DataSciFact) July 2, 2015

The name comes from the acceptance-rejection method of random number generation. For example, the obvious way to generate truncated normal random values is to generate (unrestricted) normal random values and simply throw out the ones that lie outside the interval we’d like to truncate to. This is inefficient if we’re truncating to a small interval, but it always works. We’re conforming our samples to a pre-determined distribution, which is OK when we do it intentionally. The problem comes when we do it unintentionally.

Photo of Mercury above via NASA

]]>The previous post said that for almost all *x* > 1, the fractional parts of the powers of *x* are uniformly distributed. Although this is true for almost all *x*, it can be hard to establish for any particular *x*. The previous post ended with the question of whether the fractional parts of the powers of 3/2 are uniformly distributed.

First, lets just plot the sequence (3/2)^{n} mod 1.

Looks kinda random. But is it uniformly distributed? One way to tell would be to look at the empirical cumulative distribution function (ECDF) and see how it compares to a uniform cumulative distribution function. This is what a quantile-quantile plot does. In our case we’re looking to see whether something has a uniform distribution, but you could use a q-q plot for any distribution. It may be most often used to test normality by looking at whether the ECDF looks like a normal CDF.

If a sequence is uniformly distributed, we would expect 10% of the values to be less than 0.1. We would expect 20% of the values to be less than 0.2. Etc. In other words, we’d expect the *quantiles* to line up with their theoretical values, hence the name “quantile-quantile” plot. On the horizontal axis we plot uniform values between 0 and 1. On the vertical axis we plot the sorted values of (3/2)^{n} mod 1.

A qq-plot indicates a good fit when values line up near the diagonal, as they do here.

For contrast, let’s look at a qq-plot for the powers of the plastic constant mod 1.

Here we get something very far from the diagonal line. The plot is flat on the left because many of the values are near 0, and it’s flat on the right because many values are near 1.

Incidentally, the Kolmogorov-Smirnov goodness of fit test is basically an attempt to quantify the impression you get from looking at a q-q plot. It’s based on a statistic that measures how far apart the empirical CDF and theoretical CDF are.

]]>First a theorem:

For almost all *x* > 1, the sequence (*x*^{n}) for *n* = 1, 2, 3, … is u.d. mod 1. [1]

Here “almost all” is a technical term meaning that the set of *x*‘s for which the statement above does not hold has Lebesgue measure zero. The abbreviation “u.d.” stands for “uniformly distributed.” A sequence uniformly distributed mod 1 if the fractional parts of the sequence are distributed like uniform random variables.

Even though the statement holds for almost all *x*, it’s hard to prove for particular values of *x*. And it’s easy to find particular values of *x* for which the theorem does not hold.

From [1]:

… it is interesting to note that one does not know whether sequences such as (

e^{n}), (π^{n}), or even ((3/2)^{n}) are u.d. mod 1 or not.

Obviously powers of integers are not u.d. mod 1 because their fractional parts are all 0. And we’ve shown before that powers of the golden ratio and powers of the plastic constant are near integers, i.e. their fractional parts cluster near 0 and 1.

The curious part about the quote above is that it’s not clear whether powers of 3/2 are uniformly distributed mod 1. I wouldn’t expect powers of any rational number to be u.d. mod 1. Either my intuition was wrong, or it’s right but hasn’t been proved, at least not when [1] was written.

The next post will look at powers of 3/2 mod 1 and whether they appear to be uniformly distributed.

* * *

[1] Kuipers and Niederreiter, Uniform Distribution of Sequences

]]>One of the case studies in Michael Beirut’s book How to is the graphic design for the planned community Celebration, Florida. The logo for the town’s golf course is an illustration of the bike shed principle.

C. Northcote Parkinson observed that it is easier for a committee to approve a nuclear power plant than a bicycle shed. Nuclear power plants are complex, and no one on a committee presumes to understand every detail. Committee members must rely on the judgment of others. But everyone understands bicycle sheds. Also, questions such as what color to paint the bike shed don’t have objective answers. And so bike sheds provoke long discussions.

People argue about bike sheds because they understand bike sheds. Beirut said something similar about the Celebration Golf Club logo which features a silhouette of a golfer.

Designing the graphics for Celebration’s public golf club was much harder than designing the town seal. It took me some time to realize why: none of our clients were Schwinn-riding, polytailed girls [as in the town seal], but most of them were enthusiastic golfers. The silhouette on the golf club design was refined endlessly as various executives demonstrated their swings in client meetings.

Image credit: By Source, Fair use, https://en.wikipedia.org/w/index.php?curid=37643922

]]>The so-called plastic constant *P* is another Pisot number, in fact the smallest Pisot number. *P* is the real root of *x*^{3} – *x* – 1 = 0.

Because *P* is a Pisot number, we know that its powers will be close to integers, just like powers of the golden ratio, but the *way* they approach integers is more interesting. The convergence is slower and less regular.

We will the first few powers of *P*, first looking at the distance to the nearest integer on a linear scale, then looking at the absolute value of the distance on a logarithmic scale.

As a reminder, here’s what the corresponding plots looked like for the golden ratio.

]]>Here’s a diagram that shows the basic kinds of rings and the relations between them. (I’m only looking at commutative rings, and I assume ever ring has a multiplicative identity.)

The solid lines are unconditional implications. The dashed line is a conditional implication.

- Every field is a Euclidean domain.
- Every Euclidean domain is a principal ideal domain (PID).
- Every principal ideal domain is a unique factorization domain (UFD).
- Every unique factorization domain is an integral domain.
- A
**finite**integral domain is a field.

Incidentally, the diagram has a sort of embedded pun: the implications form a circle, i.e. a ring.

More mathematical diagrams:

]]>In his paper Mindless statistics, Gerd Gigerenzer uses a Freudian analogy to describe the mental conflict researchers experience over statistical hypothesis testing. He says that the “statistical ritual” of NHST (null hypothesis significance testing) “is a form of conflict resolution, like compulsive hand washing.”

In Gigerenzer’s analogy, the **id** represents Bayesian analysis. Deep down, a researcher wants to know the probabilities of hypotheses being true. This is something that Bayesian statistics makes possible, but more conventional frequentist statistics does not.

The **ego** represents R. A. Fisher’s significance testing: specify a null hypothesis only, not an alternative, and report a *p*-value. Significance is calculated after collecting the data. This makes it easy to publish papers. The researcher never clearly states his hypothesis, and yet takes credit for having established it after rejecting the null. This leads to feelings of guilt and shame.

The **superego** represents the Neyman-Pearson version of hypothesis testing: pre-specified alternative hypotheses, power and sample size calculations, etc. Neyman and Pearson insist that hypothesis testing is about what to *do*, not what to *believe*. [1]

* * *

I assume Gigerenzer doesn’t take this analogy too seriously. In context, it’s a humorous interlude in his polemic against rote statistical ritual.

But there really is a conflict in hypothesis testing. Researchers naturally think in Bayesian terms, and interpret frequentist results as if they were Bayesian. They really do want probabilities associated with hypotheses, and will imagine they have them even though frequentist theory explicitly forbids this. The rest of the analogy, comparing the ego and superego to Fisher and Neyman-Pearson respectively, seems weaker to me. But I suppose you could imagine Neyman and Pearson playing the role of your conscience, making you feel guilty about the pragmatic but unprincipled use of *p*-values.

* * *

[1] “No test based upon a theory of probability can by itself provide any valuable evidence of the truth or falsehood of a hypothesis. But we may look at the purpose of tests from another viewpoint. Without hoping to know whether each separate hypothesis is true or false, we may search for rules to govern behaviour in regard to them, in following which we insure that, in the long run of experience, we shall not often be wrong.”

Neyman J, Pearson E. On the problem of the most efficient tests of statistical hypotheses. *Philos Trans Roy Soc A*, 1933;231:289, 337.

This morning I was reading Terry Tao’s overview of the work of Yves Meyer and ran across this line:

The powers φ, φ

^{2}, φ^{3}, … of the golden ratio lie unexpectedly close to integers: for instance, φ^{11}= 199.005… is unusually close to 199.

I’d never heard that before, so I wrote a little code to see just how close golden powers are to integers.

Here’s a plot of the difference between φ^{n} and the nearest integer:

(Note that if you want to try this yourself, you need extended precision. Otherwise you’ll get strange numerical artifacts once φ^{n} is too large to represent exactly.)

By contrast, if we make the analogous plot replacing φ with π we see that the distance to the nearest integer looks like a uniform random variable:

The distance from powers of φ to the nearest integer decreases so fast that cannot see it in the graph for moderate sized *n*, which suggests we plot the difference on the log scale. (In fact we plot the log of the *absolute value* of the difference since the difference could be negative and the log undefined.) Here’s what we get:

After an initial rise, the curve is apparently a straight line on a log scale, i.e. the absolute distance to the nearest integer decreases almost exactly exponentially.

**Related posts**:

In a recent interview, Tyler Cowen discusses complacency, (neruo-)diversity, etc.

Let me give you a time machine and send you back to Vincent van Gogh, and you have some antidepressants to make him better. What actually would you do, should you do, could you do? We really don’t know. Maybe he would have had a much longer life and produced more wonderful paintings. But I worry about the answer to that question.

And I think in general, for all the talk about diversity, we’re grossly undervaluing actual human diversity and actual diversity of opinion. Ways in which people—they can be racial or ethnic but they don’t have to be at all—ways in which people are actually diverse, and obliterating them somewhat. This is my Toquevillian worry and I think we’ve engaged in the massive social experiment of a lot more anti-depressants and I think we don’t know what the consequences are. I’m not saying people shouldn’t do it. I’m not trying to offer any kind of advice or lecture.

I don’t share Cowen’s concern regarding antidepressants. I haven’t thought about it before. But I am concerned with how much we drug restless boys into submission. (Girls too, of course, but it’s usually boys.)

]]>Two finite-dimensional vector spaces over the same field are isomorphic if and only if they have the same dimension.

For a finite dimensional space *V*, its dual space *V** is defined to be the vector space of linear functionals on *V*, that is, the set of linear functions from *V* to the underlying field. The space *V** has the same dimension as *V*, and so the two spaces are isomorphic. You can do the same thing again, taking the dual of the dual, to get *V***. This also has the same dimension, and so *V* is isomorphic to *V*** as well as *V**. However, *V* is **naturally** isomorphic to *V*** but not to *V**. That is, the transformation from *V* to *V** is **not** natural.

Some things in linear algebra are easier to see in infinite dimensions, i.e. in Banach spaces. Distinctions that seem pedantic in finite dimensions clearly matter in infinite dimensions.

The category of Banach spaces considers linear spaces and **continuous** linear transformations between them. In a finite dimensional Euclidean space, all linear transformations are continuous, but in infinite dimensions a linear transformation is not necessarily continuous.

The dual of a Banach space *V* is the space of **continuous** linear functions on *V*. Now we can see examples of where not only is *V** not naturally isomorphic to *V*, it’s not isomorphic at all.

For any real *p* > 1, let *q* be the number such that 1/*p* + 1/*q* = 1. The Banach space *L*^{p} is defined to be the set of (equivalence classes of) Lebesgue integrable functions *f* such that the integral of |*f*|^{p} is finite. The dual space of *L*^{p} is *L*^{q}. If *p* does not equal 2, then these two spaces are different. (If *p* does equal 2, then so does *q*; *L*^{2} is a Hilbert space and its dual is indeed the same space.)

In the finite dimensional case, a vector space *V* is isomorphic to its second dual *V***. In general, *V* can be embedded into *V***, but *V*** might be a larger space. The embedding of *V* in *V*** is natural, both in the intuitive sense and in the formal sense of natural transformations, discussed in the previous post. We can turn an element of *V* into a linear functional on linear functions on *V* as follows.

Let *v* be an element of *V* and let *f* be an element of *V**. The action of *v* on *f* is simply *fv*. That is, *v* acts on linear functions by letting them act on it!

This shows that *some* elements of *V*** come from evaluation at elements of *V*, but there could be more. Returning to the example of Lebesgue spaces above, the dual of *L*^{1} is *L*^{∞}, the space of essentially bounded functions. But the dual of *L*^{∞} is larger than *L*^{1}. That is, one way to construct a continuous linear functional on bounded functions is to multiply them by an absolutely integrable function and integrate. But there are other ways to construct linear functionals on *L*^{∞}.

A Banach space *V* is reflexive if the **natural** embedding of *V* in *V*** is an isomorphism. For *p* > 1, the spaces *L*^{p} are reflexive.

However, R. C. James proved the surprising result that there are Banach spaces that are isomorphic to their second duals, **but not naturally**. That is, there are spaces *V* where *V* is isomorphic to *V***, but not via the natural embedding; the natural embedding of *V* into *V*** is **not** an isomorphism.

**Related**: Applied functional analysis

A category is a collection of objects and arrows between objects. Usually these “arrows” are functions, but in general they don’t have to be.

A functor maps a category to another category. Since a category consists of objects and arrows, a functor maps objects to objects and arrows to arrows.

A natural transformation maps functors to functors. Sounds reasonable, but what does that mean?

You can think of a functor as a way to create a picture of one category inside another. Suppose you have some category and pick out two objects in that category, *A* and *B*, and suppose there is an arrow *f* between *A* and *B*. Then a functor *F* would take *A* and *B* and give you objects *FA* and *FB* in another category, and an arrow *Ff* between *FA* and *FB*. You could do the same with another functor *G*. So the objects *A* and *B* and the arrow between them in the first category have counterparts under the functors *F* and *G* in the new category as in the two diagrams below.

A natural transformation α between *F* and *G* is something that connects these two diagrams into one diagram that commutes.

The natural transformation α is a collection of arrows in the new category, one for every object in the original category. So we have an arrow α_{A} for the object *A* and another arrow α_{B} for the object *B*. These arrows are called the *components* of α at *A* and *B* respectively.

Note that the components of α depend on the objects *A* and *B* but not on the arrow *f*. If *f* represents any other arrow from *A* to *B* in the original category, the same arrows α_{A} and α_{B} fill in the diagram.

Natural transformations are meant to capture the idea that a transformation is “natural” in the sense of not depending on any arbitrary choices. If a transformation does depend on arbitrary choices, the arrows α_{A} and α_{B} would not be reusable but would have to change when *f* changes.

The next post will discuss the canonical examples of natural and unnatural transformations.

**Related**: Applied category theory

Eight short, accessible blog posts based on the work of the intriguing mathematician Srinivasa Ramanujan:

]]>Larry Wall, creator of the Perl programming language, created a custom degree plan in college, an interdisciplinary course of study in natural and artificial languages, i.e. linguistics and programming languages. Many of the features of Perl were designed as an attempt to apply natural language principles to the design of an artificial language.

I’ve been thinking of a different connection between natural and artificial languages, namely using natural language processing (NLP) to reverse engineer source code.

The source code of computer program is text, but not a text. That is, it consists of plain text files, but it’s not a text in the sense that Paradise Lost or an email is a text. The most efficient way to parse a programming language is as a programming language. Treating it as an English text will loose vital structure, and wrongly try to impose a foreign structure.

But what if you have *two* computer programs? That’s the problem I’ve been thinking about. I have code in two very different programming languages, and I’d like to know how functions in one code base relate to those in the other. The connections are not ones that a compiler could find. The connections are more psychological than algorithmic. I’d like to reverse engineer, for example, which function in language *A* a developer had in mind when he wrote a function in language *B*.

Both code bases are in programming language, but the function names are approximately natural language. If a pair of functions have the same name in both languages, and that name is not generic, then there’s a good chance they’re related. And if the names are similar, maybe they’re related.

I’ve done this sort of thing informally forever. I imagine most programmers do something like this from time to time. But only recently have I needed to do this on such a large scale that proceeding informally was not an option. I wrote a script to automate some of the work by looking for fuzzy matches between function names in both languages. This was far from perfect, but it reduced the amount of sleuthing necessary to line up the two sets of source code.

Around a year ago I had to infer which parts of an old Fortran program corresponded to different functions in a Python program. I also had to infer how some poorly written articles mapped to either set of source code. I did all this informally, but I wonder now whether NLP might have sped up my detective work.

Another situation where natural language processing could be helpful in software engineering is determining code authorship. Again this is something most programmers have probably done informally, saying things like “I bet Bill wrote this part of the code because it looks like his style” or “Looks like Pat left her fingerprints here.” This could be formalized using NLP techniques, and I imagine it has been. Just as Frederick Mosteller and colleagues did a statistical analysis of The Federalist Papers to determine who wrote which paper, I’m sure there have been similar analyses to try to find out who wrote what code, say for legal reasons.

Maybe this already has a name, but I like “unnatural language processing” for the application of natural language processing to unnatural (i.e. programming) languages. I’ve done a lot of ad hoc unnatural language processing, and I’m curious how much of it I could automate in the future.

]]>I wondered what a collage of these images would look like, so I used the ImageQuilts software by Edward Tufte and Adam Schwartz to create the image below.

**Related**: Applied complex analysis

Here’s a condensed view of the graph. You can find the full image here.

The graph is so dense that it’s hard to tell which areas have the most or least connections. Here are some tables to clarify that. First, counting how many areas an particular area contributes to, i.e. number of outgoing arrows.

|-------------------------------------+---------------| | Area | Contributions | |-------------------------------------+---------------| | Homological algebra | 12 | | Lie groups | 11 | | Algebraic and differential topology | 10 | | Categories and sheaves | 9 | | Commutative algebra | 9 | | Commutative harmonic analysis | 9 | | Algebraic geometry | 8 | | Differential geometry and manifolds | 8 | | Integration | 8 | | Partial differential equations | 8 | | General algebra | 7 | | Noncommutative harmonic analysis | 6 | | Ordinary differential equations | 6 | | Spectral theory of operators | 6 | | Analytic geometry | 5 | | Automorphic and modular forms | 5 | | Classical analysis | 5 | | Mathematical logic | 5 | | Abstract groups | 4 | | Ergodic theory | 4 | | Probability theory | 4 | | Topological vector spaces | 4 | | General topology | 3 | | Number theory | 3 | | Von Neumann algebras | 2 | | Set theory | 1 | |-------------------------------------+---------------|

Next, counting the sources each area draws on, i.e. counting incoming arrows.

|-------------------------------------+---------| | Area | Sources | |-------------------------------------+---------| | Algebraic geometry | 13 | | Number theory | 12 | | Lie groups | 11 | | Noncommutative harmonic analysis | 11 | | Algebraic and differential topology | 10 | | Analytic geometry | 10 | | Automorphic and modular forms | 10 | | Ordinary differential equations | 10 | | Ergodic theory | 9 | | Partial differential equations | 9 | | Abstract groups | 8 | | Differential geometry and manifolds | 8 | | Commutative algebra | 6 | | Commutative harmonic analysis | 6 | | Probability theory | 5 | | Categories and sheaves | 4 | | Homological algebra | 4 | | Spectral theory of operators | 4 | | Von Neumann algebras | 4 | | General algebra | 2 | | Mathematical logic | 1 | | Set theory | 1 | | Classical analysis | 0 | | General topology | 0 | | Integration | 0 | | Topological vector spaces | 0 | |-------------------------------------+---------|

Finally, connectedness, counting incoming and outgoing arrows.

|-------------------------------------+-------------| | Area | Connections | |-------------------------------------+-------------| | Lie groups | 22 | | Algebraic geometry | 21 | | Algebraic and differential topology | 20 | | Noncommutative harmonic analysis | 17 | | Partial differential equations | 17 | | Differential geometry and manifolds | 16 | | Homological algebra | 16 | | Ordinary differential equations | 16 | | Analytic geometry | 15 | | Automorphic and modular forms | 15 | | Commutative algebra | 15 | | Commutative harmonic analysis | 15 | | Number theory | 15 | | Categories and sheaves | 13 | | Ergodic theory | 13 | | Abstract groups | 12 | | General algebra | 10 | | Spectral theory of operators | 10 | | Probability theory | 9 | | Integration | 8 | | Mathematical logic | 6 | | Von Neumann algebras | 6 | | Classical analysis | 5 | | Topological vector spaces | 4 | | General topology | 3 | | Set theory | 2 | |-------------------------------------+-------------|

There are some real quirks here. The most foundational areas get short shrift. Set theory contributes to only one area of math?! Topological vector spaces don’t depend on anything, not even topology?!

I suspect Dieudonné had in mind fairly high-level contributions. Topological vector spaces, for example, obviously depend on topology, but not deeply. You could do research in the area while seldom drawing on more than an introductory topology course. Elementary logic and set theory are used everywhere, but most mathematicians have no need for advanced logic or set theory.

More math diagrams:

]]>Analytic number theory uses the tools of analysis, especially complex analysis, to prove theorems about integers. The first time you see this it’s quite a surprise. But then you might expect that since analysis contributes to number theory, then number theory must contribute to analysis. But it doesn’t much.

Topology imports ideas from algebra. But it exports more than in imports, to algebra and to other areas. Topology started as a generalization of geometry. Along the way it developed ideas that extend far beyond geometry. For example, computer science, which ostensibly has nothing to do with whether you can continuously deform one shape into another, uses ideas from category theory that were developed initially for topology.

Here’s how Jean Dieudonné saw things. The following are my reconstructions of a couple diagrams from his book Panorama of Pure Mathematics, as seen by N. Bourbaki. An arrow from A to B means that A contributes to B, or B uses A.

For number theory, some of Dieudonné’s arrows go both ways, some only go into number theory. No arrows go only outward from number theory.

With topology, however, there’s a net flux out arrows going outward.

These diagrams are highly subjective. There’s plenty of room for disagreement. Dieudonné wrote his book 35 years ago, so you might argue that they were accurate at the time but need to be updated. In any case, the diagrams are interesting.

**Update**: See the next post of a larger diagram, sewing together little diagrams like the ones above.

Those days are dead and gone and the eulogy was delivered by Perl.

The other was a line from James Hague:

… if you romanticize Unix, if you view it as a thing of perfection, then you lose your ability to imagine better alternatives and become blind to potentially dramatic shifts in thinking.

This brings up something I’ve long wondered about: What did the Unix shell get right that has made it so hard to improve on? It has some truly awful quirks, and yet people keep coming back to it. Alternatives that seem more rational don’t work so well in practice. Maybe it’s just inertia, but I don’t think so. There are other technologies from the 1970’s that had inertia behind them but have been replaced. The Unix shell got something so right that it makes it worth tolerating the flaws. Maybe some of the flaws aren’t even flaws but features that serve some purpose that isn’t obvious.

(By the way, when I say “the Unix shell” I have in mind similar environments as well, such as the Windows command line.)

On a related note, I’ve wondered why programming languages and shells work so differently. We want different things from a programming language and from a shell or REPL. Attempts to bring a programming language and shell closer together sound great, but they inevitably run into obstacles. At some point, we have different expectations of languages and shells and don’t want the two to be too similar.

Anthony Scopatz and I discussed this in an interview a while back in the context of xonsh, “a Python-powered, cross-platform, Unix-gazing shell language and command prompt.” While writing this post I went back to reread Anthony’s comments and appreciate them more now than I did then.

Maybe the Unix shell is near a local optimum. It’s hard to make much improvement without making big changes. As Anthony said, “you quickly end up where many traditional computer science people are not willing to go.”

**Related post**: What’s your backplane?

It’s a very crude technique in general; you can get much more accuracy with the same number of function evaluations by using a more sophisticated method. But for smooth periodic functions, the trapezoid rule works astonishingly well.

This post will look at two similar functions. The trapezoid rule will be very accurate for one but not for the other. The first function is

*g*(*x*) = exp( cos(*x*) ).

The second function, *h*(*x*) replaces the cosine with its Taylor approximation 1 – *x*^{2}/2. That is,

*h*(*x*) = exp(1 – *x*^{2}/2 ).

The graph below shows both functions.

Both functions are perfectly smooth. The function *g* is naturally periodic with period 2π. The function *h* could be modified to be a periodic function with the same period since *h*(-π) = *h*(π).

But the periodic extension of *h* is not smooth. It’s continuous, but it has a kink at odd multiples of π. The derivative is not continuous at these points. Here’s a close-up to show the kink.

Now suppose we want to integrate both functions from -π to π. Over that range both functions are smooth. But the behavior of *h* “off stage” effects the efficiency of the trapezoid rule. Making *h* periodic by pasting copies together that don’t match up smoothly does not make it act like a smooth periodic function as far as integration is concerned.

Here’s the error in the numerical integration using 2, 3, 4, …, 10 integration points.

The integration error for both functions decreases rapidly as we go from 2 to 5 integration points. And in fact the integration error for *h* is slightly less than that for *g* with 5 integration points. But the convergence for *h* practically stops at that point compared to *g* where the integration error decreases exponentially. Using only 10 integration points, the error has dropped to approximately 7×10^{-8} while the error for *h* is five orders of magnitude larger.

**Related**: Numerical integration consulting

First, *r* is typically a function of θ, just as *y* is typically a function of *x*. But in rectangular coordinates, the independent variable is the first element of a pair while in polar coordinates it is the second element.

Second, if you’re going to walk a mile northwest, how do you proceed? You first face northwest, then you walk for a mile. You don’t walk a mile to the east and then walk 135° counterclockwise along an arc centered where you started. That is, you set your θ first, then increase your *r*.

The (*r*, θ) convention isn’t going to change. Maybe the only take-away from this discussion is to appreciate someone’s confusion who sees polar coordinates for the first time and wants to reverse their order.

**Related post**: Why use *j* for imaginary unit

(I don’t use *j* for imaginary unit, except when writing Python code. The *i* notation is too firmly engraved in my brain. But I understand why *j* has advantages.)

Here’s a close-up of the graph from a photo of my copy of A&S.

This was my reply.

It looks like a complex function of a complex variable. I assume the height is the magnitude and the markings on the graph are the phase. That would make it an elliptic function because it’s periodic in two directions.

It has one pole and one zero in each period. I think elliptic functions are determined, up to a constant, by their periods, zeros, and poles, so it should be possible to identify the function.

In fact, I expect it’s the Weierstrass *p* function. More properly, the Weierstrass ℘ function, sometimes called Weierstass’ elliptic function. (Some readers will have a font installed that will properly render ℘ and some not. More on the symbol ℘ here.)

**Related posts**:

Fourier series arise naturally when working in rectangular coordinates. Bessel series arise naturally when working in polar coordinates.

The Fourier series for a constant is trivial. You can think of a constant as a cosine with frequency zero.

The Bessel series for a constant is not as simple, but more interesting. Here we have

Since

we can write the series above more symmetrically as

**Related posts**:

It is supposed to be computationally impractical to create two documents that have the same secure hash code, and yet Google has demonstrated that they have done just that for the SHA1 algorithm.

I’d like to make two simple observations to put this in perspective.

**This is not a surprise**. Cryptography experts have suspected since 2005 that SHA1 was vulnerable and recommended using other algorithms. The security community has been gleeful about Google’s announcement. They feel vindicated for telling people for years not to use SHA1

**This took a lot of work**, both in terms of research and computing. Crypto researchers have been trying to break SHA1 for 22 years. And according to their announcement, these are the resources Google had to use to break SHA1:

- Nine quintillion (9,223,372,036,854,775,808) SHA1 computations in total
- 6,500 years of CPU computation to complete the attack first phase
- 110 years of GPU computation to complete the second phase

While SHA1 is no longer recommended, it’s hardly a failure. I don’t imagine it would take 22 years of research and millions of CPU hours to break into my car.

**I’m not saying people should use SHA1**. Just a few weeks ago I advised a client not to use SHA1. Why not use a better algorithm (or at least what is currently widely believed to be a better algorithm) like SHA3? But I am saying it’s easy to exaggerate what it means to say SHA1 has failed.

]]>

Even though he saw no value in the books he was assigned, he bought and saved every one of them. Then sometime near the end of college he began to read and enjoy the books he hadn’t touched.

I wanted to read their works now, all of them, and so I began. After I graduated, after Ellen and I moved together to New York, I piled the books I had bought in college in a little forest of stacks around my tattered wing chair. And I read them. Slowly, because I read slowly, but every day, for hours, in great chunks. I pledged to myself I would never again pretend to have read a book I hadn’t or fake my way through a literary conversation or make learned reference on the page to something I didn’t really know. I made reading part of my daily discipline, part of my workday, no matter what. Sometimes, when I had to put in long hours to make a living, it was a real slog. …

It took me twenty years. In twenty years, I cleared those stacks of books away. I read every book I had bought in college, cover to cover. I read many of the other books by the authors of those books and many of the books those authors read and many of the books by the authors of those books too.

There came a day when I was in my early forties … when it occurred to me that I had done what I set out to do. …

Against all odds, I had managed to get an education.

]]>

What I’ve done: Math prof, programmer, statistician

What I do now: Consulting

— John D. Cook (@JohnDCook) February 21, 2017

(The formatting is a little off above. It’s leaving out a couple line breaks at the end that were in the original tweet.)

That’s not a bad summary. I’ve worked in applied math, software development, and statistics. Now I consult in those areas.

Next, I did the same for Frank Sinatra.

Frank Sinatra #microresume:

Experience: puppet, pauper, pirate, poet, pawn, king, up, down, over, out

— John D. Cook (@JohnDCook) February 21, 2017

This one’s kinda obscure. It’s a reference to the title cut from his album That’s Life.

]]>I’ve been a puppet, a pauper, a pirate

A poet, a pawn and a king.

I’ve been up and down and over and out

And I know one thing.

Each time I find myself flat on my face

I pick myself up and get back in the race.