Live data from Hacker News

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

matt.might.net

11–20 of 95 posts

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

#11
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…

Agreed, i'm not sure whether one letter (immutable) greek variables are better than proper named variables.

Another consideration: A formal rule based math syntax could be checked by a computer (theorem prover).

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

#12
> Explicit sequences tend to be wrapped in angle-brackets, so that:

s = (Please note that in LaTeX, one should use \langle and \rangle for angle brackets--not less than and greater than.)

The article is pretty good overall, but I find this an little odd. I don't think I've ever seen sequences denoted with angle brackets. You usually see those used for denoting an inner product. I've only ever seen sequences denoted with parentheses, like (a_n) = (a_1, a_2, ..., a_n).

It's kind of humorous to me that we can sort of fingerprint the textbooks/lecturers people learned from by the idiosyncrasies of their notation.

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

#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 a couple. Sure you can write it in Julia, but I don't think the article is about creating math output in the Latexify.jl example, but how to code these math structures where certain languages can express them out of the box in an easier manner.

[1] https://www.jsoftware.com/books/pdf/

[2] https://www.amazon.com/Haskell-Logic-Programming-Second-Comp...

[3] https://mitpress.mit.edu/sites/default/files/titles/content/...

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

#14
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…

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?

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

#15
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…

I tried something along these lines based on the computer algebra system SymPy [1,2]. The syntax is Python so feels a little weird for doing math, but the SymPy function names match very closely to the math verbs like solve, expand, simplify, factor, which is very good for learning.

For example, factoring a polynomial can be done by calling the `factor` function:

   >>> factor(x**2 - 5*x + 6, x)
   (x-3)*(x-2)
see https://live.sympy.org/?evaluate=factor(x**2%20-%205*x%20%2B...

Suddenly all the boring and fear-inducing math operations are available to you after a few simple calculations in a REPL! That's a huge win if you ask me ;)

______

[1] Printable math+SymPy tutorial https://minireference.com/static/tutorials/sympy_tutorial.pd... [2] Notebook version of [1] https://nbviewer.jupyter.org/github/minireference/SymPyTut/b...

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

#16
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…

That sounds like something that could be done using a Jupyter Notebook and SageMath.

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

#17
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 those two worlds are reconcilable, and mergeable, with worlds of structured and 'just-in-time' teaching.

I am going to also, claim, that style of presentation of mathematics is more appropriate for formulating vision, structure, strategy, architecture in formal technical/financial 'contracts'.

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.

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

#18
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…

Agreed, i'm not sure whether one letter (immutable) greek variables are better than proper named variables. Another consideration: A formal rule based math syntax could be checked by a computer (theorem prover).

Where widely understood, I consider a Greek variable to be vastly superior. The problem is how well it's understood. Delta is an example of a succinct variable which has a well defined meaning which to encapsulate in a named variable either requires a long name or leaving out some nuance (delta isn't 'change' which is ambiguous in English, but the difference between two measurable things.)

Keep in mind we use special single letter variables all the time, sometimes multiple for the same concept. Multiply, divide, add, subtract. You learned them all in early education along with everyone else, and now you have a universal set of symbols to express arithmetic concepts.

Would we be better off if every occurrence of '+' was replaced with 'sum'? I don't think so, but that doesn't necessarily mean that loading up with single letter variables that people aren't familiar with is better. It's entirely to do with how familiar the target audience is with them. A library targeted for use by scientists might see benefit to more of them, while one targeted towards being accissible to many people might not.

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

#19
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…

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?

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

#20
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…

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?

[deleted]
Post reply on HN