9 ms·
Legible Mathematics: Sketches of interactive arithmetic for programming (2014)
- jxy 7y agoI guess it is useful if you are teaching kindergarteners. For high schoolers we write for(i=0;i<N;++i){ for(j=0;j<N;++j){ force = G*mass1[i]*mass2[j]/radius(i,j)^2 // do something with the force } }
- Papirola 7y agoThe post is from 2014. I wonder what progress was made since.
- atomoton 7y agoPython3 Allows you to put underscores in numbers for legibility: a = 100_000 b = 1_000_000
- Someone 7y agoThat started at least with Ada, in 1979 (https://softwareengineering.stackexchange.com/a/403959 https://softwareengineering.stackexchange.com/a/403959). Traditional FORTRAN ignores all spaces, so one can write a million as 1 000 000 there, C++14 allows apostrophes (https://en.wikipedia.org/wiki/Decimal_separator#Data_versus_mask https://en.wikipedia.org/wiki/Decimal_separator#Data_versus_...)
- NikkiA 7y agoWell, I'd hope he fixed the 10^11 to 10^-11 in the excel sheet, but given he hasn't updated the page to reflect that, I'm not hopeful. Although, perhaps it's deliberate as a canary test for those that intend to defend non-traditional mathematical notation in programming.
- diffeomorphism 7y agoSo the only take-away I get is that the author does not like to use brackets and really likes writing fractions. Unfortunately, this does work very badly for long fractions, iterated fractions or, well, anything more complicated than toy examples. This pops up from time to time with latex and how a/b should give you a fraction instead of having to write \frac{a}{b}. Problem is, this makes one easy case marginally shorter, but something like \frac{a+b}{c+\frac{d}{3}} much harder.
- andrepd 7y ago{a+b}/{c+d/3} Still looks much better
- diffeomorphism 7y agoHm, reading that it is not immediately obvious whether you mean (c+d)/3 or c + (d)/3. At that point I think it should be straightforward to implement {}/{} as syntactic sugar for \frac{}{}. Mathematics notation is basically completely determined by consensus and people come up with new notation all the time whenever they need it. In particular, in order to convince someone that your notation is better you have to show previously how hard stuff becomes easy and not how easy stuff becomes even easier.
- abdullahkhalids 7y agoTeX already has the primitive of {}\over{} that does what you are saying. It is not typically used. https://tex.stackexchange.com/questions/73822/what-is-the-difference-between-over-and-frac https://tex.stackexchange.com/questions/73822/what-is-the-di...
- petschge 7y agoA big downside of that proposal is that everything takes up much more space, which makes it much harder to keep track of what else is going on. In toy problems it is fine, but in real problems having the answer to "did the code already check for i == j" visible at the same is really important. Let alone context such as "is this the reference implementation for single core validation or the vectorized function" or "is the radius at timestep n or n+1/2".
- jedieaston 7y agoThis looks a heck of a lot like Desmos without the graph. (https://desmos.com/calculator https://desmos.com/calculator)
- ivanbakel 7y agoMy thought as well - it's jarring at first to get used to, but Desmos' way of typing in equations, where keypresses really act more like operations on the equation than raw text input, gives a natural easy way to write good equations. At the very least, typing / automatically makes a fraction with separate top and bottom input areas - which means that brackets for numerator and denominator aren't necessary.
- mkl 7y agoDesmos's input is done with an open source library called MathQuill: https://github.com/mathquill/mathquill https://github.com/mathquill/mathquill
- xixixao 7y agoThe mathematical notation has developed over centuries to __think about and solve problems on paper__. Besides it being taught in schools and hence familiar, I think it’s not at all a good tool to use in the significantly different digital medium. Another reason is that the notation is mostly a tool for __oneself__ to think in, but is fairly bad at communicating (think about the level of expertise required to read a math paper vs reading someone’s code). Here’s a concrete difference to support these claims. Using math notation we often write large expressions which include many meaningful subexpressions and complex operations. In code we prefer to use lots of names (variables) and simple expressions.
- Grustaf 7y agoReading math is hard because math is hard. The notation is incredibly powerful, intuitive and flexible. In all my years hanging around mathematicians I’ve never heard anyone complain about notation. After all, you are always free to use your own notation if you want, and if others like it they will follow.
- munificent 7y ago> In all my years hanging around mathematicians I’ve never heard anyone complain about notation. There's likely to be some survivorship bias at play here.
- Grustaf 7y agoNo, since anyone is free to invent and use whatever notation they prefer. That’s how mathematical notation has evolved so far. People come up with new notation all the time.
- eru 7y agoThough when you are writing a paper, it's useful to pick standard notation. But yeah, when working something mathematical out for the first time, picking / making up the right notation is crucial.
- maire 7y agoI would like a computer system that can do algebraic reductions. This is the only thing that forced me to go back to pen and paper. This looks like it does substitutions but I didn't see reductions.
- petschge 7y agoSuch things exists under the name "Computer Algebra Systems". Notable commercial offerings include Mathematica and Maple, but there is also free software such as Sage and Sympy.
- jfarmer 7y agoThis sort of thing is called a Computer Algebra System (CAS) and there are good free ones. https://www.sagemath.org/ https://www.sagemath.org/ http://maxima.sourceforge.net/ http://maxima.sourceforge.net/ https://www.sympy.org/en/index.html https://www.sympy.org/en/index.html
- mb7733 7y agoHow hard have you looked? You'd be hard pressed to find a computer alebgra system (CAS) that doesn't support algebraic reduction. It's been available for decades at this point. Popular systems offering this can do this include Mathematica, Maple and Sage. Even MATLAB had extensions for symbolic manipulation now.
- alanbernstein 7y agoIt's probably not a good solution for most people, but here's what I do: I have a TI-89 emulator on my android phone. I used one of those calculators for about six years in high school and college, and I'll never lose the muscle memory of the interface. (I also still own the device, which justifies using the emulator ethically, if not strictly legally.) I believe it's actually faster for me than, say, sympy, which I also use in other contexts. Also faster than using pencil and paper, for sufficiently large problems. If you're not familiar, it uses a CAS called derive which handles algebraic simplification (including trigonometry), differentiation and integration. Oh, and a function called "rref" (reduced row echelon form; familiar to matlab users), which solves a linear system (including symbolically), with absolutely minimal overhead in the "CLI". Now that I say that, I want an actual CLI tool called rref that works in the same way.
- taliesinb 7y agoI always enjoy seeing new attempts at visualizing and explaining function composition. Here’s something I played around with a few years ago that tried to visualize function composition: https://taliesin.ai/posts/function-trees/ https://taliesin.ai/posts/function-trees/
- andrewla 7y agoThis dovetails to some degree with thoughts that I've been having about language and expression design. Associativity and operator precedence are ideas that made sense as a shorthand in written mathematics (and have deep roots in the structure of arithmetic) but don't actually add a lot of value in programming languages, except to put a huge mental burden on developers to unpack the precedence. My thought is just to remove precedence and associativity entirely -- instead of "a + b + c/2" you have to make it explicit -- "a + (b + (c/2))". The only problem that I see is that there are two ways of writing this, you could also write "(a + b) + (c/2)". In my experience, though, especially in programming (though not always in financial programming), there are almost always semantics associated with those intermediate values which makes one of the two groupings preferable. Taking numeric constants and adding internal separators makes a lot of sense as well (both before and after the decimal point). Ideally this would be enforced at some arbitrary cultural level, (e.g. using the US-standard groupings of three with comma), and would be required -- "2000" is invalid and "20,00" is invalid (so python3's approach of allowing arbitrary _'s in numbers is not really great, because it doesn't protect against typos). The right-of-the-decimal-point separators are not really common, but it would be nice to take advantage of this to make a sensible arbitrary enforced designation, like using "," to the left and "_" to the right, once again mandatory and required to support groupings of three. Would probably also be desirable to have a convention for hexadecimal numbers and other supported bases -- in particular binary is not supported by many languages, but is very natural for most programming languages, if we had a way of using delimiters -- 0b0100_0000 is more readable and meaningful than 0x40, but 0b0010_0100_0011_0010_0000_0010_0010 is not so good (quick, how many bytes did I just type?).
- simongray 7y ago> My thought is just to remove precedence and associativity entirely -- instead of "a + b + c/2" you have to make it explicit -- "a + (b + (c/2))". The only problem that I see is that there are two ways of writing this, you could also write "(a + b) + (c/2)". Or how about... (+ a b (/ c 2))
- c3534l 7y agoStill a bunch of pointless parens. Obviously a b + c 2 / or even / 2 c + b a is the more efficient, unambiguous notation.
- contravariant 7y agoWhile I can see where the author is coming from, I have a couple of points where I disagree. 1. I've yet to see any automatically formatting system that's not extremely painful to work with. 2. Mathematical notation hasn't just been developed over 100s of years it is continuing to do so. 3. Units aren't labels.
- lwb 7y agoAnyone interested in this stuff who hasn't read it yet should check out Bret Victor's Kill Math series of essays and explorable explanations: http://worrydream.com/#!/KillMath http://worrydream.com/#!/KillMath
- evanb 7y agoIf the labels are supposed to indicate units, they should at least indicate the RIGHT units! rent, electric, and internet are dollars/month. Otherwise the 12480 in the example is dollars*months, clearly not the right units.
- dang 7y agoLooks like a follow-up to yesterday's thread here: https://news.ycombinator.com/item?id=22399516 https://news.ycombinator.com/item?id=22399516
- j88439h84 7y agoObservable.js is like this
- guramarx11 7y agothe first example feels deliberately complicated, where gravity constant can be shortened to G_ = 6.67x10^-11, (G_ * M1 * M2 / Rad^2)