Intro

Math is beautiful because theoretical math — which is created without any applications in mind — ends up being a necessity for the formulation of theories in physics [1] and, in some cases, theoretical math leads to a scientific discovery in physics. How is this possible? Why is this the case? As Einstein pointed out, the universe has mathematical structure; it is as if the behavior of the universe is constrained by this mathematical structure; furthermore, math is beautiful because there exists a relationship between math and programming which inexorably leads one to ask questions such as “Is the Haskell programming language discovered or invented?”

Correspondence between physics and math

Eugene Wigner, a theoretical physicist and Nobel prize recipient observed in [1] that pure/theoretical mathematics often ends up becoming a necessity in the formulation of theories in physics. I find this quite remarkable and find it amazing and beautiful. Mathematics is tremendously more than the mathematics you learn before university. A mathematical world is waiting to be discovered — mathematical objects are part of the objective world we perceive. There exists mathematical objects such that an association exists with knowable unknowns in Physics. As Eugene Wigner pointed out in [1] it is amazing that there’s an objective world and even more amazing there are minds capable of grasping it:

It is difficult to avoid the impression that a miracle confronts us here, quite comparable in its striking nature to the miracle that the human mind can string a thousand arguments together without getting itself into contradictions, or to the the two miracles of the existence of laws of nature and of the human mind’s capacity to divine them.

For example, the theory of General Relativity. If you want to talk precisely about the theory of General Relativity you need certain mathematical notions: you need the notion of a topological set, the notion of a manifold. Why are theories such as General Relativity expressed in mathematical notions that were developed without practical applications in mind? It seems that the universe and the abstract world of mathematics are meshed together; that is, you can’t talk about one without talking about the other. And I am not talking about the importance of mathematical calculation in physics; instead, I am talking about, how it seems as if these mathematical objects such as manifolds exist as part of the objective universe, giving the universe flow; for example, again I will mention the theory of General Relativity. The theory of General Relativity dictates that as soon as you place planets and other astronomical objects in spacetime, spacetime curves and, in turn, the curvature of spacetime provides the flow of the astronomical objects. Spacetime is a four dimensional manifold which is a topological set with additional information which in turn is a set. That is, since differential geometry forms the basis for Einstein’s gravity theory then it is the geometry of the universe which gives the flow of the universe. Without the realm of mathematics, the universe as we know it may not exist. In addition to the theory of General Relativity, complex numbers are also mysterious; for example, complex numbers were invented (or discovered?) by mathematicians to solve quadratic equations — they wanted quadratic equations to have roots. If we wish, for example, for \({x^2} + 1 = 0\) to have roots we need to introduce the symbols \(i\) and \(- i\). Then explain to me why complex numbers ended up becoming a necessity for the formulation of quantum theory? Without complex numbers you cannot formulate quantum physics; moreover, the discovery of quarks was a mathematical discovery [2]. I marvel at the fact that mathematical theorems and reasoning led to a discovery in Physics — how could pure mathematical theorems have done this?

Correspondence between math and programming

In addition to the mysterious and beautiful relationship between physics and pure mathematics, programming and mathematics also forms a deep and beautiful relationship. Propositions as Types dictates a correspondence between a given logic and a given programming language [3]. The relationship between logic and programming entails the following: propositions as types; that is for each proposition in the given logic there is a corresponding type in the given programming language; moreover, the correspondence also entails: proofs as programs; that is, for each proof of a proposition there is a correspondence to a program for a given type. Finally, Propositions as Types entails simplifications of proofs as evaluation of programs; that is, if there exists a way to simplify a proof then there exists a way to evaluate the corresponding program. This correspondence of logic — i.e., natural deduction — and programming — i.e., the lambda calculus — is the ground for functional programming. As it is with the physics and mathematics correspondence the relationship between logic and programming raises profound questions as Philip Wadler writes in [3]:

Propositions as Types is a notion of mystery. Why should it be the case that intuitionistic natural deduction, as developed by Gentzen in the 1930s and simply-typed lambda calculus, as developed by Church around the same time for an unrelated purpose, should be discovered 30 years later to be essentially identical…Those of us that design and use programming languages may often feel they are arbitrary, but Propositions as Types assure us some aspects of programming are absolute.

Relationship between math and programming from a less deeper perspective

Consider \(\sum_{i=1}^n\).

The sigma notation \(\sum\) is an abstraction that mathematicans figured out to talk about sums abstractly without worrying about particular sums. This notation expresses the concept of summation. Similarly, in programming you can express the same abstraction using a higher-order procedure. Consider this procedure in Scheme:

(define (sum-integers i n)
   (sum (lambda (x) x)
        i
        (lambda (s) (+ s 1))
        n))

(define (sum term i next n)
   (if (> i n)
       0
       (+ (term i)
          (sum term (next i) next n))))

By writing this higher-order procedure you can think at a higher level of abstraction; that is, instead of writing procedures of particular sums you can apply the same summation pattern to multiple sums.

In this way, math and programming are related.

References

[1] Eugene Wigner, The Unreasonable Effectiveness of Mathematics in the Physical Sciences

[2] Edward Frenkel, Love and Math

[3] Philip Wadler, Propositions as Types