Live data from Hacker News

Translating math into code with examples in Java, Racket, Haskell, Python (2011)

matt.might.net

21–30 of 95 posts

Re: Translating math into code with examples in Java, Racket, Haskell, Python (2011)

#21
post #4

I dream of material that would explain some advanced (for a regular person understanding of the word) math concepts using Python. Maybe it's because I've programmed more in my life than did math, but the "language" we use to write it is absolutely crazy: one letter variables everywhere, no structure, thousands of custom notations etc. I'm not criticising it, I realise it exists this way for a reason and if I wasn't s…

Most of the structuring (and, therefore, syntax) around an 'enterprise' application, is about how easy it is to 'replace'/'change' functions based on future needs (or known, but yet un-realized requirements). In mathematics, the driver for notation is: how succinctly can I express, what I want to express in this particular effort, yet allowing others to verify my work without mis-interpretation. I am not sure if thos…

> As I progress (perhaps, already at a sunset) of my career, I can see that lack of fluency in mathematics (both algebra and analysis) is a major impediment for transition into more highly compensated (and impactful) , yet, still technical roles for many of us, out there.

Do you have an example off the top of your head? I'm assuming that by, "fluency in mathematics (both algebra and analysis)", you mean something beyond basic calculus and linear algebra.

My experience has been that software engineers at the staff, principal and architect levels don't really need to know advanced mathematics at all. From what I've seen they usually have a breadth of experience as generalists and a depth of experience in one or two particular specializations, which may or may not involve any advanced mathematics at all.

Re: Translating math into code with examples in Java, Racket, Haskell, Python (2011)

#22
post #13

Julia is notably missing. Packages like this one are dope https://github.com/korsbo/Latexify.jl Or this https://github.com/qojulia/QuantumOptics.jl Or this https://www.juliahomotopycontinuation.org/

I like Julia for all of the libraries, the Lisp underneath, however, from the article: "Many of the encodings are as immutable, purely functional data structures (even in imperative languages), a topic unfortunately omitted from many computer science curricula." Julia and similar PLs don't express math like APL, J[1], Haskell[2], Scheme[3] or even Clojure can with immutable structures and function composition to name…

Idk why apl or haskell would be any better.

Re: Translating math into code with examples in Java, Racket, Haskell, Python (2011)

#23
post #19

Earlier quoted context omitted.

you will take single letter variables from my cold, dead, hands! I'm more used to math than to code, and I find multiple-letter variables ridiculous when not unreadable. In the ancient times, mathematicians used to write formulas using latin sentences. Even the simplest arithmetic result occupied a few lines of text. Are you proposing that we go back to that age?

" Even the simplest arithmetic result occupied a few lines of text. Are you proposing that we go back to that age? " What if students learned "Force = mass * acceleration", and only later moved to "F = ma" once they'd gotten tired of writing it, instead of smacking students in the face with "F = ma" right out of the gate, to say nothing of all the other stuff we smack them with right away?

That's precisely how I learned that formula. In fact that's basically the pedagogy that's been presented to me for almost all the mathematics I've learned.

Sets? Define a set semantically, then replace "set" with S. Vector spaces? Define a vector space semantically, then replace "vector space" with V. Limits? Define a limit semantically, then replace the word with "lim".

Moreover mathematicians typically use jargon in a more reader-friendly way than simply throwing obtuse equations at them. Expressions, equations, inequalities and identities are complements to the proof, not the proofs themselves. Best practice holds that you present a theorem in plain language alongside the necessary notation, then break its proof down into as many atomic units (lemmas, propositions, corollaries, etc) as possible. Here is a blog post[1] from Terence Tao giving general advice for why that's useful. Tao has written a bunch[2] of these on the theme of emphasizing exposition and clarity.

Also contrary to popular belief, well-written mathematics papers actually have quite a lot of exposition in them. For a famous example, look at Yitang Zhang's proof[3] that there are infinitely many primes with 70 million numbers (or fewer) in between them. He spends a full five pages on introduction, background results used to develop the proof, and (most importantly) notation. He also includes a "sketch" of the proof in broad strokes so that a reader can follow his arguments at both a high level and in gritty detail.

That doesn't mean papers like Zhang's are accessible to most people. The jargon is still there and you can't really change that unless you want papers to become self-contained monographs. But the point is that what you're proposing - concepts defined in a straightforward way before moving on to dense notation - is already the general practice.

__________________________________

1. https://terrytao.wordpress.com/advice-on-writing-papers/crea...

2. https://terrytao.wordpress.com/advice-on-writing-papers/

3. http://annals.math.princeton.edu/2014/179-3/p07

Re: Translating math into code with examples in Java, Racket, Haskell, Python (2011)

#24
post #19

Earlier quoted context omitted.

you will take single letter variables from my cold, dead, hands! I'm more used to math than to code, and I find multiple-letter variables ridiculous when not unreadable. In the ancient times, mathematicians used to write formulas using latin sentences. Even the simplest arithmetic result occupied a few lines of text. Are you proposing that we go back to that age?

