Login
You're viewing the mstdn.social public feed.

Replies

  • 💬 1🔄 2⭐ 17
  • 💬 0🔄 1⭐ 3
  • May 6, 2026, 2:35 PM

    @shana that, and equations over planes also implicitly translate into loops over each value of the plane

    that's basically what made maths finally click for me

    💬 1🔄 0⭐ 0
  • May 6, 2026, 4:15 PM

    @xerz If only someone had just put a couple of for-loops as footnotes in my school texts! It would have been such a time saver.

    💬 0🔄 0⭐ 4
  • 💬 0🔄 0⭐ 2
  • May 6, 2026, 2:52 PM

    @shana not really for loops. In math a sum can and often does go up to infinity, whereas a for loop cannot do that.

    As an analogy to convey some information is fine, I'm just reminding that it ain't the same thing.

    💬 2🔄 0⭐ 4
  • May 6, 2026, 2:58 PM

    @nyx @shana while not quite a for-loop, in lazy languages that have bignums, you could yield partial sums forever, at least until your sum grows to millions of digits

    💬 3🔄 0⭐ 3
  • May 6, 2026, 4:22 PM

    @hjvt hey, why have one for-loop when you can have Parallel.ForEach() and turn *all* your cpu cores into one toasty personal heating unit!

    💬 0🔄 0⭐ 2
  • May 6, 2026, 6:22 PM

    @hjvt @shana that is cute but still very far from infinity. And you can't do it forever, at least not according to our current understanding of the universe. You only have until heat death, and even if you did it until then you would be nowhere near infinity.

    💬 1🔄 0⭐ 1
  • May 7, 2026, 6:26 AM

    @nyx @shana
    Ok? That's not really different from maths though. You can't evaluate the whole infinite series, but you sure can do useful work with one as an object

    💬 1🔄 0⭐ 0
  • May 7, 2026, 6:58 AM

    @hjvt in math you absolutely can evaluate the whole series. That makes it different already.
    And yes there are cases on which they align and that's why I said that as an analogy it is fine. But saying that they are the same is like confusing a map for the actual terrain or like mixing physics with actual nature.
    You cannot put math in a computer, you can only put a series of instructions to read and write from and to a finite binary register. Some things in math can be represented that way, others things can be approximated, and yet others can't. And even when you can it is a representation, like that of a map with respect to actual terrain. A very useful one, there is no denying in that. The ubiquitous presence of computers all around the world is a testament to that fact. But they are different things.
    I have nothing against harnessing the educational power of analogies to help learners, but I think the statement in the original image "are just" is an oversimplification which potentially denies the reader the full beauty of the sigma notation for sums in math, and that's why I wanted to add a little extra.

    💬 1🔄 0⭐ 1
  • May 7, 2026, 7:01 AM

    @nyx you can't evaluate an infinite sum, unless your definition of evaluation includes analytical realization that the sum is in fact infinite.

    💬 1🔄 0⭐ 0
  • May 7, 2026, 7:19 AM

    @hjvt I'm not sure why you say you can't. Here is an example from a math textbook.

    Infinite series of 1/2 to the power of n starting at n=1, the result is 1.
    💬 1🔄 0⭐ 0
  • May 7, 2026, 7:31 AM

    @nyx well that's the thing, that doesn't fit my, a not-mathematician computer guy, definition of "evaluation". Yes, you can prove that that sum converges to 1, but you very much do not do that by straightforwardly evaluating it term by term.

    💬 1🔄 0⭐ 0
  • May 7, 2026, 8:13 AM

    @hjvt yeah, that's the beauty of math. You don't "evaluate" term by term, you sum all of them simultaneously. Actually doing it term by term can lead to problems.
    That's another reason why the sum in math and the for loop are not the same thing

    💬 0🔄 0⭐ 0
  • May 7, 2026, 7:24 AM

    @hjvt @nyx @shana Great, now I am nerdsniped into pondering when a compiler can justifiably terminate what is by spec an inftinite loop into an analytical result.

    💬 1🔄 0⭐ 0
  • May 7, 2026, 7:37 AM

    @chrysn @nyx @shana damn, that's an interesting thought.
    IIRC, it would actually be permissible for a C++ compiler to do this, since infinite loops without side-effects are UB by spec.

    💬 1🔄 0⭐ 1
  • May 7, 2026, 8:11 AM

    @hjvt @nyx @shana That's the UB I was thinking of. For the compiler to make that jump, I think the loop still needs a break condition, like "if next == last", otherwise, the compiler would just mark the whole branch as unreachable. With ffastmath or equivalent, a compiler could trust that the sequence converges, and apply analytics such that 1.0+2.0+3.0+... = -1/12 or 1.0+0.9+0.81+... = 10.0, even when due to rounding it might not actually converge.

    💬 0🔄 0⭐ 0
  • May 6, 2026, 4:13 PM

    @nyx Super nitpickity, if you don't have a stop condition, a for-loop will happily go on until the death of the universe (or your pc, whichever comes first)

    But in general, the sigma is the abstract definition, the for-loop is a possible concrete implementation of that definition, in a language that the target of this PSA (non mathy programmers) can understand and go "oooh ok I get it now". It would have saved me like half a semester if someone had shown me this up front, no other words needed.

    💬 1🔄 0⭐ 4
  • 💬 0🔄 0⭐ 0
  • May 6, 2026, 4:38 PM

    @nyovaya @nyx Of course, that's neither the point of the infinite summation nor the point of the translation of the math notation into the for-loop.

    The point is that there is a translation from the notation to a computer language format that allows a person not versed in maths to understand the underlying concept of the math notation in an intuitive way, as a starting point. If you can't understand what sigma does at its most basic, you cannot understand its actual math purpose as a whole.

    💬 1🔄 0⭐ 3
  • May 6, 2026, 6:30 PM

    @shana @nyovaya I did recognize that it is fine as an analogy! And I added extra information because I think there is beauty in nuance.

    Also if you think that is nitpicking, oh boy you haven't dealt with math enough 🤭
    Look, I'll use an analogy: math is like programming in that you get one symbol wrong and your whole program/theorem doesn't compile.

    💬 1🔄 0⭐ 3
  • May 6, 2026, 6:41 PM

    @nyx Oh yeah that's a good analogy! You're totally right, it's way more subtler than this, and the for-loop can never be a complete translation.

    I just don't think the detail of the infinity or stopping conditions is where the analogy visibly breaks down because you can always mimic those details in the translation and it *looks* like it still works. The breakage is more fundamental than that (declarative vs evaluated etc), and I was just amused by what got picked up as the gotcha.

    💬 1🔄 0⭐ 1
  • May 6, 2026, 6:44 PM

    @nyx I was expecting someone to point out that you can just omit a starting point in the sigma notation, because it doesn't necessarily need one because it's not really a linear evaluation mechanism, which would completely shatter the silly programming analogy and bring the whole house of cards down! 😝😅

    Alas.

    💬 1🔄 0⭐ 0
  • May 6, 2026, 9:23 PM

    @shana yeah, you can also start your sum at negative infinity and end in positive infinity. Also sums can become integrals in some limit scenarios, and I'd like to see you try to use a for loop to sum infinitely small pieces all the way from minus inf to plus inf. 🤭

    💬 0🔄 0⭐ 1
  • 💬 1🔄 0⭐ 0
  • 💬 0🔄 0⭐ 1
  • 💬 0🔄 0⭐ 0
  • 💬 1🔄 0⭐ 1
  • 💬 0🔄 0⭐ 1
  • May 6, 2026, 4:12 PM

    @shana when I was doing the maths parts of my degree, I very quickly realised that maths notation is the problem with why maths is difficult.

    Borring from the field of computer science to remove all the greek characters that often have multiple uses [1] and rename operators with descriptors could make it way more accessible.

    [1] Okay this is mainly astrophysics's fault that one equation used sigma in both cases for three different things.

    💬 1🔄 0⭐ 1
  • May 6, 2026, 4:24 PM

    @tautology That might have been why my high school math teacher made me promise I would not go into maths in exchange for a passing grade.

    I ended up in computers instead which totally has no maths whatsoever!

    (in hindsight, not the best maths teacher)

    💬 1🔄 0⭐ 3
  • May 6, 2026, 5:18 PM

    @shana Mine told me outright that I would fail A-level math[s] (in the UK, the exam you take at 18 before you leave school).

    More fool him: I scraped a decent grade and have now (decades later) done math[s] modules at degree level.

    Unless, that was his plan all along, to try and shame me into putting some effort in?

    💬 1🔄 0⭐ 2
  • 💬 0🔄 0⭐ 1
  • 💬 0🔄 0⭐ 0
  • 💬 0🔄 0⭐ 1
  • May 6, 2026, 8:06 PM

    @shana I think the reverse take is more powerful: some loops can be avoided if you have a closed mathematical form for them.

    And as someone else noted when quoting this post, for loops imply an ordering, the mathematical operation does not.

    Plus, loops are just one form: generators are another, and the fact that

    \[\sum_{i=0}^{m} f(i) = \sum_{i=0}^{n-1} f(i) + f(n) + \sum_{i=n+1}^{m} f(i) \]

    means that generators are really another option.

    💬 0🔄 0⭐ 0
  • 💬 0🔄 0⭐ 0
  • May 6, 2026, 9:29 PM

    @shana @arclight I have managed to get as old as I am without having ever come across the capital PI product thing. And I did physics and astro physics at uni and a masters.

    💬 1🔄 0⭐ 2
  • May 6, 2026, 11:15 PM

    @cyberspice yeah, I think I've seen it in passing but never actually engaged with the thing at all, zero clue what it meant until Freya's post tbh :-P

    💬 0🔄 0⭐ 1
  • May 7, 2026, 7:12 AM

    @shana It’s like seeing the sheet music for the first time, even though you’ve been playing the song in your own band for years 😅

    💬 0🔄 0⭐ 0
  • May 7, 2026, 9:39 PM

    @shana Nobody has pointed out the most important* difference, which is that one is very painful to write on a chalk board, while the other is very painful to write on a teletype.

    *well...

    💬 0🔄 0⭐ 0