[HN Gopher] The Mathematical Hacker (2012)
___________________________________________________________________
The Mathematical Hacker (2012)
Author : andsoitis
Score : 124 points
Date : 2022-12-23 17:33 UTC (5 hours ago)
(HTM) web link (www.evanmiller.org)
(TXT) w3m dump (www.evanmiller.org)
| dekhn wrote:
| I use math with computers all the time; have since pretty much
| the beginning of my programming experience 35 years ago. But I
| don't use it well. I depended a lot on other people to convert a
| mathematical equation into a program (for example, think of a
| summation-- that's really just a for loop incrementing an
| accumulator. And an integration isn't much more than that, just
| divide by a constant at the end). I learned gravitational
| simulations that way (amusingly, I was able to do mandelbrot on
| my own knowing just z = z ** 2 + c and brute forcing myself
| through the details).
|
| For me math is more of a received wisdom. I'll have a problem I
| need to solve, and as part of that, I need to compute some
| function. But the naive version of the function that I was taught
| (say, factorial function) is slow, and might fail because of
| integer data types outside their range. In comes my professor,
| who mentions
| https://en.wikipedia.org/wiki/Stirling%27s_approximation which
| allows me to complete my project and graduate in time. Said
| professor also derived analytic derivatives of our objective
| function, since at the time (1993-4) we didn't have
| autodifferentiation.
|
| At the time, I didn't really think too much about it. I had a
| problem and somebody handed me a practical solution. But I got
| curious... what was this gamma function and why is it defined
| over floats (reals!) over integers? And so that led down a rabbit
| hole of mathematical exploration (most of which was executed
| using a highly worn copy of Mathematical Recipes in C).
|
| Another example is the mandelbrot set. You can take the raw
| definition and attempt to compute set members but your
| calculation will never complete. Instead, clever math people
| figured out ways to compute an approximately right answer faster-
| and in some cases, optimized for the limited hardware of the time
| (see FRACTINT for an integer-based fractal program for x86
| machines pre-floating point hardware). This and many other tricks
| made fractal exploration on consumer hardware practical (although
| probably not very useful?)
|
| Over time I've come to be better at math- at understanding
| concepts- and the relationship between practical high performance
| computing and both the underlying math and physics that are
| required to do it effectively. I've learned so many different
| ways to approach problems compared to when I started, much of it
| because I continued to learn more math, and practice at it. I see
| a close relationship between computing theory and the
| math/physics that enabled it (IE, transistors and vacuum tubes
| before them, and mechanical gears and switched before that).
|
| I've also realized that I can learn some math easily- for
| example, more or less anything on a cartesian grid- while other
| things, like complex symbolics or tree structured algorithms-
| take a lot more thinking.
|
| To me it's an endless world of unknown delights that I stumble
| across and periodically take 20+ years to understand. I am _just
| now_ solving problems that my smarter grad school friends managed
| to do in a day, 20 years ago, because they 're better at math
| (and logic, and memory, and more...)
| hintymad wrote:
| > They seem to agree on one thing: from a workaday perspective,
| math is essentially useless.
|
| The creator of Dilbert advocates stacking, namely learning
| multiple skills and combining them to achieve better results than
| any single skill can. His advice applies to maths as well. I work
| on distributed systems as a generalist, yet I find maths, time
| and time again, career changing. A few typical examples: queuing
| theory that helps improving latency of my services by more than
| 10x. Statistics to identify patterns in data, which led to a new
| product. Time series analysis that led to a new system. Data
| mining and information retrieval in search and recommendation for
| continuous improvement of my search product. Linear algebra,
| calculus, and combinatorics as foundations to identify or prove
| certain properties of my systems for later optimization. And in
| general, the ability to understand papers (or at least know what
| to learn to unblock myself) to stay on top of what's going on in
| exciting fields.
|
| One does not necessary need maths to build systems, but boy it is
| satisfying and career-rewarding when I actively look for real
| problems that scream for some maths. What's most amazing is that
| we don't even need graduate-level maths. Entry-level college
| maths play wonders most of the time.
| bmitc wrote:
| In Steve Yegge's linked post:
|
| > Math is a lot easier to pick up after you know how to program.
| In fact, if you're a halfway decent programmer, you'll find it's
| almost a snap.
|
| This couldn't be more wrong. Mathematics is the hardest thing I
| have ever done. I'm sorry, but mathematics is orders of magnitude
| more intensive and difficult than most programming. A simple fact
| that shows this is the amount of programmers who have no formal
| training in engineering or computer science but we're able to
| self-teach the concepts. The same cannot be said of mathematics,
| which requires deep, dedicated study. Most programmers I know
| know very little mathematics, and it's not like I'd claim I know
| a lot either. I've forgotten more than I know.
|
| He even mentions how little math he took, so I'm not sure he's an
| authority on the subject. Most of his post is just surface level
| platitudes. I'm generally confused why I see his posts referenced
| so frequently.
|
| To be clear, this isn't some attempt at gatekeeping. It's just
| that mathematics is a very deep, difficult, and misunderstood
| subject. I think maybe only true philosophy is harder because
| there, it's usually not even clear what the questions are.
| jjtheblunt wrote:
| He might be describing one bifurcation in the world of math,
| where constructive proofs reign, but overlooking
| nonconstructive "existence" proofs.
| strangattractor wrote:
| Implementing numerical solutions for math concepts can give you
| insight into the math ex. Newton-Raphson Method or FFT. I would
| not sell yourself short on being able to understand. You may
| not be skilled at doing all the symbol manipulation required
| for what people consider typical "math" but that does not mean
| you cannot understand it.
| bmitc wrote:
| I do agree that programming is very useful as a medium of
| exploration, a la what you said. I really like how the book
| _Turtle Geometry_ approaches this. But that is really
| something different than what the quoted text is attempting
| to get at.
|
| > I would not sell yourself short on being able to
| understand.
|
| I have a master's in mathematics and have continued to take
| courses while working full-time. It's just that I'm more than
| aware of the amount of mathematics I do not know compared to
| an active graduate student in mathematics and above. Or maybe
| you meant the royal you.
| bee_rider wrote:
| What do you mean by "learning Mathematics?" It should be notes
| that significantly less than 50% of the US population even has
| to learn _calculus_ so getting into the stuff that most people
| would consider pretty advanced is not so hard, right?
|
| I'd be curious what people's coolest math tricks are that
| they've used at work. I did like one Taylor Series expansion
| and felt cool for a week.
| dinkumthinkum wrote:
| You are right about the 50% but you might as well have said
| "fewer than 99%". I mean, the real number is far, far less. A
| very small percentage of US residents would recognize and
| calculus or be able to solve a simple linear equation.
| zozbot234 wrote:
| Never mind calculus; a non-trivial fraction of the U.S.
| population has trouble learning _elementary algebra_. The
| fact that the U.S. K-12 educational system is notoriously a
| failure compared to otherwise similar countries should not be
| used to draw inferences about the inherent worth of any
| particular subject. Not least because that same system also
| often fails to teach functional literacy, or any amount of
| basic facts about society that may elsewhere be assumed to be
| known by any educated adult.
| subradios wrote:
| Then why do all New England states outcompete most European
| countries?
|
| Why is most STEM research produced in Eastern Europe, the
| US, or China?
|
| This really depends on what metrics you are using and has
| infinite room for gaming.
|
| US undergrads (both native and foreign born) absolutely
| crush all of these nondescript places you are suggesting
| are better, and graduate programs make the gap even wider.
|
| A non trivial fraction of those are educated K12 in the US
| system.
| zozbot234 wrote:
| U.S. undergrads have to complete "general educational
| requirements" that are taken care of in high school in
| practically every other developed country. Why does that
| happen? Because U.S. colleges don't trust K-12 to provide
| a satisfactory education.
| texaslonghorn5 wrote:
| or that there's value in a college level comprehensive
| education as well
| zozbot234 wrote:
| All other things being equal (including quality), high
| school is actually _better_ than college at doing the
| "comprehensive education" thing. College level gen-eds
| are almost universally reviled as a pointless box-ticking
| exercise that gets in the way of specialized education.
| This particular dysfunction has effects even further out;
| U.S. college education pushes things out to the grad
| school level that are elsewhere part of the later years
| of undergrad.
| bee_rider wrote:
| New England is mostly sanely governed, it shouldn't be
| used as a stand in for the rest of the country.
|
| The US was a neat idea we had but it went a little off-
| kilter around the second half of Pennsylvania.
| kvathupo wrote:
| I'd agree: there's a common misconception that math is
| "objective." Even if one agrees on the axioms (Axiom of Choice
| [1]), one must reach consensus on definitions, which seem to be
| consciously chosen to allow generalization of theorems to more
| mathematical objects; that is, building connections between
| previously disparate fields of math, e.g. algebra and geometry,
| calculus and geometry, etc. Why have many domain-specific
| theorems when we can have one?
|
| One could have a valid proof to a theorem, but there's the
| human element of having people understand and accept the
| result.
|
| That said, I think when people speak of math, they speak of its
| application to the real-world, not the proofs.
|
| [1] - From the Wikipedia page for the axiom, Jerry Bona has an
| amusing quote: "The axiom of choice is obviously true, the
| well-ordering principle obviously false, and who can tell about
| Zorn's lemma?"
| JadeNB wrote:
| > That said, I think when people speak of math, they speak of
| its application to the real-world, not the proofs.
|
| I think it very much depends on who the people are. I'm a
| math teacher, and, when I speak of math, I definitely don't
| just mean its applications to the real world. I definitely
| think programming--in the sense of thinking about the craft,
| not just cudgelling the computer into doing what one wants--
| is good preparation for learning the proof-theoretic arts of
| mathematics.
| kccqzy wrote:
| I learned Haskell before I learned to write proofs. And yes it
| did help.
|
| But no I don't think experience doing boot camps and churning
| out React apps and gluing together APIs would help with
| learning mathematics.
|
| Go learn a language that seriously challenges you like Haskell.
| starwind wrote:
| Math hard. Can confirm. Starwind have math degree. Starwind
| much better at programming than Starwind ever was at math.
| shankr wrote:
| I spend 5 years doing mathematics and still can't wrap my
| head around lot of maths. If you really want to see the
| difficulty in Computer science you'll have to go explore the
| theoretical stuff which at the end is just maths.
| tombert wrote:
| I think Yegge is actually completely correct. I started to
| learn to program when I was 14, and once I understood the
| concept of functions, I found it much easier to do my calculus
| and physics work. Fundamentally I understood how to break
| things down into computable steps.
|
| Granted, I think get the impression we might be overloading the
| term "mathematics".
| BeetleB wrote:
| For most mathematicians, calculus as is often taught in
| typical undergrads is not "true" mathematics. It's just a
| tool for computation. For them, calculus is analysis
| (theorems/proofs that are used to build up calculus).
|
| So my question is: Did you study analysis and would you
| credit programming in helping you get good at it?
| edgyquant wrote:
| Not them but I def would. I built a fintech/econometric-
| lite system in python years back and it was mostly just
| taking in a ton of "obvious" knowledge and realizing the
| cool stuff you could do in practice
| c0balt wrote:
| +1 for this comment. Calculus, i.e., Calculating with
| mostly finite numbers and (usually) a known set of well
| defined rules is only a part of mathematics.
|
| As a student that currently learns Analysis and linear
| algebra, it is far more complex and abstract than calculus.
| It is not neccessarily harder to learn but different. And
| adapting to this paradigma takes time (and effort).
|
| It is similiar to learning Assembley as a Python developer.
| Knowing Python will help with Assembley. But the levels of
| abstraction are obviously different and will require a lot
| of learning.
| bmitc wrote:
| Mathematics is not just functions and calculus.
|
| And it seems to me that you learned the concept of functions
| through programming first but that there's not evidence that
| you couldn't have learned it from mathematics at first.
| Functions are a pretty easy concept, so I think it's pretty
| easy to introduce it from a variety of points of view. So I'm
| not sure the anecdote backs up any argument about learning
| programming makes mathematics easy.
|
| I am of the opinion that programming can be _used_ to explore
| and learn mathematical ideas and am a big proponent of that,
| but that is something different than "I know how to program
| so mathematics will be easy now".
| dekhn wrote:
| functions in traditional programming and functions in math
| are two different things entirely. They should have been
| called procedures (I think there's historical debate about
| this but I can't find the reference). Obviously, functional
| programming is an attempt to address this.
| edgyquant wrote:
| I grew up programming (from 10 or so) and couldn't agree
| more. I have almost no formal education yet I've picked up
| enough math to do ML and (mediocre) cryptography and keep up
| with people who have scary sounding degrees. in the process
| I've fallen in love with math and think as programmers we
| haven't been meeting mathematicians half way.
| constantcrying wrote:
| For me the opposite was true. My mathematical education made it
| incredibly easy to pick up programming and programming
| languages, everything was somewhat familiar and the concepts
| just came naturally.
| dekhn wrote:
| How did you feel when you first came across a global
| variable, or even a pointer? It seems to me that math-first
| people would probably find C to be an abomination.
| constantcrying wrote:
| I believe one thing which came really natural was to think
| in virtual machines, to see a programming language as
| something which acts upon a fictitious environment, where
| certain instructions map to certain consequences. Of course
| programming and mathematics are very different activities,
| but one core principle that I always relied on was thinking
| in abstractions. What option do I have to manipulate the
| environment and what invariants are there? How are complex
| thing constructed out of others?
|
| >It seems to me that math-first people would probably find
| C to be an abomination.
|
| I certainly don't. You might do so if you wanted
| programming to be an expression of pure mathematics, but I
| do not think that is the right approach. C does well for
| what it is an abstraction over an underlying, real machine
| and thinking of it as an abstraction is the right thing.
| bmitc wrote:
| Most definitely. For me, I have never used any specific
| mathematical concept in programming aside from some side
| projects for using programming to explore mathematical ideas.
| But my so-called training in mathematics taught me both
| highly abstract thinking and deep, concrete, in the weeds
| thinking, and that's what really comes in handy in
| programming.
| BeetleB wrote:
| Technically, that's the converse, not the opposite ;-)
|
| Someone may be led into thinking you're countering the OP.
| quantum_state wrote:
| If I may, would like to add that the statement is not even
| wrong ...
| edgyquant wrote:
| I disagree because Math _is_ programming. All those symbols you
| see map to a set of steps (a program.). It's just knowing what
| subroutine every esoteric symbol stands for that's hard.
|
| I will agree it's been more difficult learning math than
| programming for myself as well: but that's because math is
| geared and targeted for people who like doing symbolic logic by
| hand. Math people think we're a level below them (we are in
| some ways from a working perspective) so they tend to write off
| complaints like this as us just wanting to make math more like
| programming.
|
| The fact we don't have a nice and intuitive way of writing math
| via a keyboard is proof that these two fields, which should be
| tightly coupled, are not on the same page.
| BeetleB wrote:
| I think the math you've been exposed to is mostly on the
| computational side (compute an integral, solve an equation,
| etc).
|
| Much (most?) of math is quite different from it. Proving that
| there is a well ordering of the reals, and simultaneously
| proving that it is impossible to _show_ you such an ordering:
| Very different from skills needed in programming.
| edgyquant wrote:
| I disagree. You're only able to prove that ordering of the
| reals (and that it's impossible to show) because you are
| computing the abstract structure underlying the reals
| (which is based on some lower level ideas etc.) Just
| because a problem is computationally hard with a step by
| step CPU doesn't mean it isn't computation.
|
| This is actually a problem of interest to me, so I've
| definitely been exposed to it and the limits of modern
| computation. But I'm not speaking strictly about the modern
| day CPU.
| bmitc wrote:
| > You're only able to prove that ordering of the reals
| (and that it's impossible to show) because you are
| computing the abstract structure underlying the reals
| (which is based on some lower level ideas etc.) Just
| because a problem is computationally hard with a step by
| step CPU doesn't mean it isn't computation.
|
| The set of computable real numbers is countable and thus
| has measure zero. In other words, almost all real numbers
| are non-computable, and almost all has an exact
| definition.
|
| So you can't compute the real numbers unless you're
| meaning something else by computing.
| bmitc wrote:
| > Math is programming.
|
| That doesn't make any sense. What do you mean by that?
|
| > I agree it's been more difficult learning math than
| programming for myself as well: but that's because math is
| geared and targeted for people who like doing symbolic logic
| by hand.
|
| Mathematics is not about symbolic logic. Mathematics is the
| study of idealized structures, their properties, and their
| relationships. Symbols are just a convenient shorthand. They
| are not the mathematics in and of themselves.
|
| > The fact we don't have a nice and intuitive way of writing
| math via a keyboard is proof that these two fields are not on
| the same page.
|
| What does that have to do with anything? Although LaTeX and
| the like are pretty decent at it, there's a lot of things we
| can't do easily via a keyboard. Why is that a constraint on
| anything or relevant?
|
| Not trying to be provocative, but I honestly have little idea
| what you're talking about.
| constantcrying wrote:
| >All those symbols you see map to a set of steps (a program.)
|
| Simply not true. Most mathematical statements, e.g. proofs of
| existence have no relation to a "program".
|
| >math is geared and targeted for people who like doing
| symbolic logic by hand.
|
| No, it is not. There is absolutely nothing interesting about
| symbol manipulation, it is always the least interesting part
| of a proof. It usually is the part the author handwaves away,
| while focusing on the actual interesting parts, the idea
| behind the proof and the possible intuitions for them.
| Textbook might include them, but as training and because you
| need to be more explicit when teaching.
| zozbot234 wrote:
| A constructive proof of existence is _exactly_ a program.
| (It might not always be a program for a Turing machine,
| because "constructive" and "computable" are not exactly
| the same - but that's beside the point.) Even a non-
| constructive proof of existence for _x_ can be significant
| in a programmatic context; it tells you that you can posit
| an oracle for _x_ (e.g. asking for it to be input by the
| user, introducing further assumptions based on some special
| case, etc.) without thereby crashing the program or causing
| it to behave incorrectly.
| constantcrying wrote:
| >but that's beside the point
|
| It seems to me that it is an important point though.
|
| > Even a non-constructive proof of existence for x can be
| significant in a programmatic context
|
| Which has no relation whatsover to proofs and programms
| being the same thing.
| zozbot234 wrote:
| A type-level program is still a program. Non-constructive
| proofs are addressing the question "will this program
| crash or go wrong if I extend it to do X, regardless of
| how I achieve that?", which is exactly the domain of
| type-level programming.
| edgyquant wrote:
| >Simply not true.
|
| Okay. What is a proof other than a step by step explanation
| for why something's true? You're getting caught up in
| "program" when it's objectively the case that all math
| follows a series a steps. A lot of those steps are
| "handwavy" I'll give you that. That's not relevant to what
| I said though.
|
| >there is nothing interesting about symbol manipulation
|
| Cool. You missed my entire point again. Math education is
| geared towards a certain set of people who pick up on (and
| gain an interest in) the language of math. Only once you
| get to higher level math do you even start to get
| alternative visualizations etc (at which point you've
| weeded out a ton of people who would have benefited from
| e.g. visualizing numbers as groups of shapes). There are a
| million ways to teach math and we're leaving a lot of
| people behind. That was my point
| constantcrying wrote:
| >Okay. What is a proof other than a step by step
| explanation for why something's true?
|
| Cooking instructions are a series of steps as well. Would
| you also claim cooking, mathematics and programming
| really are all the same thing?
| tsss wrote:
| If you want to get technical then programming is also math,
| provably so.
| dysoco wrote:
| > mathematics is orders of magnitude more intensive and
| difficult than most programming
|
| But what level of programming and mathematics are you comparing
| here though? because college-level algebra and calculus is
| really not that hard imho (once it "clicks" for you, but it's
| the same for programming), and if we are comparing math as in
| what you see in a BSc/Msc of Mathematics (or research-level)
| then I agree it's hard but you have to compare for an
| equivalent level of programming.
|
| > simple fact that shows this is the amount of programmers who
| have no formal training in engineering or computer science but
| we're able to self-teach the concepts. The same cannot be said
| of mathematics
|
| I would blame it more on the fact that programming is a very
| useful tool for people outside Computer-Science, it has very
| direct applications and you can monetize it very easily, so
| it's very likely that they might want to learn it, however,
| rarely you see someone deciding to take Calculus just for the
| sake of it if they never bothered with it in College.
|
| Overall I agree with you, but personally I find math more
| difficult, most people probably do but I don't think it's
| inherently more difficult, it's just that people are less used
| to study it.
| nickelpro wrote:
| I would hard disagree that undergrad level Analysis or even
| just the trickier corners of vector calculus are within the
| bounds of what programmers can easily pick up without
| dedicated and guided study. Everybody's gangster until they
| have to parameterize some bullshit helical structure in R3.
|
| Comparable levels of programming, what we expect of CS
| juniors, are regularly picked up by "the guy who is good with
| Excel" in office settings as it's mostly a function of
| experience and exposure, not theory.
|
| And now my worthless anecdotal evidence: I self taught myself
| into professional programming and it was a simple matter of
| banging my head against a wall until shit started working.
| The feedback loop, "did the thing crash or not", permitted me
| to learn on my own. I wouldn't even begin to understand how
| to self-teach myself Stokes Theorem or some shit, and have
| zero ability to author the proofs required to reach the
| conclusions higher level mathematics are built on.
| zozbot234 wrote:
| > I wouldn't even begin to understand how to self-teach
| myself Stokes Theorem or some shit
|
| Input it into a proof assistant, and rely on the same sort
| of feedback "does the computer accept your proof, or get
| stuck". The hard job of formalizing stuff for this purpose
| has seen significant progress, e.g. by the Lean mathlib
| project.
| nickelpro wrote:
| I would quibble with whether this is exactly equivalent.
|
| In programming I knew I needed to sort a list or find a
| most efficient path because some practical problem I was
| trying to solve demanded that I do that. Frequently I had
| a basically crap but working independent solution before
| I learned the names "EWD" or "A*". I independently
| discovered that I needed virtual interfaces (before I
| knew them by that name, "I wish pointers to parent
| classes could call implementations in subclasses") _and
| then_ discovered language facilities for polymorphism and
| OOP.
|
| Without formal or at least guided instruction I would
| never think to move towards or discover "I wonder if
| there's a relationship that makes these double integrals
| of curls of vector fields easier to solve for".
|
| Programming has a high coupling between necessity,
| experience, and theory. In mathematics that coupling is
| much, much, much looser. Self learners in programming
| regularly re-discover and re-implement, typically less
| efficiently, all sorts of fundamentals of CS. The
| equivalent in mathematics rarely happens post-algebra.
| nextos wrote:
| I think your comparison is a bit unfair. Essentially, CS
| is as hard as mathematics because _it is_ mathematics.
|
| For example, take any good static analyzer that
| implements abstract interpretation. It generally works
| using Galois connections, which is just abstract algebra.
|
| Dijkstra's algorithm or A* came pretty early in the
| history of CS. It would be fair to compare their
| difficulty to something similar in mathematics, say some
| basic results in Euclidean geometry.
| nickelpro wrote:
| CS may be mathematics but programming certainly isn't
|
| If you're discussing pure CS, the thing you can write
| down in a book and for which a computer is a largely
| theoretical device, sure CS is mathematics.
|
| If we're talking about the practical reality that CS
| majors in America today are trying to achieve, and their
| undergraduate programs are trying to prepare them for,
| that's becoming a working programmer and has very little
| relation to mathematics.
| JadeNB wrote:
| > Input it into a proof assistant, and rely on the same
| sort of feedback "does the computer accept your proof, or
| get stuck". The hard job of formalizing stuff for this
| purpose has seen significant progress, e.g. by the Lean
| mathlib project.
|
| As a math teacher who disagrees with the premise of the
| GGP post ("This couldn't be more wrong. ... I'm sorry,
| but mathematics is orders of magnitude more intensive and
| difficult than most programming"), and thinks that any
| _good_ programmer can learn mathematics--of course there
| are code wodgers out there who don 't really understand
| their craft of programming, and so can't translate that
| knowledge to facilitate an understanding of mathematics--
| I think I also disagree with this. I've never tried it,
| but I can't imagine someone learning about Stokes's
| theorem in anything like this way. One of the many axes
| along which I imagine this failing are that the state of
| human readability in proof assistants is, well, let's say
| it's less well developed than the, cough, stellar state
| of the art in compiler error messages.
|
| But, more importantly, you can, at least in principle,
| know every single step in a proof of Stokes's theorem
| without understanding in any real sense _why_ it 's true
| --and a proof assistant in particular will force you into
| the weeds of minutiae that absolutely do not help to
| build any intuitive picture--and, even if you manage in
| the process to piece together that understanding of why
| it's _true_ , you will never thereby gain an
| understanding of why it's _interesting_ (e.g., among
| other things, its connections to physics and the entree
| it offers to differential geometry).
| zozbot234 wrote:
| The flip side of a proof assistant's 'minutiae' (and
| there's plenty of room to disagree wrt. whether paying
| attention to those minutiae helps with gaining a better,
| more accurate intuition!) is its ease of refactoring a
| proof. A proof assistant can instantly tell you whether a
| seemingly nicer, better-abstracted proof B really manages
| to prove the same thing as proof A, something that's very
| hard to do without the use of precise formalized
| statements and automated checking.
| dinkumthinkum wrote:
| Self teach Stokes Theorem by inputting it into a proof
| assistant? Are you serious? That is very inefficient; the
| OP was talking about learning the kind of vector calculus
| taught in first calculus sequence. I think just watching
| a short YouTube video and doing a few exercises will work
| and is a proven method. Proofs of theirebs are very often
| much more complicated than applying them (understatement
| intended).
| dysoco wrote:
| Do you have more information on this approach? Sounds
| very interesting. I've read and toyed a little with
| things like Lean and I'm interested in that field but the
| barrier seems a bit high (without pre-existing knowledge)
| to just "input" a theorem and toy with it.
| anthk wrote:
| Read The Computational Beauty of Nature and compile the
| associated examples:
|
| https://github.com/gwf/CBofN
| conformist wrote:
| Feels like the "modern" data science & python hacker/plumber is
| typically closer to the Fortan and linear algebra side these
| days?
| cod1r wrote:
| CS/programming for me was a good balance between practical
| application and theory. Spending more time programming and
| getting better at programming will probably land you a higher
| salary than if you were to spend your time learning complex math
| which you might/might not use.
| magicloop wrote:
| When I first was learning to program I was shocked at the logical
| mistakes and errors I was making. I thought these were an initial
| bout of bad luck that would pass. But no! And I learned the craft
| of debugging before my programming hobby took could really take
| off.
|
| Programming takes high precision thinking. Learning mathematics
| is what has tuned my mind to better, more precise, thinking. So I
| am grateful for this and feel I am a much better programmer for
| it. It also seems to sharpen up ones debugging skills.
|
| There are other things that help also. Second, I'd say learning
| to write well helps a lot also. Programming is communication (by
| way of the source code you leave behind for others to read and
| interpret). A deft hand for exposition sits at the centre of good
| naming practices for code.
| wwweston wrote:
| > Rather, mathematics is a tool for understanding phenomena in
| the world: the motion of the planets, the patterns in data, the
| perception of color, or any of a myriad things in the world that
| might be understood better by manipulating equations.
|
| OK, so on one hand I love this point, and I'd love for it to be
| more broadly understood and appreciated, especially since my
| educational background is Mathematics and my CS has been
| practical, half self-taught, and frankly patchier than I'd like.
|
| But:
|
| > Fortran-school programmers view the computer as an advanced
| tool for doing mathematics.
|
| If we're understanding "mathematics" as numerical/analytical work
| + engineering ( _maybe_ applied mathematics) I can see this.
|
| But the Lisp programmer talking in terms of recursive fibonnaci
| definitions is doing something that can quite adequately be
| described as mathematics, though it's also mathematics to figure
| out the closed form and understand why you might or might not use
| it. Not sure if it's mathematics to simply know a given closed
| form, though it's something mathemeticians sometimes do.
|
| And I'm more skeptical that Lisp programmers _don 't_ do all this
| stuff: recursive demonstrations of fibonacci numbers are usually
| in textbooks _to teach recursion_ rather than present an optimal
| way of computing fibonacci numbers, because it 's simpler than
| starting with dynamic programming, and you're gonna need
| recursion to effectively solve _some_ problems.
|
| Not only that but a higher level, I think that a lot of
| developers (Lisp included) are already reaching into the very
| mathematical skills of domain modeling at one level or another --
| often first with a different set of tools than a mathematician
| might bring, but a similar kind of work. If Miller's overall
| point is that we all could do a better job with more of a
| mathematician's tools, I agree, but then again as someone who
| came into industry with a math undergrad's tools the utility of
| those might be overemphasized here.
|
| Or maybe I just don't appreciate what I already have.
| userxyz wrote:
| I think the author is making two points among others:
|
| 1. LISP based text/books always present the same two cliche
| examples
|
| 2. They never go beyond (1) given how much they talk about
| recursion. He mentions sqrt of 5 in the explicit formula of
| Fibonacci sequence and how that could be explored in more
| detail to find out where that comes from. For that you need to
| know [0]. That's part of a larger suit of theorems on
| sequences. This stuff together with theory that surrounds the
| Gamma function can easily take up a whole book. But there are a
| ton of books that treat either one really nicely: most
| textbooks on discrete math and real analysis.
|
| [0] https://ibb.co/TR1f5Gz
| zozbot234 wrote:
| Non image-based link: https://en.wikipedia.org/wiki/Linear_re
| currence_with_constan... (Also,
| https://en.wikipedia.org/wiki/Constant-
| recursive_sequence#Cl... )
| userxyz wrote:
| I see someone disagreed with me. Not sure about what, but
| just in case I will show how to derive a formula for
| Fibonacci using the above. You be the judge if it belongs in
| a LISP programming textbook, even though this particular
| result is very elementary.
|
| Recurrence relation for Fibonacci is F_k = F_(k-1) + F_(k-2)
| for k=> 2 with F_0 = F_1 = 1. Also, t^2 - t - 1 = 0 implies t
| = (1 + sqrt(5))/2, (1 - sqrt(5))/2. Both of these facts
| satisfy the conditions of the linked theorem and so we have
| F_n = x((1 + sqrt(5))/2)^n + y((1 - sqrt(5))/2)^n for n=>0.
|
| Now F_0 = x + y = 1 and F_1 = x(1 + sqrt(5))/2 + y(1 -
| sqrt(5))/2 = 1 from which it follows that x = (1 +
| sqrt(5))/2sqrt(5) and y = -(1 - sqrt(5))/2sqrt(5) meaning
|
| F_n = (1 + sqrt(5))/2sqrt(5)((1 + sqrt(5))/2)^n + (-1 +
| sqrt(5))/2sqrt(5)((1 - sqrt(5))/2)^n.
|
| This math (complete with a universe of theorems and their
| proofs) can obviously be extended in many different
| directions in such a way that it can take over your whole
| book.
| graycat wrote:
| I was a "programmer", and well paid at the time, but also had a
| good background in ugrad plus some in pure/applied math.
|
| The math helped, was enough help to be a crucial difference and
| put me way ahead of the pack, that is, everyone else around. The
| math I did was to solve problems in the job I had. The job was as
| a programmer or other computer guy title, but I saw the problems
| and used math to attack them successfully.
|
| So much for some generalizations. Some examples are needed:
|
| Example 1: One afternoon Fred Smith, founder, COB, CEO of FedEx,
| stumbled out of his office, tired, frustrated saying "we need a
| computer". He had just been trying to schedule his fleet of
| airplanes. Soon the BoD was also concerned, so concerned that
| crucial, necessary equity funding was seriously at risk.
|
| A guy I knew in ugrad physic class called me. At the time I was
| being a computer guy at Georgetown U. and also teaching courses
| in computer science. Several of us met in a conference room in
| the library to discuss what to do about the scheduling. There was
| lots of noise. Finally I announced that I would design and write
| the software. I got an account on a time sharing service offering
| CP67/CMS (VM/CMS) computing and wrote the software in my favorite
| language, then and now, PL/I.
|
| Later in Memphis, one evening SVP Roger Frock and I used my
| software to develop and print out a schedule for the full planned
| fleet. The next day two representatives of Board Member General
| Dynamics went over the schedule and announced "It's a little
| tight in a few places, but it's flyable." The BoD was happy, and
| the funding came. Smith's remark was that the schedule "solved
| the most important problem" facing the company.
|
| Role for math? Apparently I was the only one around who could see
| that calculations of great circle paths was just the the law of
| cosines for spherical triangles and to do the vector calculations
| to handle winds.
|
| Right, not much math was involved, but the math was crucial, and
| I was the only one around who had it.
|
| Example 2: At Georgetown a computer science prof got some public
| code for some statistical operations, wrote a main program to
| call that code, and used the result in teaching a course in
| statistics. In his testing, three of the public routines had
| problems. Two of the problems I fixed with just some PL/I tricks
| with memory and some algorithms from Knuth. For the third, there
| were numerical problems, and I solved those with a version of
| orthogonal polynomials. Not much math, but the math solved the
| problems the prof saw, and I was the only one around who knew
| that math.
|
| Example 3: I was in a software house, part of KMS (early
| connection with laser fusion), and bidding on some software the
| Navy wanted. Part of the work was Nyquist sampling, the fast
| Fourier transform (FFT), power spectral estimation, digital
| filtering, etc. I had been working close to all that due to
| working with the FFT, got the Blackman and Tukey book on the
| statistics of power spectral estimation, quickly wrote some
| sample code, in PL/I, illustrating how to do much of what the
| Navy wanted in the bid, showed the code and its output to one of
| the Navy engineers, and presto, bingo KMS got coveted "sole
| source" from the Navy. My work with the math put our software
| house far ahead of the software houses we were competing with.
|
| Example 4: The BoD at FedEx wanted some revenue projections.
| People around the office had hopes, intentions, dreams, etc. but
| nothing rational or convincing. We knew the current revenue and
| the revenue from the full, planned fleet. So, the projections
| were an interpolation between those two. Argue that the revenue
| would grow by current customers influencing customers to be so
| that the rate of growth would be proportional to the number of
| current customers doing the influencing and the number of
| customers to be being influenced. So, at time t, let the revenue
| ($ per day) be y(t), the current time t = 0, the current revenue
| y(0), and the planned revenue b. Then for some constant of
| proportionality k, we should have
|
| d/dt y(t) = y'(t) = k y(t)(b - y(t))
|
| So, this is a first order, linear, ordinary differential equation
| initial value problem. There is a closed solution based on,
| right, exponentials. It is just calculus to solve the equation. I
| did that, picked a reasonable k, drew a graph, and, ..., in short
| this work kept the BoD from _collapsing_ and saved the company.
|
| Calculus. Gee, just calculus. My big advantage was that I
| remembered calculus (quite well, and way beyond this problem) and
| was able to formulate the problem as calculus and solve the
| differential equation.
|
| Right, the solution is a _lazy S curve_ and is related to some
| models of Covid growth.
|
| There were other examples in 0-1 integer linear programming, some
| original work in mathematical statistics, continuous time,
| discrete state space Markov processes, etc.
|
| Here is how that can go: Are working in computing in a company,
| see a problem the company has, see some math that provides a
| solution, and, by writing some software and using available data,
| proceed with some success. Maybe no one else in the company sees
| the problem because they don't know enough math to see a math
| formulation and solution.
|
| It appears that commonly where people are doing a lot of
| important work, there are important problems that need solving,
| are being neglected, and where some math can be the key tool in
| formulation and solution. A person with that math may be unique
| in the company.
|
| But don't hold your breath looking for job descriptions that
| mention such usages of math. Uh, why not? Did I mention that the
| person with the math might be unique in that organization.
|
| Also draw from the two old Disney movies _Snow White_ and
| _Cinderella_ and see the possible roles of jealousy and sabotage.
| In my experience, Disney was 100% correct.
| Someone wrote:
| > _it is possible to be a productive and well-compensated
| programmer -- even a first-rate hacker -- without any knowledge
| of science or math. But I think that most programmers who are
| serious about what they do should know calculus (the real kind),
| linear algebra, and statistics_
|
| Not surprisingly, those happen to be branches of mathematics with
| lots of applications. I would argue that programmers should know
| them, but only superficially, as in having an understanding of
| what mathematical properties mean in real life and in knowing how
| to compute them, without having to understand why and when those
| computation steps work.
|
| For example, when computing a double integral, changing
| integration order is only allowed under specific circumstances (h
| ttps://en.wikipedia.org/wiki/Order_of_integration_(calculus...).
|
| In a math exam, you'd have to show these properties hold before
| switching integration order. If you do that well and then make a
| slight mistake in your subsequent computation, you get a tiny
| point deduction, but still easily pass your exam.
|
| In physics, you'd just switch order, compute the answer, check it
| with reality, and if it doesn't look wrong, declare you solved
| the problem (that may be slightly exaggerated, ;-)).
|
| The check with reality is important even if switching integration
| order is OK because, if you make a slight mistake in your
| subsequent computation and design a bridge based on the result,
| people may die.
|
| The point is: for physicists, it's not the journey that's the
| reward, but the destination. And yes, ideally they'll know when
| their tool won't work, but physicists rarely encounter the weird
| constructs that mathematicians consider in their job such as
| functions that are continuous, but nowhere differentiable
| (https://en.wikipedia.org/wiki/Weierstrass_function), or
| discontinuous at every rational number, but continuous elsewhere
| (https://en.wikipedia.org/wiki/Thomae%27s_function), and there's
| always the reality check at the end that will catch (most)
| errors.
|
| > _Rather than viewing mathematics as an advanced tool reserved
| for extremely specialized computer applications, Fortran-school
| programmers view the computer as an advanced tool for doing
| mathematics._
|
| Here, I'd say Fortran-school programmers view the computer as an
| advanced tool for doing _computations_. That's not surprising;
| Fortran-style programmers are physicists. They care about the
| result. Mathematicians don't, at least not in the sense of
| something that's useful in the physical world.
| javaunsafe2019 wrote:
| Maybe we could first try distinguish both. So when I think about
| it, software development is mostly about the application of
| mathematics and transformation of information whereas mathematics
| are about describing the world in a formal manner.
| rsrsrs86 wrote:
| After reading the article, I am confused. I use types and
| categories frequently, and how is that not math?
| leephillips wrote:
| I really like this article, but there's something the author is
| not considering:
|
| https://lee-phillips.org/lispmath/
| mschoenert wrote:
| As pointed out above - the most efficient to compute large
| fibonacci numbers is to compute the matrix power
| [[1,0],[1,1]]^n using repeated squaring. Or you could use the
| known identities to compute Lucas numbers, which amount to the
| same thing. The lispmath talks about computing fib(40000) in
| 100..200 ms, the repeated squaring approach computes the same
| number in < 5 ms (on my not very powerful machine).
| JoeyBananas wrote:
| I define a hack as a use of something in a way it was not
| intended to be used to achieve a goal. This definition is missing
| from this essay, and the ones it does present are poor IMO. Under
| my definition, hacking falls entirely in domain of the Lisp
| programmer. Fortran engineers are the ones who get fired for
| hacking.
|
| There is nothing inherently wrong with the "Fortran" approach.
| Sometimes, it is necessary. But it's clear that the Lisp-style
| solution is always preferable unless proven inadequate for the
| problem at hand.
| revskill wrote:
| As i see, maths is more about proof, and rediscovery new
| theorems, than to write "arbitrary, unproven proof". It's more
| like 100% unit test coverage of your codebase (harder than
| writing the code).
| tromp wrote:
| The suggested "efficient" solutions for fibonacci and factorial
| only work on small inputs as they return the result as a long
| int. For these small instances the use of floating point
| functions like pow, sqrt, and exp is likely less efficient than a
| simple iterative solution. For larger instances using bignums as
| output, floating point computations do not even offer an
| alternative.
|
| It's true though that mathematics offers faster integer only
| (e.g. matrix based) methods of computing fibonacci.
| zozbot234 wrote:
| The matrix based method for Fib can be understood as applying
| the closed-form solution over Q(sqrt5). OP seems to miss this
| point.
| mschoenert wrote:
| My thoughts at this point in the original article was:
|
| Well - if you want to demonstrate how mathematics helps here,
| then you should mention that computing the n-th fibonnaci
| number can be computed as the n-th power of the matrix
| [[1,0],[1,1]], and that the most efficient way to compute
| powers (in any associative domain) is the repeated squaring
| algorithm.
| BeetleB wrote:
| Indeed, I kind of stopped reading the article there.
|
| The other issue is his picking on Lisp programmers with this
| example. If you open books on programming using C, it almost
| always will have either the iterative or the recursive solution
| - not the closed for one. So why is he picking on Lisp
| programmers in particular?
| jdkee wrote:
| "Again, no recursion is required as long as one knows that a
| factorial is actually a special case of the gamma function. (The
| implementation of log-gamma is usually a polynomial approximation
| which requires constant time to evaluate.)"
|
| A prime idea behind using recursive techniques is that for many
| complex problems you do not have to know the "special case" as
| you can break complex problems into simpler pieces that can be
| solved via recursion.
| adalacelove wrote:
| I would be surprised if there is not some kind of loop in the
| code that is used to evaluate the gamma function. You can also
| define factorial like for example the number of different
| permutations of any set of a given size.
| texaslonghorn5 wrote:
| outside of edge cases, c++ lgamma (log of gamma) uses Lanczos
| iteration with 8 iterations and gamma is just exp(lgamma)
| adamnemecek wrote:
| I think that the most important idea of math, programming,
| physics etc is the idea of fixed points which is predicated on
| the idea of nilpotence.
|
| Fixed points go by many names like invariance, spectra,
| diagonalization, embedding, braids etc.
|
| By fixed point I mean something like the "Lawvere's fixed point
| theorem".
| https://ncatlab.org/nlab/show/Lawvere%27s+fixed+point+theore...
|
| I have a braindump on this https://github.com/adamnemecek/adjoint
|
| I also have a discord https://discord.gg/mr9TAhpyBW
| layer8 wrote:
| Corrected link:
| https://ncatlab.org/nlab/show/Lawvere%27s+fixed+point+theore...
| adamnemecek wrote:
| Fixed.
| lkuty wrote:
| Point.
| [deleted]
| strangattractor wrote:
| Kind of agree but my argument would be that solving math problems
| exercises the same mental muscles that programming uses and vice
| versa. Doing one improves the other. Saying that it is necessary
| or essential is a false dilemma. They are complementary. Is
| computation mathematically based - that seems obvious. Does
| programming get done despite programmers lack of understanding
| the math of computation - obviously quite a bit.
| cs702 wrote:
| "Writing software" = "writing down math".
|
| Consider:
|
| * "Writing software" means arranging symbols (bits in a machine
| language, UTF or ASCII characters in a high-level language) in
| certain permitted ways, to transform an input sequence of symbols
| (e.g., a stream of byte values representing user actions from a
| video game controller) into an output sequence of symbols (e.g.,
| byte values representing pixel RGB colors for display on a
| screen).
|
| * "Writing down math" (e.g., to prove something, or to solve a
| problem) means arranging symbols ('x', '2', '+', etc.) in certain
| permitted ways, to transform an input sequence of symbols
| (representing mathematical notions) into an output sequence of
| symbols (representing other mathematical notions). Turing,
| Church, Curry, Godel, and many others realized this in the 1920's
| and 1930's.
|
| That said, most self-described "software developers" are
| typically working to solve relatively simple problems for
| immediate practical application, whereas most self-described
| "mathematicians" are typically working to solve highly complex
| problems, often highly abstract in nature, without regard for
| practical application.
| constantcrying wrote:
| Mathematics is not about computation. Certain means of
| arranging computation are entirely irrelevant to mathematics,
| computation is a mathematical tool, not an end.
| cs702 wrote:
| I never said that mathematics "is about computation."
|
| What I did say is that writing down mathematics is equivalent
| to writing software.
|
| Both require the use of a _formal system_.
| constantcrying wrote:
| >I never said that mathematics "is about computation."
|
| But programming is about computation. If mathematics isn't
| about computation as well, then they are not alike.
|
| >What I did say is that writing down mathematics is
| equivalent to writing software.
|
| It is not. That is plainly false. E.g. mathematics
| considers objects which are not computable and makes non-
| computable calculations with those objects. I am aware that
| you can encode certain formal mathematics into certain
| software, but that is like saying cooking is like
| programming because you can encode recipes as a program.
|
| >Both require the use of a formal system.
|
| So what?
| epgui wrote:
| >> What I did say is that writing down mathematics is
| equivalent to writing software.
|
| > It is not. That is plainly false.
|
| Whether the two look the same or not, maths and computer
| programs are in fact fundamentally isomorphic. [1]
|
| [1] https://en.wikipedia.org/wiki/Curry%E2%80%93Howard_co
| rrespon...
| constantcrying wrote:
| >isomorphic
|
| Certainly not every computation is a proof. What
| statement does:
|
| void f(){ printf("?"); }
|
| prove?
| petemir wrote:
| I fear that's a very narrow view of mathematics. Nevertheless,
| most of the time you can see the output of what you created
| while programming, check if it's the correct result, etc. I
| don't think it's like that in math, where you deal in a much
| more abstract realm.
| cs702 wrote:
| "Mathematics" is not the same as "writing down math."
| petemir wrote:
| I stand by what I said, applicable even to proofs, but I
| take your point.
| cs702 wrote:
| :-)
| MontyCarloHall wrote:
| This article misses the point. The Fibonacci/factorial
| calculations are just toy examples to easily illustrate recursion
| to a beginner. Nobody who actually needs to compute them for a
| real application would think that these inefficient, merely
| pedagogical examples would be the way to do it; Lisp hackers
| would have no problem using the closed-form solutions.
| brianyu8 wrote:
| (2012)
| dang wrote:
| Added. Thanks!
| zozbot234 wrote:
| Discussed:
|
| https://news.ycombinator.com/item?id=4796586 (2012, 1 comment)
|
| https://news.ycombinator.com/item?id=4915328 (2012, 133
| comments)
|
| https://news.ycombinator.com/item?id=6953774 (2013, 102
| comments)
|
| https://news.ycombinator.com/item?id=20142828 (2019, 86
| comments)
| Karrot_Kream wrote:
| I used to work on these problems in school all the time, but once
| I decided to join industry I encountered a bunch of these Lisp-
| style engineers who love computation in the abstract but not the
| application thereof. Scala seemed to attract a lot of folks like
| this. Maybe if I had gone into scientific computing I would have
| found more.
|
| I get to use these skills every so often though. When I was
| designing one of our early two-level caches at $WORK, I wrote an
| analysis of chosen TTLs and jitter values by looking at
| microservice latency distributions. I've debugged a nasty
| concurrency issue by modeling it in TLA+ and then fixing the bug
| (full disclosure: once I thought through the TLA+ model, the bug
| was fairly obvious to me, but the modelling itself was the
| valuable exercise.) I've used MILP solvers for capacity planning
| our boxes. I've designed queue backpressure through probabilistic
| analysing. Each of these things has been crucial in designs I've
| used, but I only encounter a problem like this once every some
| years. (And these days I often write more docs than code.)
| kqr wrote:
| I quite frequently encounter code that can be made much faster
| (at no significant loss of value generated) by sampling or
| using other statistical techniques to reduce precision.
|
| Also flows and buffers in the software that can be improved
| with queueing theory. Logic that can be simplified with boolean
| algebra.
| mschoenert wrote:
| The idea that the "Lisp programmers" are somehow adverse to
| mathematics is historically untenable. Macsyma was written in
| Lisp. And Macsyma was one of - if not THE most important
| application for the Symbolic Lisp machines (the ancestor of all
| later Lisp machines). Many later systems (Maple, Mathematica,
| ...) were written by people who would consider themselves
| belonging to the Lisp crowd. For example all of those systems had
| automatic memory management with garbage collection, most had
| closures/lambdas, etc.
| mindcrime wrote:
| I basically hate math discussions on HN. Why? Because it seems
| like there's two (at least) "camps" in terms of how they
| interpret what "math" even means. And the various camps
| constantly talk around each other, with neither camp seeming to
| realize that they're arguing about completely different things.
| So they keep arguing, nobody gets anywhere, and the whole thing
| is largely a cluster-fuck.
|
| So what do I mean by "camps"? Well, the most obvious dividing
| line is between people who see "math" as something that everybody
| does, and that includes everything from elementary school
| addition up to, well whatever, and has a primary goal of
| computing something. Then you get the camp who see "math" as the
| exclusive domain of mathematicians, look down on any maths class
| at a level lower than abstract algebra or real analysis, and
| consider the primary goal of math to be more math (eg, proving
| things that we didn't already consider proven). And the latter
| often tend to look down their noses at anybody who dares talk
| about "learning math" but without a goal of becoming a
| mathematician.
|
| _sigh_
|
| My position is that "math" includes both of those notions, and
| that in most conversational contexts you have to explicitly
| define which one you are talking about up front in order to have
| even a chance at a productive conversation.
___________________________________________________________________
(page generated 2022-12-23 23:00 UTC)