r/ProgrammerHumor • • Oct 06 '21

Don't be scared.. Math and Computing are friends..

Post image
65.8k Upvotes

2.4k comments sorted by

View all comments

Show parent comments

998

u/nuclearslug Oct 06 '21

This would have been so helpful when I was talking calculus

406

u/[deleted] Oct 06 '21

Yeah, once I realized these are just for loops, the notation made way more sense.

231

u/uhmhi Oct 06 '21

But most of the interesting ones loop to infinity…

145

u/Cat_Marshal Oct 06 '21

It’s while loops then

91

u/OnyxMelon Oct 06 '21

or for loops with a bad exit condition

for (int i = 0; i >= 0; i++) {}

113

u/CodeLobe Oct 06 '21

Or the crying emoji for loop:

for ( ; ; ) { ... }

9

u/supersharp Oct 07 '21

"I forbid you to use while (true)!"

"..... Okay!"

→ More replies (3)

11

u/[deleted] Oct 06 '21

That will exit if your int wraps; hard code to true instead

9

u/[deleted] Oct 06 '21

I think this is the better answer because noone would be able to have the time or memory to repeat something to true infinity.

→ More replies (2)

23

u/Potatolimar Oct 06 '21

You can do that in a for loop (or at least represent it the same way we represent manually adding with these notations)

→ More replies (1)
→ More replies (9)

23

u/[deleted] Oct 06 '21

Integrals are like an infinite summing for loop

20

u/decerian Oct 06 '21

Not really, because a lot of summations also go to infinity. Integrals are continuous compared to the for-loops discrete nature, so there's no direct analog for them in programming (that I'm aware of)

12

u/[deleted] Oct 06 '21

Well its summing up infinitesimally small units of something typically. They can be approximated by making the "infintesimally small units" larger (and thus discrete).

→ More replies (6)

5

u/[deleted] Oct 06 '21

It's not really possible to do in a for loop because you wouldn't use a for loop usually without some other domain beyond a monotonically increasing counter. Most integrals I've come across in programming involve some sort of time domain so you are just taking the delta as the discrete period and summating those (which I guess is the same as just summating any arbitrary linear function to describe the curve of the integral). I mean you still only have the resolution of your timer but it usually is within whatever you're trying to accomplish in accuracy.

→ More replies (1)
→ More replies (12)

5

u/MinusPi1 Oct 06 '21

It's more like

for(int n = a; n <= b; n += 0.000000...01){...}
→ More replies (2)
→ More replies (4)

0

u/[deleted] Oct 06 '21

[deleted]

→ More replies (5)

80

u/[deleted] Oct 06 '21

Yeah holy shit how was this not taught to me? I got Cs in all three levels of calculus and shit like this would have helped me immensely.

31

u/theGoddamnAlgorath Oct 06 '21

I just realized I've been writing Nashian models for decades to to sort peoples photos.

Holy shit

→ More replies (4)

23

u/gobblox38 Oct 06 '21

The biggest issue with calculus for most people is that it is taught in an abstract way. That's math in general though. I didn't really understand calculus until I took physics where I had real world applications for calculus.

I later took a scientific computing class where we revisited sums, series, methods, etc. and wrote code (matlab) that applied these concepts. And sure, a lot of these concepts have functions built into Matlab, but the point was to show how these functions work, what their shortcomings are, and how to determine when an approximation is good enough (ie how many steps into Taylor's series are required and when does more steps give no additional benefit).

5

u/Polar_Reflection Oct 06 '21

Exactly. A minority of us enjoy abstraction for the sake of abstraction. A good teacher will try to motivate the abstract concepts with real life examples that speak to the student. I'm lucky to have been blessed with absolutely great math teachers until I reached university (I'm still upset at my integral calculus teacher in college who spent an entire 90m lecture deriving the fundamental theorem of algebra on the board to "explain" partial fraction decomposition, before telling us he did it for fun and we didn't have to know any of it for the purposes of the course).

→ More replies (5)

43

u/TheoryOfSomething Oct 06 '21

As someone who did math first and programming later and has also been a teacher, it would never occur to me to teach it this way. I do not understand why this is any simpler than teaching it as repeated addition.

24

u/[deleted] Oct 06 '21

In this case it just helps me conceptualize it as something that makes a little more sense. Code makes more sense to me than math as I'm not great at math, so it's basically just taking a concept and converting it to something I would understand better.

I mean in these two series, particularly the summation, it's easy enough and I don't think I had any struggles there. I did, however, have struggles with your higher-level series dealing with more complex subjects such as a Ramanujan series. I didn't understand Ramanujan at all until I had a programming course ask me to write one, and then it actually made a good bit of sense.

→ More replies (7)
→ More replies (14)

0

u/[deleted] Oct 06 '21

[deleted]

6

u/Judge_Syd Oct 06 '21

I was taught that it was a summation and I really don't see how that could be confusing at all tbh but everyone learns differently so....

→ More replies (11)

12

u/ajswdf Oct 06 '21

For non-programmers it could end up being a lot more confusing.

→ More replies (3)
→ More replies (7)
→ More replies (18)