6 ms·
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 progra
by dreen 7y ago
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 so lazy I would have learnt it in school. But with my 31-year old brain oriented for looking at a sequential flow of code, it's quite difficult to learn math now.
- everyone 7y agoAgreed. I think the internet needs a 'math as code' wiki site. Math is so easy! and its a joy to work with when programming, but the way its written, the notation, is often baffling to me.
- jciochon 7y agoMaybe you can start from a different angle. It might sound odd, but try taking a simple concept that you know, say calculating a restaurant tip or something and write it out in English + LaTeX. Build on this until you can do some more complicated problems, and soon I would bet you’ll read math as something a bit closer to code in your head. I had to do this a lot for classes in college, and forcing yourself into exposition is the math equivalent of rubber ducky programming. LaTeX will give you a feel somewhere between math and code that might feel a bit more natural.
- 87zuhjkas 7y agoAgreed, 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).
- kbenson 7y agoWhere 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.
- plv7 7y agoSingle letter variables (including Greek ones) are great when they stand for something, or are well-known so they don't need to stand for anything. If you stick to convention and use stuff like A for array, i for index, r for root, δ for small change (a delta), ε for error, Σ (Greek S) for sum, Π (Greek P) for product, etc. It's only when you start using variable names as if they were free variables when they really aren't that you get into trouble with comprehension, especially from people not in your field.
- 87zuhjkas 7y agoIt think this is somewhat similar to: many chinese characters vs ASCII. Neither is the superior notation. I prefer to write words by concatenation of multiple ASCII letters instead of one letter symbols, but that's due to my cultural background.
- enriquto 7y agoyou 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?
- jerf 7y ago" 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?
- throwawaymath 7y agoThat'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/create-lemmas/ https://terrytao.wordpress.com/advice-on-writing-papers/crea... 2. https://terrytao.wordpress.com/advice-on-writing-papers/ https://terrytao.wordpress.com/advice-on-writing-papers/ 3. http://annals.math.princeton.edu/2014/179-3/p07 http://annals.math.princeton.edu/2014/179-3/p07
- ivan_ah 7y agoI 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%206%2C%20x)%0A%23--%0A 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.pdf https://minireference.com/static/tutorials/sympy_tutorial.pd... [2] Notebook version of [1] https://nbviewer.jupyter.org/github/minireference/SymPyTut/blob/master/notebooks/Intro.ipynb https://nbviewer.jupyter.org/github/minireference/SymPyTut/b...
- throwawaymath 7y agoThat sounds like something that could be done using a Jupyter Notebook and SageMath.
- 75dvtwin 7y agoMost 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.
- throwawaymath 7y ago> 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.
- baron_harkonnen 7y ago> mean something beyond basic calculus and linear algebra. "Fluency" in mathematics, in my experience, isn't about being able to perform more complex computation, that's what computers are for. The key to fluency in mathematics is increased efficiency at equational reasoning. Granted, I work in data science, but I've personally seen that more and more problems I have are solved writing out a few equations and reasoning about the problem than writing code. It's not about knowing, for example, what SVD is, but seeing how a variety of common problems trivially map to it. Or figuring out how to transform a business problem into a probability problem so you can quickly estimate your success. Many times now I have spent a few afternoons writing equations that simplified what would have been very large and unnecessarily complex programs. The mistake programmers make is thinking that math is just fancy computation, but mathematical reasoning is an entirely distinct way of reasoning about problems and computation is usually the least important part. I used to also think that there was no reason for programmers to learn any math outside of enough calculus and linear algebra to compute basic things. But really understanding these areas and reasoning about them fluently (as well as other areas of mathematics) opens up many possibilities of problem solving that code it self does not.
- chmod775 7y agoAt 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.
- mikorym 7y agoThe article covers quite a few topics in set theory so that suggests that it does provide for advanced topics. If you mean advanced proofs, again the article may be the right place to start.
- jjtheblunt 7y agoI suspect what's jarring is the difference between programming in an imperative sense, where you write down steps to be taken to get a computation, and equations, like declarative programming. I once dated, in math grad school, a hardcore differential equations student, and she took Java, which she thought so very different than a world of equations. Made sense, I thought, having been exposed to imperative and declarative programming myself.
- jimmaswell 7y agoMath has a syntax to write imperative algorithms in too. Came up in the Discrete Math course I took, for things like finding GCD.
- discreteevent 7y agoGerry Sussman had the same idea and wrote a paper on it: https://www.researchgate.net/publication/37597511_The_Role_of_Programming_in_the_Formulation_of_Ideas https://www.researchgate.net/publication/37597511_The_Role_o...
- abecedarius 7y agoHis SICP coauthor Hal Abelson also cowrote Turtle Geometry, which explores stuff like topology and the basics of general relativity in Logo. An underappreciated old book I'd like to see more like.
- madhadron 7y agoTo be fair, when you actually look at Structure and Interpretation of Classical Mechanics (which is a great book), it's still math that a physicist recognizes, not so much an ALGOL-esque program. The Scheme system was extended to handle the math rather than the math brought to the language. What they did was make all the math explicit, mostly by inserting all the necessary pieces of differential geometry that were glossed over in all other treatments.
- asark 7y agoI've come to the conclusion that my brain's "algorithm"y, rather than "equation"y. My scores on (especially) spatial reasoning tests are excellent so one would think I'd have a leg up in mathematics, but trying to read typical "mathy" (equation-heavy) writing makes me feel the way I assume dyslexics do, even when it's something I'm pretty familiar with. Algorithms, though? No problem. Programming in typical Algol-family languages & similar came easily to me. The "tough" early topics? Pointers, recursion? Not even a bump in the road, totally natural. To this day, though, the ones that look more like mathematical writing (Haskell) are really hard to read, let alone write. I can get all the concepts at play in a piece of Haskell and still not be able to keep the syntax or meaning of the code itself straight. When I do want or have to read mathematics of any complexity whatsoever, I only make headway by converting it to something more algorithmic as I go ("OK, so what does this term or whatever do to any other values passing through, here?")
- new4thaccount 7y agoYou're not alone. The Math symbols are easy once you learn them (at least the subset I know), but it was challenging getting there. My field has a lot of dense math that makes the pyramids look simple (ok I exaggerate, but there is a lot going on). The only way I've been able to really grok it is by writing software to do it. Now that I know what's going on, the math notation is useful in that it explains the problem in a succint way. I think Calculus via Python with nothing but the stdlib and Matplotlib would be a better way for me to learn to be honest.
- soegaard 7y agoCheck SICM. https://mitpress.mit.edu/sites/default/files/titles/content/sicm_edition_2/book.html https://mitpress.mit.edu/sites/default/files/titles/content/...
- hackermailman 7y agoThere's a few books around for this, first is Jeremy Kun's book https://pimbook.org/ https://pimbook.org/ and is probably exactly what you're looking for: math from a programmer's perspective. There's also Discrete Math w/Functional programming https://cs.wheaton.edu/~tvandrun/dmfp/ https://cs.wheaton.edu/~tvandrun/dmfp/ in which most chapters translate theorems into algorithms or turn sets into types. Sussman also has two books translating Lagrange equations and differential eq into Scheme but both assume an undergrad physics background. Brown has a course in linear algebra using Python http://cs.brown.edu/courses/cs053/current/lectures.htm http://cs.brown.edu/courses/cs053/current/lectures.htm but you can do it with any math language library that builds matrices or write your own naive implementation as you go. Of course the best way to do this would be to try and model the notation yourself (if possible) into function specs or algorithms, as you go through various math books. Then you'd really understand the notation even if you failed to implement it. You could try Pyret to do this https://papl.cs.brown.edu/2018/func-as-data.html#%28part._.A_.Little_.Calculus%29 https://papl.cs.brown.edu/2018/func-as-data.html#%28part._.A...
- xodast 7y agohttps://projecteuler.net/ https://projecteuler.net/ Some problems with solutions in different languages. Each problem leads to the next one.
- rpeden 7y agoThere used to be a Coursera course called Coding the Matrix. It covered many linear algebra topics using Python. The course isn't available anymore on Coursera anymore, but you can still buy the textbook: https://www.amazon.com/Coding-Matrix-Algebra-Applications-Computer/dp/0615880991/ https://www.amazon.com/Coding-Matrix-Algebra-Applications-Co...
- happy-go-lucky 7y agoAll of the course's video lectures are still available at: https://www.youtube.com/channel/UCGVa4wp8SWGFtMe6hcdpHlg/playlists https://www.youtube.com/channel/UCGVa4wp8SWGFtMe6hcdpHlg/pla...
- pdm55 7y agoslides https://codingthematrix.com/ https://codingthematrix.com/ code http://resources.codingthematrix.com/ http://resources.codingthematrix.com/
- JWKennington 7y agoI wrote a blog post describing the tensor product in terms of functional programming techniques in python https://jwkennington.com/blog/tensor-product-for-programmers/ https://jwkennington.com/blog/tensor-product-for-programmers... I would also be interested in a "math for programmers" approach to deciphering formalism. I've studied a fair amount of linear algebra / differential geometry and could see how Python-definitions might help. I'm less familiar with other areas of mathematics
- bonoboTP 7y agoAbout variable naming in math. I sometimes also think that it would be good to define sensibly named variables and then use them in subsequent equations much more often than is usually done. Math equations are traditionally very large and complicated, even though they could be broken down to pieces and then assembled piece by piece. I think one argument against this is that in math you often want to reach down a few abstraction levels and reorder terms, factor out things etc. which requires peeking into the "internals of boxes". You can't abstract to the point where you only have two or three variables in one equation because to show the next step, you would need to make the expanded formulas of those variables interact (cancellations etc.). Another is that math is quite a different way of thinking. Most professions don't do as much of this input/output-based, requirements-based thinking with lots of ad-hoc on-the-fly introduced abstractions that is usual in programming. For example engineers, doctors etc. just work very differently and consider many different levels of abstraction at the same time. They consider it normal to sprinkle in temperatures, voltage values etc. in supposedly high-level discussions. Programming is a product of the mind so we have an easier time with it for sure, as our abstractions are more reliable (even if they leak to some degree, they leak much much more in other disciplines). Now, math is also a product of the mind, but tradition is quite different. Of course math is very abstraction-heavy but the abstractions are usually not generated by the practitioner on-the-fly, on-demand, the way you just write a function or introduce a class in programming. Rather they are widely-known definitions and conventions, which are mostly only created by the people developing new theory. Of course you do define some notations and variables in math, but I find it not as pervasive as in programming. The closest you can get to programming-like variables in math writing that still somewhat adheres to math tradition is to place full words into subscript positions (index). For example, you can write out N_columns (as a subscript) or S_upper or L_dual or f_transform. This is also something I see more in CS papers than in non-CS math content.
- 0815test 7y agoYou can use full words or even short multi-world phrases in math expressions. From a typesetting POV, write them in roman (upright) type, and enclose them in brackets whenever ambiguity arises (due to the possibility of separating spaces within a single variable, or the concurrent use of juxtaposition (of single letters) as a product or for other purposes within the same sorts of expression. This is very common in the applied sciences in general, and the convention is universally understood.
- Buttons840 7y agoA few personal observations: 1) A lot of frustration comes from bad expectations about how easy a math formulate should be to read. If I see 3 short lines of code, my gut tells me "this will be easy", and it's right. If I see 3 lines of math I feel like it should be easy but then get frustrated when 30 minutes later I'm still looking at the same 3 lines. 2) Once you understand a formula, I often decided I couldn't write it any better myself. It's most useful as a tool for thought and remembering, not necessarily as a tool for teaching.
- stared 7y agoI try to achieve this goal with "Thinking in Tensors, Writing in PyTorch" project: https://github.com/stared/thinking-in-tensors-writing-in-pytorch https://github.com/stared/thinking-in-tensors-writing-in-pyt... (very much a Work in Progress). The idea is to have equations (in LaTeX) and code (in PyTorch) line-by-line, so it is easy to see how to use it in practice. I think it may help to bridge the gaps between coders (but not experienced in maths) and mathematicians (but with little experience in practical programming).