" Even the simplest arithmetic result occupied a few lines of text. Are you proposing that we go back to that age? " What if students learned "Force = mass * acceleration", and only later moved to "F = ma" once they'd gotten tired of writing it, instead of smacking students in the face with "F = ma" right out of the gate, to say nothing of all the other stuff we smack them with right away?

but even "force = mass * acceleration" uses those sneaky single-letter symbols that are not even letters! In appropriate, user friendly notation it would be "force equals mass multiplied by acceleration".

But this is not clear enough. What force? What acceleration? More precisely, what is the direction of the acceleration? The original statement of this law is less ambiguous: "Mutationem motus proportionalem esse vi motrici impressae, et fieri secundum lineam rectam qua vis illa imprimitur. "

Or, in plain english: "The alteration of motion is ever proportional to the motive force impress'd; and is made in the direction of the right line in which that force is impress'd"

There! we are good to go. Now write the fundamental theorem of calculus in english, readable by everybody, without those ugly, unreadable variables and fancy symbols...

Re: Translating math into code with examples in Java, Racket, Haskell, Python (2011)

#26
post #4

I dream of material that would explain some advanced (for a regular person understanding of the word) math concepts using Python. Maybe it's because I've programmed more in my life than did math, but the "language" we use to write it is absolutely crazy: one letter variables everywhere, no structure, thousands of custom notations etc. I'm not criticising it, I realise it exists this way for a reason and if I wasn't s…

At 31 years you are quite young still. Some of my peers studying maths are around your age or older than that.

Don't be afraid to dive into maths if you feel like it.

Anecdotally people >25 do better than younger people. Maturity appears to be an asset sometimes.

Yes, young people might think and learn slightly quicker, but older people tend to be less easily distracted and more focused on the task at hand.

Maths is not a race though, so I believe age is an advantage at the end of day.

Re: Translating math into code with examples in Java, Racket, Haskell, Python (2011)

#27
post #19

Earlier quoted context omitted.

you will take single letter variables from my cold, dead, hands! I'm more used to math than to code, and I find multiple-letter variables ridiculous when not unreadable. In the ancient times, mathematicians used to write formulas using latin sentences. Even the simplest arithmetic result occupied a few lines of text. Are you proposing that we go back to that age?

" Even the simplest arithmetic result occupied a few lines of text. Are you proposing that we go back to that age? " What if students learned "Force = mass * acceleration", and only later moved to "F = ma" once they'd gotten tired of writing it, instead of smacking students in the face with "F = ma" right out of the gate, to say nothing of all the other stuff we smack them with right away?

Seems like this would be sensible, the multiplication symbol is one any student learning this should already be familiar with. To generalize, keep using well-learned symbols so things don't get out of hand in verbosity and slowly introducing new ones seems logical. I know when I was in school there were certain math and physics classes where I kept having to ask myself what a symbol meant that was introduced 5 minutes ago so writing it out fully would have been helpful often.

Re: Translating math into code with examples in Java, Racket, Haskell, Python (2011)

#28
> Mathematics is a purely functional language.

It is not. E.g. x ∈ ℕ ∧ x > 2 ∧ x This is just one of the many mathy myths that plague the FP community. Yes, there are some similarities between FP and mathematical notation, but FP and imperative are much closer to one another than either is to mathematics.

Re: Translating math into code with examples in Java, Racket, Haskell, Python (2011)

#29
Not sure what the point of translating math into code is. Just because we represent something with code doesn't mean it is computable. It's also technically incorrect to say math is translated into code. The mathematical symbols are being swapped with codey things, but the underlying semantics are quite different. For example, we might say the symbol 'oo' is infinity, but infinity itself is something that cannot be embedded in a finite program. So, we might be coerce a parser to realize that 1/oo=0 with a background ruleset, but the identity itself was derived by our minds accessing the mathematical world of forms that is completely inaccessible to finite computational mechanisms.

It seems like this effort is going to increase a lot of overhead to do math, and obscures the role of thinking through the math conceptually. There seems to be a Principia Mathematica 2.0 idea in the programming world that we just need to reduce mathematics to code and it'll become easily accessible and usable. I'm not convinced that will be the case.

Re: Translating math into code with examples in Java, Racket, Haskell, Python (2011)

#30
post #13

Earlier quoted context omitted.

I like Julia for all of the libraries, the Lisp underneath, however, from the article: "Many of the encodings are as immutable, purely functional data structures (even in imperative languages), a topic unfortunately omitted from many computer science curricula." Julia and similar PLs don't express math like APL, J[1], Haskell[2], Scheme[3] or even Clojure can with immutable structures and function composition to name…

Idk why apl or haskell would be any better.

I'm not as opinionated on Haskell, but APL is both a programming language AND executable math notation. It's just the notation is different than what most are already used to.
Post reply on HN