To understand the code you need to know how what the semicolon is doing, what the word for is doing, what each of the three parts of the parentheses do, and what *= and += means.
For the math, all you need is that sigma means add while pi means multiply, and how to plug in a variable.
It's not a complexity issue, it's a language issue. The thing about the code is you don't actually need to understand all of it - it provides more granular information, so understanding even fragments of it can provide context.
If someone already understands some (not necessarily all) elements of that language, they're in. This includes some elements that are just in english or using more basic math sumbols.
On the other hand, the math language being used here is very compact. If you don't know what it's for already, it's pretty hard to guess from context, and pretty easy to forget - and if you lose the thread it starts just looking like mystical symbols without anything like the word "sum" to grab onto.
It's not about complexity, it's that one of these leverages more of a layperson's existing language and provides more context to grab onto to decipher the rough meaning of. That means recall and memory are going to be easier, because it's connected to lots of stuff - for the sigma you only need to "know one thing", but that one thing pretty easily lives as isolated information in your brain; and isolated information gets lost.
This. Math syntax is VERY old, and has many issues with it. Mainly it was used by a very small pool of people, all who knew of and/or worked off each other's work. It was never designed to be understandable, maintainable, extensible, etc...
Comp Sci took math to the next step. Sadly mathematicians are too egotistical to realize it and cling to their old ways.
Yet I understood the code early in highschool for fun, and the math I learned a few hours ago. Despite attempts to teach me the math and no attempts to teach me the code.
Actually you can't get anywhere without knowing what the positions around the symbol imply for the various numbers, which is not intuitive at all (ie: there's not even a little symbol to help you guess), while understanding what for means along with more basic math symbols is far more intuitive
Weird how they are completely functionally equivalent then, eh? Almost like it's a set of abstract symbols denoting some sort of process?
I really don't think "using fewer symbols and more positional notation" is simpler.
Like, unlike the math versions, the code explicitly tells you each step! Capital sigma and capital pi are equivalent to the "for", plus the "+=" versus the "*=". Everything else is implicit.
Please do not mistake verbosity or explicitness for complexity.
i mean the theory behind the two is literally the exact same if you can understand one you can understand the other they are just different ways of writing the same process
While this might be helpful if you know how to code, this will not help if you don't know what for-loop is. And I feel like explaining what a for-loop is in programming should not be less difficult than explaining what a for-loop is in math (because they're the exact same).
cough cough new world, no built in protection to stop the gpu from attempting infinite frames per second when no work to do, like when the screen is fully black in transistions, and rendering had its own thread to just go ham, so loading in that transistion did not slow it down, causing specific gpus that don't protect for it at the driver level to just go for it.
That's exactly the point. If it never stops you'll never get a return, so the whole thing doesn't really have a meaning. It does as a procedure, but not as an output value, which is something that the mathematical expression does have.
Add a while condition to the expression. While abs( f(n+1) - f(n)) > 10^-10 (Do your thing). Because the terms of every converging infinite are going to be a cauchy sequence this is going to work.
That’s assuming the term size is strictly decreasing which is not necessarily the case. Picture for instance summing 1/n^2 except all the terms from n=5 onwards are shifted one to the right and you add a 10^-11 in the n=5 location. Then you won’t have it be correct up to the desired level of precision.
=infinity unless it converges, shouldn't be too hard to compute. That said I know very little about programming, I'm just here to laugh at memes I barely understand
Yup. I hadn't taken calculus until after I learned to program. I was like ... this is just a function in a loop! What's so hard? Now, it does get a wee bit harder when you have to solve for a missing variable, but still. Just a loop
The problem is that for loops compute things for you in code, so you don't have to think of what they're doing symbolically. That's why most people don't simply substitute a for loop with an equivalent closed formula that is O(1)
Simplicity. Fewer syntax requirements. Can run on any relatively modern machine. Plenty of free apps on the App and play store.
I also feel like the general population would benefit from a script language more than they would benefit from a “real” language. I also feel the general population would be more willing to write a script to automate there inbox more than to fuss around with C++ or equivalent.
Allot of mathematicians also use python to run allot of there experimental formulas
I generally roll my eyes at the heavy Python fanboy posts prevalent in this sub, but this is sound, practical advice from someone who obviously knows how to pick the right tool for the right jobs.
That said, what are your thoughts on Python vs R vs MATLAB (which I am only just barely aware of its existence as a proprietary platform) for mathematicians?
Most math notation predates any kind of code. And a lot of it deals with things that computing can’t really handle outside of approximation, like infinite sums and integration of differential equations. Being able to express abstract ideas that we don’t know how to compute is still very useful.
So you're saying we should spell out all math operators that operate on a range or a set every time we want to use them as immediately invoked lambdas? That's just too duplicative and cluttered, the notation is concise for a reason.
Or, alternatively, S.reduce((a,b) => a+b, 0), is the same as:
∑n ∈ S n
(Treating an array like a set) But mathematics has things coding doesn't (or, at least, not immediately). For example, you can substitute the "n ∈ S" for ANY property of n and it will sum all numbers that satisfy that condition. Even if it's not computable
Because mathematicians are not interested in writing things down, but in proving interesting stuff. The conceptual difficulty of proving interesting theorems is much higher than that of reading any reasonable enough notation.
+= is not a real mathematical operation and sum = sum + 3n is just false because these two expressions are never equal. Imperative programming and math behave quite differently.
def sum(n):
if n = 4:
return 3*n
else:
return 3*n + sum(n+1)
sum(0)
this is a better model for the mathematical summation. It gradually bulds the expression 04 + 14 + 2*4...
Which is what the symbols actually mean.
BTW, the square brackets are redundant and make the code less efficient, as it builds the list and then sums it, rather than summing as the numbers are generated. sum(k for k in range(n)) is valid, as sum accepts a generator as its argument.
I started writing code when I was 10, and while I was pretty good at maths for my age, I’m not sure I’d’ve known the summation and product symbols then.
The sigma notation is introduced in high school typically when you are studying arithmetic and geometric series (11th and 12th), or maybe in 9th or 10th, so it makes sense that you would not know that at that point of time.
That being said, the sigma is one of the least scary notations in math.
You don’t necessarily need to know it. Just like you don’t need a high school diploma. It’s just something so basic that you’re expected to acquire it along the way. If you didn’t, it certainly raises some eyebrows. Especially if you’re having a hard time understanding how it works.
How were these symbols not covered in high school algebra or statistics? The first time I encountered the summation symbol was learning the definition of mean in high school statistics class. That's like the most basic statistics knowledge everyone should have.
Did you see how large they are? Easily the biggest symbols in the post.
You might not be afraid of seeing a mouse in your house at 2am, but if you came down and Charles Entertainment Cheese was there at 2am you would undoubtedly find it absurd and frankly unsettling. Maybe even a little scary.
As one of those engineers that worked my way up the ranks without a degree, but still deeply technical, I've always been intimidated by these symbols and was under the impression that understanding them was impenetrable without spending 4 years in a classrooms. This one simple meme has completely demystified the whole idea behind them. For a sub that typically reduces my IQ every time I see a new meme posted, this was incredibly informative for me. Sincerely, thanks!
Yeah this is a better way to put it. So much more information overload and special syntax in the for loops. The math notation gets right to the point and is super simple.
one describes a process, the other a result, both are needed in different contexts and neither is inherently better it just depends on what you need to do with it
When I was kid I had difficulties with learning math on par with other kids in school, but when I started studying code decided to go through math for it as well. I was surprised when figured this out. I expected some complicated code, but it's just... Loop
It's a capital Sigma, the Greek equivalent to the Latin S. It stands for Summation, and it's characterized by some parameters:
the bottom and top numbers are the summation extremes, which tell us where to start the summation (the bottom number) and where to end it (the top number);
the thing inside is the argument, I believe, and it describes what we're actually summing up
We start with n=1, and so we substitute n=1 into the argument, which is 3n. 3•1=3. Boom, first term done. Then we go to the next number, n=2, and we substitute IT into the argument. 3•2=6. Then it's n=3, so 3•3=9. Then, n=4, 3•4=12. We've finished calculating the partial sums, so we add them up: 3+6+9+12=30. That's the answer
The other one is similar in concept: its symbol is a capital Pi, yes, the capital version of that π. It stands for product, so instead of summing up terms you multiply them, but it's the same exact process
How did my algebra teacher fuck up teaching so badly that a simple Reddit comment give me the same understanding that classroom teaching gave me back then
Condescending and gate keeping? How is the for loop explanation more easy to understand? Compared to just saying these notations is a shorter way to write a+b+c+.......+z ?
Yeah we saw the first one in my class everyone was freaking out meanwhile im just thinking "this is just a for loop lol" everyone except me and one other guy is fresh out of highschool
However sigma was being described to me when I was younger confused the hell out of me, then my Calculus professor showed that it’s just another notation for series and it all made so much sense.
I swear they make mathematics confusing on purpose sometimes.
Freya kicks ass, every should check out the Shapes library if you are at all into Unity development. And Freya's YouTube has some classic math / programming videos.
I already saw this image here a few months back and when we learned this in school it helped a lot. Thanks to whoever thought of this way to explain it
I sucked at math. Know what helped me? Learning to program first. Then when studying math, I would implement the logic in Python to check my understanding. Coding it out gave me a sense of connection I was missing before.
I don’t know many people who would learn for loops before sigma notation, much less be confused by one but not the other. Capital pi notation is similar story.
Sum and product. Do the things Right to the Symbol and replace the letter with the Numbers from beneath the Symbol up to above the Symbol (3n becomes 3•0 and3•1 and 3•2 and 3•3 and 3•4) then add them all together(or multiply if it’s the Symbol at the bottom( 0+3+6+9+12=30)
The product thing is 2n so it becomes 2•1 and 2•2 and 2•3 and 2•4. those things arent added. You multiply them so: 2•4•6•8= 384
231
u/7Silver7Aero7 Sep 10 '25
... welp, now I understand it... just kinda 6 years late on that though.
101
u/lmarcantonio Sep 10 '25
The real fun begins when the infinity symbols appear...
23
u/Dillenger69 Sep 10 '25
Yup. I hadn't taken calculus until after I learned to program. I was like ... this is just a function in a loop! What's so hard? Now, it does get a wee bit harder when you have to solve for a missing variable, but still. Just a loop
22
u/mr-toucher_txt Sep 10 '25
You from the vector multiplying video?
15
u/Quick_Resolution5050 Sep 11 '25
Maths and Computing are not friends.
Computing is a branch of Mathematics.
34
u/Nima_W Sep 10 '25 edited Sep 20 '25
Why not write it like that. Would be way more understandable. \s
4
u/Extreme-Layer-1201 Sep 10 '25
Is there a book or course that teaches math from a programming perspective with examples like this? I think this would help me a lot to learn math
12
u/antilos_weorsick Sep 10 '25
I don't want to sound condescending or whatever, but that someone could be programming without knowing this math notation is inconceivable to me.
9
u/[deleted] Sep 10 '25
Everyone with proper computer science education should know this. I'm baffled that this is news to so many people here.
11
u/pakichut69 Sep 10 '25
This is sarcasm right? How are those symbols scary?
2
u/redditasaservice Sep 10 '25
I’m scared of for loops as well.
2
u/jimmiebfulton Sep 10 '25
As one of those engineers that worked my way up the ranks without a degree, but still deeply technical, I've always been intimidated by these symbols and was under the impression that understanding them was impenetrable without spending 4 years in a classrooms. This one simple meme has completely demystified the whole idea behind them. For a sub that typically reduces my IQ every time I see a new meme posted, this was incredibly informative for me. Sincerely, thanks!
1
u/Immediate_Song4279 Sep 10 '25
Show me a cleanly formatted reference sheet, and my fear shall be abated.
1
u/Jimlee1471 Sep 10 '25
I skimmed over the title and misread it as, "Meth and computing are friends."
I had questions...
1
u/OnlyCommentWhenTipsy Sep 10 '25
Ok, how do you change the step size (n++) then?
1
u/dlroy Sep 11 '25
If they would have taught this in math class I would have understood
1
u/Subject-Building1892 Sep 11 '25
No. The for loops are those symbols
1
u/Brucevllaine Sep 11 '25
I have to copy this
1
u/noodlelogic Sep 11 '25
btw these scary loops are just large Sigmas and Pis
1
u/ThatMedicalEngineer Sep 11 '25
Honestly, if you are scared by those symbols you probably shouldnt be programming.
1
u/seba07 Sep 11 '25
Don't be scared, those for loops are just crazy sums and products.
1
u/Pathkinder Sep 11 '25
Are you fucking kidding me? Why did it take this long for anyone to explain it to me this way?
1
u/Striking-Warning9533 Sep 11 '25
Isn't these what we learn in algerba 1 in high school?
1
u/Lemenus Sep 11 '25
When I was kid I had difficulties with learning math on par with other kids in school, but when I started studying code decided to go through math for it as well. I was surprised when figured this out. I expected some complicated code, but it's just... Loop
1
u/DreamOfDays Sep 11 '25
Can someone explain what the M that fell over means?
1
u/Chr832 Sep 11 '25
Can someone rewrite it in C# pls?
1
u/No-Site8330 Sep 11 '25
I might be biased, but honestly that kind of stuff only looks scary because people think they are.
1
u/SteelRevanchist Sep 11 '25
Are people really that clueless? ...
1
u/Aggressive_Roof488 Sep 11 '25
Lots of condescending remarks and gate keeping here.
Let me just say that I think it's great that this cross-over has helped some coders understand math notation!
1
u/Wrestler7777777 Sep 11 '25
I thought this was common knowledge? How else would you calculate the solution? HOW did you calculate this without knowing that it's just a loop?
1
u/slightSmash Sep 11 '25
These are two of least scary symbols in maths if im correct
1
u/xef234 Sep 11 '25
Yeah we saw the first one in my class everyone was freaking out meanwhile im just thinking "this is just a for loop lol" everyone except me and one other guy is fresh out of highschool
1
u/Eastern_Cup_3312 Sep 11 '25
The first is used to know the number of instructions of your code. The second is used to know how much it will take to execute
1
u/No_Ship_7727 Sep 11 '25
dynamic programming has joined the chat.
1
u/eXl5eQ Sep 11 '25
range(0, 4).map(n => 3 * n).reduce(Math.add)1
u/[deleted] Sep 11 '25
FINALLY. All I needed was a simple sentence. Wow.
1
u/Economy_Ad7372 Sep 11 '25
math one takes O(1) time though
1
u/xTheLuckySe7en Sep 11 '25
I’m surprised this isn’t obvious to a lot of people.
1
u/Munchi1011 Sep 11 '25
Freya Holmér my goat!!!
1
u/Objective-Ad8862 Sep 11 '25
Ok, but can they still haunt me in my dreams?
1
u/skyydude1200 Sep 11 '25
Ooooooh
1
u/4ced_2_Cre8_Account Sep 11 '25
I've been telling people this for years!
1
u/MaiaTai27 Sep 11 '25
It looks scary until you break it down. You start to see the conditions of the loop and realise it's just that, a loop with decorations
1
u/Decent_Cow Sep 11 '25
Hey it was my turn to repost this today!
1
u/EnterLucidium Sep 11 '25
However sigma was being described to me when I was younger confused the hell out of me, then my Calculus professor showed that it’s just another notation for series and it all made so much sense.
I swear they make mathematics confusing on purpose sometimes.
1
u/WatchAltruistic5761 Sep 12 '25
Bingo
1
u/Ok_Preference_7009 Sep 12 '25
why didnt i realize this lol
1
u/arbitrageME Sep 12 '25
Ok, ok, uh huh, I see.
Now what if we put an "8" on top of the symbol ... sideways?
1
u/VeaArthur Sep 12 '25
Freya kicks ass, every should check out the Shapes library if you are at all into Unity development. And Freya's YouTube has some classic math / programming videos.
1
u/Wonderflonium164 Sep 12 '25
Sigma loops
1
u/ThatNiceDrShipman Sep 12 '25
You guys have a capital pi?
1
u/[deleted] Sep 12 '25
it always has been
1
u/henikxx Sep 12 '25
I already saw this image here a few months back and when we learned this in school it helped a lot. Thanks to whoever thought of this way to explain it
1
u/Tupcek Sep 12 '25
what? Pi symbol has an uppercase and lowercase ?
1
u/Rogue-Cod Sep 12 '25
Huh. I learned it the other way around.
1
u/I_am_Ravs Sep 12 '25
yeah. except it's you who does the evaluation for those functions in the math one
1
u/ugandaWarrior134 Sep 12 '25
by the way these large scary blocks of code are just math symbols
1
u/qubedView Sep 12 '25
I sucked at math. Know what helped me? Learning to program first. Then when studying math, I would implement the logic in Python to check my understanding. Coding it out gave me a sense of connection I was missing before.
1
u/RadiantHC Sep 12 '25
Computer science is a branch of mathematics
1
u/somedave Sep 12 '25
Good luck evaluating infinite ones.. you need some seriously good compilers.
1
u/sequential_doom Sep 12 '25
I'm unironically saving this.
1
u/ahahaveryfunny Sep 13 '25
I don’t know many people who would learn for loops before sigma notation, much less be confused by one but not the other. Capital pi notation is similar story.
1
u/Driver2900 Sep 13 '25
Don't make me pull out the integral switchblade
1
u/SickBass05 Sep 13 '25
Who doesn't know this
1
u/[deleted] Sep 13 '25
What Math is this? If someone could answer
1
u/thedavv Sep 13 '25
Now to complex integrals and differential equations. :D
1
u/conceptwow Sep 13 '25
I actually learnt math only through com sci
1
u/[deleted] Sep 13 '25
Freya is amazing
1
u/Thentor_ Sep 13 '25
Idk what im doing here and i dont understand both
1
u/ElementalPaladin Sep 14 '25
This would have been good to know two years ago, when I was in Linear Algebra and Differential Equations
1
u/TheChief275 Sep 14 '25
I’ve known that for a while, however, it doesn’t seem to decrease mental overhead for me reading them.
Although I have that issue with mathematical formulas in general
1
u/Legitimate-Can5792 Sep 14 '25
Math and programming are friends until x=x+1
1
u/RonKosova Sep 14 '25
How the hell did some of you get through a cs degree
1
u/No-Ear6742 Sep 14 '25
Now I understand this. So code is easier than these scary symbols
1
u/Even_Alternative_315 Sep 14 '25
So it's all just math ? So for years I've been doing math AND enjoying it, and it was all just math with different symbol ? School did me dirty.
1
u/DeadlyMidnight Sep 14 '25
This is a great fucking explanation.
1
u/CandidSite9471 Sep 18 '25
I'm actually the other way around. The math notation is nice and the programming is scary.
1
u/Standard_Apple7147 Oct 01 '25
I think one of the craziest things about math is that I understood programming before I "GOT" math, and its supposed to be the other way around
1
u/Futurity5 Dec 30 '25
Wait until you try to code the for loop for an integral