
Ask HN: What are some important math topics every programmer should know? - 1_player
I&#x27;m a self taught full stack developer who&#x27;s flunk out of high school and did not have the chance to study &quot;advanced&quot; maths such as calculus, statistics and probability.<p>In 10 years of experience I never felt the need for any of it, and a recent contract requires, for a simple feature, the basic knowledge of derivatives (given a polynomial curve, graph it in a dotted line when it falls off from the local maxima).<p>I&#x27;ve started catching up on courses on Khan Academy and having a great time. My question is, which math (or physics) knowledge have you actually used in your programming career, and think it&#x27;s mandatory for software engineers to know?<p>PS: If anyone from Khan Academy is reading this, thank you for your project, you&#x27;re doing a great service for humanity.
======
Someone1234
Every programmer should know? None.

Middle school maths is "good enough" for the majority of programming jobs
(85%+). There are of course niche programming jobs in: finance, statistics,
AI, CS, gamedev, and so on but if you look at the programming industry as a
whole those jobs are a tiny proportion overall (the majority are "boring"
enterprise-style developers and web-developers: Java/Tomcat, ASP.net/MVC, PHP,
RoR, and so on).

The thing is that the "boring"/average programming jobs are the silent
majority. You'll likely read in this thread tons of obscure topics and how
they apply to obscure jobs, but the reality is that few programmers work in
those industries, but nobody [else] is going to post just to admit that for
their job they don't need any maths day to day because it is boring and
redundant.

This is JUST my opinion, but if you want to learn obscure topics, you're
better off spending time learning CS topics (e.g. floating point number
representation/bugs/limitations, encryption/hashing/etc, binary
representations, assembly, kernel inner workings, CPU inner workings, and even
borderline electronics). While advanced maths has a place in some jobs,
advanced CS topics seem to be useful even on the web-stack/enterprise-stack to
understand where bottlenecks might be materialising.

