DEV Community

Arik
Arik

Posted on • Originally published at creactiviti.com

That programming book you never finished

Books

Tell me if this sounds familiar:

You walk into a bookstore, browse through some shelves and run into a programming book about a subject you always wanted to learn. Maybe it was about machine learning or algorithms or some other cool technology.

You read the back cover, the intro and you get really psyched. You think to yourself: "I think I can really get this". And, "when I'm done with this book I'm gonna have super powers" and "I'm gonna show the guys at work what a rock star I am" etc.

You get home, open the book that is about to change your life and 20 pages into it you're starting to fall asleep after seeing one too many mathy squiggly thingies.

Then you start thinking some other thoughts, such as "oh, not math again!" And "I'll never get this, I suck at math!" And "I guess I'm just stupid" and other such nonsense.

If I had a dollar for every time...anyway.

So I'm here to tell you that math has a dirty little secret that will help you get through these books: mathematicians like to use big scary words and symbols to describe small and simple concepts.

Let's look at an example. Chances are you ran into the scary looking Sigma symbol:

Sigma

I don't know if it's because it's big or because it looks like Egyptian hieroglyphs, but something about that symbol freaked me out the first time I saw it. But it turns out that it's almost idiotically simple.

Sigma simply means "sum up" or "add up". What do you sum up? The thing on the right (i*2 in this case). And you do that starting at the number below the Sigma (i=1 here) until the last number designated above the Sigma (100 here).

So this particular Sigma equals to:

1 * 2 + 2 * 2 + 3 * 2 ... + 100 * 2 = 10100
Enter fullscreen mode Exit fullscreen mode

So the easiest way for me to think about Sigma is to think of it as a for loop, where the lower boundary of the loop is specified under the Sigma and the upper boundary of the loop is specified above the Sigma. Here's how it would look like in python:

def sum(i):
  s = 0
  for n in range(1,i+1):
    s = s + (n*2)
  return s
Enter fullscreen mode Exit fullscreen mode

I know, it's almost disappointingly simple.

This may sound like over-simplifying the situation. That some math concepts are just impenetrable and beyond mere mortals grasp. Well if that's the case then I haven't ran into it yet.

On the other hand, this is not a "get math quick" scheme either. To understand these math concepts you'll sometimes have to drill in to other concepts that the original concept builds on β€” recursively. This can take hours, days or more to accomplish, depending on the concept.

But the point is the same. It's just fancy words and symbols. And as long as you keep going down that rabbit hole using dictionaries, tutorials, videos, whatever you can get your hands on, to define these words and symbols, you'll eventually get it. Try it sometimes.

Happy learning.

Top comments (12)

Collapse
 
billcarverdev profile image
BillCarver

Based on the opening, I was looking for strategies on finishing books.

Collapse
 
saviobosco profile image
Saviobosco

Me too

Collapse
 
itsjoel29 profile image
itsjoel29

I was expecting the same U_u

Collapse
 
allecto profile image
Paula Hasstenteufel

Yes.

Collapse
 
sgsfak profile image
Stelios Sfakianakis

Personally I would think the following is the exact translation in Python of the math formula shown in the article:

  sum(2*i for i in range(1, 101))

(well... if you ignore the fact that the upper limit of range in not inclusive so I need to put 101 instead of 100)

So now that you know about Sigmas etc. you can read The Art of Computer Programming ;-)

Collapse
 
brandonarnold profile image
Brandon Arnold • Edited

Try reducing computation by finding a closed form instead of writing a loop. Here, the closed form is f(n) = n*(n+1) (e.g. f(100) = 100*101 = 10100):

f(n) = S[1..n] 2*i     definition
     = 2 * S[1..n] i   pull out the coefficient
     = 2 * n*(n+1)/2   by triangular number formula
     = n*(n+1)         cancel the twos
Collapse
 
jgamgam profile image
Joaquim

Not the topic I expected, bit was a nice read anyway.

Collapse
 
cben profile image
Beni Cherniavsky-Paskin

github.com/Jam3/math-as-code is a "cheatsheet" explaining tons of math notation by showing equivalent JavaScript code, similar to how this article explained Ξ£.

Collapse
 
benfaught profile image
Benjamin Faught • Edited

Mathematical Notation: A Guide for Engineers and Scientists
I bought this little jewel just for this situation:
amazon.com/Mathematical-Notation-G...

Collapse
 
dothtm profile image
dotHTM

*Greek…

I πŸ’– Math.

Collapse
 
clsource profile image
Camilo

I recommend this site brilliant.org for math and science stuff :)

Collapse
 
willrieske profile image
WillRieske

Misleading headline. But now high school math is coming back to me...