Maths is not useless. But most programmers won't use a lot of it day to day,
if for no other reason that they have a library which does it for them (and
they'd be foolish to reinvent the wheel).

~~~
rickhanlonii
Every _good_ programmer should know? At least abstract Algebra.

The thing about advanced maths is that it forces you to think about
abstractions in ways that not even programming forces you to think. You can
get pretty far programming without much abstraction, but you can't understand
the mathematical fact that any group of order four is either cyclic or
isomorphic to the Klein-four group[1] without thinking in a really abstract
way. The more you study these abstractions in advanced maths, the better you
get at thinking in an abstraction-first way.

A great book that just came out this year explains this really well by taking
you from a basic algorithm to an abstract implementation, explaining the maths
along the way (from multiplication to abstract algebra and number theory).
It's titled From Mathematics to Generic Programming and I recommend it to
anyone who wants to understand more of what I mean[2].

\--

[1]: [http://math.stackexchange.com/questions/165341/any-group-
of-...](http://math.stackexchange.com/questions/165341/any-group-of-order-
four-is-either-cyclic-or-isomorphic-to-v)

[2]: [http://www.amazon.com/Mathematics-Generic-Programming-
Alexan...](http://www.amazon.com/Mathematics-Generic-Programming-Alexander-
Stepanov/dp/0321942043)

~~~
j2kun
There are many ways to learn about abstraction, and abstract algebra is not
the only one. I.e., assorted facts about groups are mostly irrelevant, and if
you can learn how to think abstractly by studying, say, graph theory, why
would you need abstract algebra?

~~~
insoluble
I completely agree. Logic or philosophy can help one to practice complex
abstraction. Even the study of law (as in legal code) or religion involves
abstract thinking.

------
ColinWright
I've used a _lot_ of math in my work. But the point is, I _have_ a lot of math
to use. So many people say "I've never used math" or "Oh look, another day
without using algebra," but really what's happening is that they don't realise
that there are times when they can use mathematical thinking and techniques.

It's blub all over again.

So to be specific, I've used calculus in a bunch of places, Linear Algebra,
Markov Chains, Quaternions, Topology, and Graph Theory is just everywhere.
It's impossible to make recommendations - there's far too much, and what you
need to do is get started on something, and keep track of things that look
like they'll be interesting, useful, or the basis of something needed.

In part this is why I've started the "Topics In Maths" project I'm working on.

So good luck - keep pursuing stuff, and I hope you get more and more intrigued
by what you find.

~~~
RogerL
This is really important. I've seen so many people just thrash at problems
because they did not have the math to solve it. It's not so much that they
didn't take the course or whatever, but that they didn't even understand that
there was a systematic way to find the answer.

You _almost_ can't be a programmer these days without knowing about data
filtering and validation. And I can't tell you how many ad-hoc ways I've seen
people try to filter data that was worse than useless - it harmed the quality
of the data.

So, linear algebra, robust statistics, optimal and non-optimal estimation, and
some classification theory will take you a very long way in many jobs.

If this isn't clear - PageRank (the original google search algorithm) is just
applied linear algebra. Netflix recommendations? Linear algebra. Spam
filtering? Bayesian filtering. Medical imaging? linear algebra, Bayesian
filtering. It goes on and on.

Math is not mandatory to be in the field, but there are a vast number of
really interesting jobs which you have no hope of doing without a fair amount
of math.

This is why I feel so sad when yet another "college is for suckers" thread
starts on HN. It takes a lot of concentrated work and practice to develop the
math skills and to learn to apply them, and college is the last chance you
have to do that in a concentrated way. You just might learn about eigenvectors
and invent the next PageRank!

graycat always has interesting posts about how he has used in his career - do
a search.

~~~
j2kun
Linear algebra also allows for things like

Facial recognition, error correction/detection, linear programming
optimization, signal analysis, graphics, machine learning, quantum
computing...

The list just goes on and on.

------
mathattack
The tough part here is "every programmer should know" as there are very few
universal "Must Knows". Much of CS theory is math so there is a lot to be said
for "You're learning Math whether you think so or not."

Some general comments on math topics:

Partial Differential Equations - Useful for financial technology and
engineering applications.

Statistics - Extremely useful in financial technology and marketing
applications. (A/B testing, etc) Also good for having an informed worldview.

Regression Analysis - Same as Statistics, though less important for having an
informed worldview.

Logic - Whether you call it Philosophy or Math, it's useful in hardware,
formal verification, and general thinking.

Linear Algebra - Good for financial technology and machine learning.

Set Theory - Good for understanding databases.

Number Theory - Useful for cryptography.

Graph Theory - Great for networking, and algorithm thinking in general.

Theory of Functions - Good for understanding recursion (LISP, Scheme, etc) and
functional programming.

Does anyone need to know all of this? No, but learning the math behind
whatever niche you choose will make your intuition and thinking stronger. I
think Stats is the only general purpose math that everyone should understand
as part of being a critical thinker.

~~~
chris_wot
Logic and set theory are intertwined.

~~~
BasDirks
Set theory and everything are intertwined.

~~~
ska
Categorically.

------
jerf
High school and even undergraduate college gives you a rather late-19th,
early-20th century view of what "math" is. A lot of math doesn't involve
"numbers", per se. So, as a programmer in your self-described situation, my
advice is to work through the math in Structure and Interpretation of Computer
Programs [1], commonly referred to as SICP, and to do so seriously.

Does it not feel like math? That is, alas, a deficiency in your education, but
don't feel bad, it's a deficiency in most people's education. It's math, and
directly applicable to what you are doing in life.

Now, these other suggestions are fine too. But I find it to be very, _very_
practically useful to be able to take apart the very concepts of computation,
and thereby learn how to reassemble them to suit my whims, and not be swept
away by the fads of the day.

The SICP is a concentrated load of exactly what you missed out on by not
getting a formal computer science education. I honestly would likely prefer
someone with 3 or 4 years of industry experience and the ability to prove they
really worked through the SICP (not just read over it once, but worked it
through) over someone with a 4.0, a bachelor's degree, and nothing else.

[1]: [https://mitpress.mit.edu/sicp/full-
text/book/book.html](https://mitpress.mit.edu/sicp/full-text/book/book.html)

------
rcheu
There's a course at MIT called Mathematics for Computer Science (6.042). It's
available on Open Courseware, [http://ocw.mit.edu/courses/electrical-
engineering-and-comput...](http://ocw.mit.edu/courses/electrical-engineering-
and-computer-science/6-042j-mathematics-for-computer-science-fall-2010/)

------
meeper16
Bottom line: You're constructing and executing math and likely do not realize
how much math you are constructing and executing on a daily basis. This
includes formal and experimental advanced theoretical mathematics,
probability, statistics and number theory in some cases. Some academics do not
like to hear this, however, you deal(industry term) in functions, variables,
minimums, maximums, rates of change, statistics, probability and overall,
symbols. If you're duplicating the next facebook (as facebook did with myspace
and myspace, friendster, etc etc), snapchat or yo app your likely not directly
engaged in much math or innovation compared to inventing something on the
algorithmic level like Google. If you are creating or inventing something new
on the software engineering level including the algorithmic level, then you
are certainly creating a lot of theoretical math and perhaps without even
knowing it. This is key.

Here's a good book to understand how you've leap-frogged certain aspects of
mathematics via true and real innovative Computer Science: (the Einstein of
India. Every country and family has their very own Einstein, you might be one
of them.)

The Man Who Knew Infinity: A Life of the Genius Ramanujan
[http://www.amazon.com/The-Man-Who-Knew-
Infinity/dp/067175061...](http://www.amazon.com/The-Man-Who-Knew-
Infinity/dp/0671750615)

------
Bahamut
I find understanding of symbolic logic to be very important.

For UI programming of any sort, an understanding of basic geometry is very
important, including graphing. There have been times in my short career where
I have had to implement pixel perfect renderings due to the types of problems
that were being solved.

------
kvcc01
I work in quantitative finance and find that basic probability and statistics
help a lot in this field. In fact, they are almost like prerequisites for
hiring.

That said, I think everyone would benefit by reading a bit about these
subjects, whether or not they’re developers. We seem to have a built-in
tendency to underestimate the effect of randomness in life (see Fooled by
Randomness and How to Lie with Statistics). To counteract that, I find
statistical methods (e.g., hypothesis testing, confidence intervals, etc.) to
be very useful tools to keep in mind. Having basic familiarity with such tools
may not necessarily make us better programmers but it'll probably make us more
rational decision makers in the general sense.

------
serve_yay
DeMorgan's laws. (You'll probably end up negating a boolean expression at some
point. Don't screw it up!)

~~~
1_player
All the comments in this thread are really useful (thanks, everybody), but you
finally gave me a name for something I badly need when refactoring
overcomplicated "if" expressions.

I usually get a pen and paper and write the truth table by hand to understand
how to simplify the logic.

Thanks!

------
davnicwil
In the first year of my CS degree we studied some rudimentary CS-related
mathematics.

Some of it I barely used beyond the exam, but there are two topics which rise
high above the rest in terms usefulness when working on real-world web apps.

Set Theory:
[http://en.wikipedia.org/wiki/Set_theory](http://en.wikipedia.org/wiki/Set_theory)

and

Combinatorics:
[http://en.wikipedia.org/wiki/Combinatorics](http://en.wikipedia.org/wiki/Combinatorics)

I can't tell you how useful these branches are in terms of the indirect and
direct positive influence they have your thinking about how you organise and
process data. Which at the end of the day is the core work of most web apps.

Even the very basics will help you greatly, remember I'm talking about first
year CS courses here!

------
mcdevhammer
Depends on the industry I suppose. I work in the financial industry and I have
used linear algebra quite a bit and graph theory as well. I would say linear
algebra in pretty important as it is also used heavily in graphics/games.

------
logfromblammo
_Every_ programmer should be able to convert between decimal, binary, and
hexadecimal notation, and be able to understand the bit-shift and bitwise
operations. That's it. Programming is too diverse a field for any one branch
of mathematics to be required for all of them.

Many fields require linear algebra, geometry, trigonometry, graph theory, and
discrete math.

Graphics and 3D-modeling programmers will need to know matrices (possibly also
quaternions) and vector math. You may also need screw theory and geometric
algebra.

Engineering support will need to know calculus.

AI will need probability.

Scientific support will need statistics.

Cryptography will require all the maths that exist, plus some that haven't
been invented yet.

Business support will need to know sexagesimal math--for the clock-watching.
You will really need to know when 5:00 rolls around, so you can stop working
on your stupid CRUD app.

In short, the more math you know, the more likely it is that you will able to
apply it to any given program. And the more you know, the easier it will be to
pick up something you need and don't have already. Practically speaking, you
are better off seeking a shallow knowledge of a broad array of disciplines,
and deepen your knowledge of specific topics as needed.

If you know imaginary numbers, that makes it easier to learn about duals,
quaternions, null vectors, spacetime manifolds, and such.

------
petewailes
Background: I do a lot of work with apps at scale, so dealing with really big
sets of data, and doing maths on it. With that in mind, I'm biased towards the
maths that I use, but I'll try and be broader and as unbiased as I can be.

1\. Statistics. There's so much you can do with a really solid understanding
of the basics of statistics, it's silly. It's massively helpful with things at
scale where you get into difficult caching challenges, systems with multiple
data sources and estimating data accuracy, informing based on partial or
sampled data... Really useful stuff.

2\. Geometry. You'd be amazed how many problems there are that exist in n
dimensional space. A good grounding in geometry will let you understand how
lots of systems work. For instance, autocompletes tend to be solved nowadays
by calculating distances between input shapes and words in n dimensions, where
different stopping points add an extra dimension. Also really helpful when you
start dealing with complex data systems.

3\. Interesting algebra. Mostly if you understand code, you'll pick this up
pretty quick. Lots of philosophical similarities.

Beyond that, it depends on what fields you want to go in to as you can get
really specialised. But whatever you write, knowledge of those three will
always be handy.

------
bbcbasic
Binary numbers (1010 it's off to work we go!)

Boolean logic.

How numbers are encoded in binary. How ints, doubles, floats, etc. work under
the hood on a computer. Can be learned on the job.

------
fsk
Starting with the easiest:

boolean logic, boolean algebra

What does O(n) mean?

The compound interest formula

matrix/linear algebra, numerical analysis

The statistics behind A/B testing

numerical approximation of a derivative, integral, differential equation

Read "numerical recipes in C"

------
aout
Don't learn anything specific but be sure to be ready to learn everything when
needed. I had to learn linear algebra when I was a 3D engine developer, then I
had to learn statistics (or maybe learn to understand the notations of it so I
could use scientific papers in my work).

In the end I think it was best not to have lost hours, days, weeks of my time
on things I "could have used". I find it best to be prepared to learn
anything.

------
loumf
My first two jobs out of college were in FinTech -- lots of math there
(partial derivatives, linear algebra, numerical analysis methods, stats and
more)

Then later, I was in image processing -- a lot of linear algebra. Anything
with recognition has mathematical concepts.

I'm tutoring a teen in game programming and keep having to take breaks to
teach more and more trig.

Having a good grasp of probability and statistics will serve you in almost
anything you do.

------
viggity
Best math class I took in college was discrete math, it is extremely
applicable to computer programming.

[http://en.wikipedia.org/wiki/Discrete_mathematics](http://en.wikipedia.org/wiki/Discrete_mathematics)

Highlights include Combinatorics, Set Theory, Graph Theory, etc. Great stuff,
I liked it so much I kept the book even though the book store offered me $80
for it.

------
panic
Like other commenters have said, it depends a lot on what programs you're
writing. You might want to know some harmonic analysis if you're writing audio
software. On the other hand, if you're making user interfaces, knowing a
little bit of geometric math (vector algebra, trigonometry, calculus) can go a
long way.

------
DIVx0
The jobs I've held have not been particularly 'mathy' but knowing linear
algebra, numerical analysis and statistics have come in very handy over the
years.

Knowing how to 'read' math has been helpful digesting Computer Science papers
too.

------
pscheyer1
Tl:dr- In order; graph theory, linear algebra, number theory, and multi-
criteria decision analysis. Game theory, set theory, nonlinearity,
computational geometry a bonus.

Let's say you're learning some new algorithms. Your list might look something
like the below list[1]. I'll add in brackets the sort of math you learn about
by learning the algo if you get lost down the wiki-rabbit-hole. If you want to
solve other similar problems, more of that sort of math will help.

1) Graph algorithms [graph theory]: Breadth first search(BFS), Depth first
search(DFS), Strongly connected components(SCC), Dijkstra, Floyd-Warshall,
Minimum spanning tree(MST), Topological sort.

2) Dynamic programming [self-similarity, finite subdivision rules, nonlinear
equations]: Standard dynamic programming problems such as Rod Cutting,
Knapsack, Matrix chain multiplication etc.

3) Number theory [Number Theory]: Modular arithmetic, Fermat’s theorem,
Chinese remainder theorem(CRT), Euclidian method for GCD, Logarithmic
Exponentiation, Sieve of Eratosthenes, Euler’s totient function.

3) Greedy [goal programming, simplex algorithm, multi-criteria decision
analysis]: Standard problems such as Activity selection.

4) Search techniques [linear/vector algebra[2]]: Binary search, Ternary search
and Meet in the middle.

5) Data structures (Basic) [graph theory]: Stacks, Queues, Trees and Heaps.

6) Data structures (Advanced)[more graph theory]: Trie, Segment trees, Fenwick
tree or Binary indexed tree(BIT), Disjoint data structures.

7) Strings [set theory]: Knuth Morris Pratt(KMP), Z algorithm, Suffix
arrays/Suffix trees. These are bit advanced algorithms.

8) Computational geometry [computational geometry]: Graham-Scan for convex
hull, Line sweep.

9) Game theory [game theory]: Basic principles of Nim game, Grundy numbers,
Sprague-Grundy theorem.

[1] [http://blog.hackerearth.com/2013/09/competitive-
programming-...](http://blog.hackerearth.com/2013/09/competitive-programming-
getting-started_11.html) [2] Scott Aaronson noted that the vector algebraic
Eigenvector operation was the linchpin of google's pagerank, when applied to
the adjacency matrix of the directed graph that is the world-wide web. So i
assume that knowing some vector algebra might be useful for search.
[http://www.scottaaronson.com/blog/?p=1820](http://www.scottaaronson.com/blog/?p=1820)

------
Animats
You need much more math to survive in the field beyond the appcrap/webcrap
level. Here's the description of a 3D SLAM library for robotics. This is what
looks at an image from a moving camera and builds a map of where the camera is
and of its surroundings.

 _" RobotVision is a library for techniques used on the intersection of
robotics and vision. The current version (1.1) comprises bundle adjustment,
feature initialisation pose-graph optimisation, and 2D/3D visualisation among
other things.

The bundle adjustment class follows the classical approach - the first order
sparseness structure is exploited using the Schur complement. However,
compared to other straight-forward implementations, it has the following
features: The second-order sparseness structure -- not all landmarks are
visible in all frames - is exploited using sparse Cholesky factorisation
(using the CSparse library). Optionally, the implementation supports the use
of robust kernels in order to guard against spurious matches. Also, the
implementation generalises over different transformations, landmarks and
observations using template meta programming. Among others, SE3 pose
transformation with 3D Euclidean points and 2D image observations are provided
as a default implementation for monocular SLAM. Furthermore, the bundle
adjustment class also contains an information filter for inverse depth feature
points which can be used efficiently for feature initialisation within a
keyframe-based monocular SLAM framework.

The pose-graph optimisation framework is using Levenberg-Marquardt, whereas
the sparse Hessian is dealt with using sparse Cholesky factorisation
(CSparse). Again, it generalises over different transformations. Apart from
the standard rigid transformation SE3, it also supports 3D similarity
transformations Sim3. In other words, it can also deal with scale drift which
occurs in monocular SLAM.

Both, the bundle adjustment class as well as the pose-graph optimisation class
uses Lie theory. Poses transformations (SE3, Sim3) are represented on a
manifold/ as a Lie group while incremental updates are done in the tangent
space around the identity/Lie algebra. In this way, we achieve a minimal
representation during optimisation while ensuring that we are always far from
singularities."_[1]

That's only some of what it takes today to do robotics.

The world is about to change. Tomorrow, everyone will discover that powerful
humanoid robots are here.[2]

[1]
[https://openslam.org/robotvision.html](https://openslam.org/robotvision.html)
[2]
[http://www.theroboticschallenge.org/](http://www.theroboticschallenge.org/)

------
brudgers
Graphs.

~~~
1_player
Good call.. I had to learn them when I was building a Bitcoin arbitrage bot,
and how to implement the Bellman-Ford algorithm.

Also, any game programmer worth his name needs to understand them for
pathfinding algorithms (A*, Dijkstra, etc.)

~~~
brudgers
What is a program but a directed graph?

------
4ydx
If you don't understand set theory, you cannot possibly be a programmer. That
is to say, whether or not you realize you are applying set theory, it is the
heart of programming.

~~~
AnimalMuppet
Set theory is the heart of programming? I call BS. Can you provide a
foundation for that statement?

And no, I'm not coming from "category theory is the heart of programming",
either.

------
echeese
Sometimes I feel like I should have paid more attention in class, like when
looking at an expression and wondering if it could be simplified or if all the
parens are really necessary

------
fartbrain
I work in digital advertising (sorry, world), and use linear algebra often.
... I suck at it, so I usually get somebody with a math degree to help me out.

------
gcanti
set theory, equivalence relations, partial and total orders, algebra (monoids,
lattices, ...), graphs

------
bencollier49
Modular arithmetic. Big-O notation.

------
IndianAstronaut
Understanding stochastic processes has helped me quite a bit in my data mining
career.

------
justonepost
Ai/data sciences uses a lot of partial derivatives, linear algebra, etc

------
drostie
You've got a lot of different answers, here, so I want to raise a question in
your head instead: what, exactly, are you categorizing as _math_? I have been
an academic, an engineer, and a backend-and-frontend web developer. As an
academic, many of the professional mathematicians that I know cannot count a
tip. One of the better definitions that I know of what they do is "creating
art out of abstract patterns themselves." But computers are defined in terms
of their manipulation of abstract symbols, so _any_ programming is in this
sense some form of mathematics. More on that in a little bit. So the question
is, what do you mean by "math" here?

Do you mean _calculation_? Then you need to understand how exponents work, the
ballpark figure that 2^10 is about 10^3, that there are roughly 10^5 seconds
in a day, roughly 10^-1 seconds in your reaction time, and roughly 10^9 things
that your computer can do per second. So continuous things need to happen in
less than 100 million operations, and, say, an O(n^2) algorithm will top out
at sizes where n is around 10,000. That's the sort of arithmetic that you'll
want to keep in your head, the mathematics of exponents. The computer will
handle explicit calculations for you, but rules of thumb are unbeatable.

Maybe you mean the more "engineering math" topics. Some pieces of
combinatorics may help you -- at minimum, knowing that if N people at a party
shake hands, there are N * (N - 1) / 2 handshakes, which is also the number of
cells above the diagonal in an NxN matrix and the sum of the integers from 1
to N - 1. (All of this should make sense if you stare at it long enough.) This
simple principle underlies the "birthday paradox" math, that if you start
randomly selecting values out of N, you'll start to see random collisions
(selecting the same value) when k^2 / 2 is approximately N, or k = sqrt(2N).
So, for example, you know that if you have a playlist with 50 songs on it, the
gap between repeated songs is usually about 30 minutes (sqrt(2 * 50) * 3
minutes / song), and you'll need a smarter shuffle if you want it to be closer
to the (3 minutes) * 50 = 150 minutes that some users may be expecting.

You should ideally also pick up factorials (and maybe Stirling's approximation
of them), choose-functions, and the trick of randomly partitioning B balls
into G groups by looking at binary strings pretending that 0's are balls and
1's are group partitions, hence the strings are of length B + G - 1 and the
number of strings is the same as choosing B out of B + G - 1. Those sorts of
patterns come up in a lot of different programming contexts, especially
because a good hacker can often live by the axiom, "try brute force first" \--
knowing these rules will help you know how bad your programs are with respect
to scaling.

A lot of engineering trickery is obscenely useful when you're writing computer
programs, too: for example, engineers learn that when they know the _form_ of
something but not the _exact_ expression, they should make sure that the "edge
case" lines up. The _simplest_ example is when you're counting up on a
0-indexed array, what's the last element you read? If you've not memorized it,
just say, "oh, if the array had one element, the last index I'd read is index
0, so the exact form must be `n - 1`." If you're programming a rotation, you
might say, "Oh, this thing needs to be something like r * [± cos t, ± sin t]
... but which one is the cosine, which is the sine, are any of them plus or
minus?" you can answer this question pretty quickly if you know what the
answer is for t = 0, where sin t = 0 and cos t = 1.

Somewhere at the border between engineering math and true math is linear
algebra. You do not need linear algebra in all circumstances, but it can
enrich many circumstances and is required for a lot of them. If you're doing
graphics, physics, simulations, probability/statistics, solving simple
equations, or trying to solve linear relations, the techniques learned in a
first-year linear algebra course will be invaluable and some of the vocabulary
will stick with you.

The fundamental ideas of calculus -- like "let's tweak the inputs a little and
see how the outputs change, maybe it's roughly linear", or "why don't I store
this as a list of differences between adjacent elements?" can be quite
helpful, and in fact the "derivative" operation has a powerful analogue in
functional programming (a data structure's "zipper" turns out to be its
derivative), and occasionally you actually need to optimize things, but this
is less applicable than other branches of mathematics.

Is what you mean by "math" more abstract than calculus? At that even more
abstract level we get some serious goodies. It turns out that there is a deep
connection between mathematical models of the integers and useful data
structures, if you can figure that out. Various algebras can be super-helpful,
for example the patch-commutation algebra in the Darcs version control system,
and the relational algebra underlying SQL. Learning a bit of lambda calculus
can help you understand things on a whole new level. Finally, some basic
thinking about propositional logic can really help to elevate your knowledge
above simple boolean expressions, so that you can start to think of "foralls"
and "there-exists" symbols, especially when you start to talk about type
theories or logic programing.

More important than all of that, in my experience, is really knowing your
languages from the ground up. You don't need to be any of these to be a copy-
paste programmer: copy a file which does something like what you want, tweak
some parameters which look interesting, constantly monitoring the output of
the program until it passes the tests that you want to accomplish. That's
going to be the most common job out there. But if you know your language's
operators and reserved words and syntactic forms in-and-out, you can do
something far better -- _abstraction_ \-- which will make your code far more
useful in the end. But the thing is, if mathematics is making art out of
patterns themselves, then programming language design is also, somewhere, a
field of mathematics: and learning this is a sort of "math", too. There is a
"math" of parsing. You can even find libraries of "parser combinators" \-- you
might want to watch some talks explaining how those work. Similarly, there is
a "math" to really understanding pointers and graph traversals and such.

I've seen people who have your "10 years of experience" and have never seen
any of those things and don't really understand, for example, JavaScript's
scope rules. They write fairly good code, but it can often be much, much
smaller -- and faster and easier to maintain. So to me, that's the key first
step. Understand a couple different languages from the ground-up, and how they
approach the world.

------
bkjelden
Set theory & basic boolean algebra (De Morgan's laws, etc).

------
j2kun
I'm deeply devoted to mathematics, and even I admit that you don't _need_ any
math beyond boolean logic and arithmetic to have a successful career as a
programmer.

The rest of this comment is a pitch.

All that being said, I have found that a little bit of math makes programming
_way more fun._ I've been writing a blog called "Math Intersect Programming"
[1] for four years now, and it's turned into a little catalogue of cool things
you can do with math. While linear algebra suffices for a lot of these
applications, the rabbit hole goes pretty deep past calculus and basic
statistics. The central skill I've found useful is simply learning to read
mathematics in a productive way (it's not like any other kind of reading
you've ever done before, though if pressed I'd say it's closest to reading
dense software documentation).

In image processing, you can cleverly manipulate graphics [2], make "hybrid
images" [3] and digital watermarks [4], and do procedural content generation
[5].

While we all know graphs are ubiquitous in algorithms (searching, ranking,
data structures, etc), you can also do fun things like finding communities [6]
and turning "hard" computational problems into neat games [7] (or vice versa).

You can do cryptography and cryptanalysis [8], hunt serial killers [9], share
secrets [10], compute cheap and healthy diets [11], design markets [12],
detect and recognize faces [13], and all sorts of other things (my blog just
has examples I happen to think are fun, ignoring many examples that are
actually lucrative).

More generally by studying math you learn to tell what problems should be
attacked with what tools. You learn that any time anything exhibits symmetry
it should be studied with groups [13]. Or that with some elbow grease you can
solve lots of problems (like register allocation) by doing graph coloring [14]
or linear programming [11] or some basic Fourier analysis [15]. The more you
learn the more you get to think about, like "the shape of data" [16].

And before you know it you're like me and you think algorithms with elegant
mathematical analyses are beautiful and worth studying for their own sake. You
give up your overpaid software career, get a PhD in math, and wonder if you'll
ever have enough time to learn everything you want to know.

[1]: [http://jeremykun.com/](http://jeremykun.com/)

[2]: [http://jeremykun.com/2013/03/04/seam-carving-for-content-
awa...](http://jeremykun.com/2013/03/04/seam-carving-for-content-aware-image-
scaling/)

[3]: [http://jeremykun.com/2014/09/29/hybrid-
images/](http://jeremykun.com/2014/09/29/hybrid-images/)

[4]: [http://jeremykun.com/2013/12/30/the-two-dimensional-
fourier-...](http://jeremykun.com/2013/12/30/the-two-dimensional-fourier-
transform-and-digital-watermarking/)

[5]:
[http://en.wikipedia.org/wiki/Perlin_noise](http://en.wikipedia.org/wiki/Perlin_noise)

[6]: [http://jeremykun.com/2014/05/19/community-detection-in-
graph...](http://jeremykun.com/2014/05/19/community-detection-in-graphs-a-
casual-tour/)

[7]: [http://jeremykun.com/2014/03/17/want-to-make-a-great-
puzzle-...](http://jeremykun.com/2014/03/17/want-to-make-a-great-puzzle-game-
get-inspired-by-theoretical-computer-science/)

[8]: [http://jeremykun.wordpress.com/2012/02/03/cryptanalysis-
with...](http://jeremykun.wordpress.com/2012/02/03/cryptanalysis-with-n-
grams/)

[9]: [http://jeremykun.com/2011/07/20/serial-
killers/](http://jeremykun.com/2011/07/20/serial-killers/)

[10]: [http://jeremykun.com/2014/06/23/the-mathematics-of-secret-
sh...](http://jeremykun.com/2014/06/23/the-mathematics-of-secret-sharing/)

[11]: [http://jeremykun.com/2014/06/02/linear-programming-and-
the-m...](http://jeremykun.com/2014/06/02/linear-programming-and-the-most-
affordable-healthy-diet-part-1/)

[12]: [http://jeremykun.com/2014/04/02/stable-marriages-and-
designi...](http://jeremykun.com/2014/04/02/stable-marriages-and-designing-
markets/)

[13]: [http://jeremykun.wordpress.com/2012/12/08/groups-a-
primer/](http://jeremykun.wordpress.com/2012/12/08/groups-a-primer/)

[14]: [http://jeremykun.com/2011/07/14/graph-coloring-or-proof-
by-c...](http://jeremykun.com/2011/07/14/graph-coloring-or-proof-by-crayon/)

[15]: [http://jeremykun.com/2012/05/27/the-fourier-transform-a-
prim...](http://jeremykun.com/2012/05/27/the-fourier-transform-a-primer/)

[16]:
[http://www.ams.org/notices/201101/rtx110100036p.pdf](http://www.ams.org/notices/201101/rtx110100036p.pdf)

~~~
1_player
Those are really interesting articles! Thanks, hope to see more from you.

------
logicallee
Well, a lot of computer science literally _belongs to_ math, as in, is a
strict subset of math. (Including the words I just said, see, about subsets.)

Specifically, a lot of computer science belongs to "discrete mathematics",
(because there are discrete states not a continuous interval of possibilities,
but still math). so even for everything where you thought you were just
learning computer science - when you look at sorting, trees, big-O complexity,
correctness, graphs, one-way functions, lexical parsing, network theory,
control systems, error handling, compression, etc, you're really just ...
straight-up doing math, _by definition_. (or using a library, compiler,
operating system, network stack, database engine etc, etc, etc, by someone who
has.) I mean that it is literally the field of mathematics. Like when you
remove two 'not' in a row you are just straight-up literally doing math.

So firstly, I would say that these are just some of the things that are
directly used by people practicing computer science, even if only second-hand
-
[http://en.wikipedia.org/wiki/Discrete_mathematics](http://en.wikipedia.org/wiki/Discrete_mathematics)
\- As well as the more specific, Oh, I heard it's impossible to evaluate
whether a function will terminate... oh...I heard you can't compress random
data at ALL on average... oh the shannon limit means we could never get that
much data across this channel... wait, can you get the signal back after a
fast Fourier transform - of course! that's what an inverse fourier transform
does.. ... can a simple regular expression match if parentheses are matched
and only correctly nested - answer: not a REGULAR one -
[http://stackoverflow.com/questions/133601/can-regular-
expres...](http://stackoverflow.com/questions/133601/can-regular-expressions-
be-used-to-match-nested-patterns) etc. etc.

you see this stuff everywhere. but you just look it up and do it - well, it's
math! basically all of the 'theoretical' stuff is. so it's not so much about
finding parts of 'math' that a computer scientist should know...it's about
realizing that most what you use (right down to boolean logic) is strictly
math to begin with. you're _literally_ (not metaphorically) doing math every
single day, all day, every time you negate a boolean before returning it.

reasoning about database opreations? straight-up set theory.

so it's like your real question is, what is the math that I would find useful
if I learned it? And the answer is - as a computer scientist, "computer
science" is the math that you would find useful if you learned it . . .

the other stuff, like geometry or calculus, is interesting but a red herring -
in a way they could be considered the application logic. your calculus
equations are only useful if your functions implementing them bother to ever
return a value... you can hardly write two loops without at least thinking
about time complexity. bam, math. _all the rest_ of computer science is math
too. everything you do every day. it is just part of mathematics. so go ahead
and learn more math - what part? the "computer science" part :)

------
antoyo
Functors and monads!

