I am almost totally uneducated in programming and computer science in general, though I am really fascinated by these topics. I read that mathematics is important in programming and that nowadays many mathematicians specialise in applied mathematics in this field. So, I wonder how these two branches are linked with each other. What are the fields of mathematics that are useful (maybe unavoidable?) in writing a computer program?
$\begingroup$ This feels rather broad to me, though svick's answer does a good job of explaining how "it depends". One thing to which I would draw attention is that programming and computer science are somewhat separate. A lot of computer science is mathematics, whereas programming is a tool that computer scientists sometimes use (and, conversely, mathematics is a tool that programmers sometimes use). $\endgroup$
Commented Feb 15, 2016 at 23:31$\begingroup$ The relationship of mathematics to programming is the same as the relationship of chemistry to chemical engineering, or physics to mechanical engineering, or, for that matter, art to industrial design. The job of the engineer is to build useful (safe, on time, on budget, etc) systems out of the raw tools of science. For software engineers, that science is computer science and, as David rightly said, that can be thought of as a branch of (or allied art of) mathematics. $\endgroup$
Commented Feb 15, 2016 at 23:42$\begingroup$ The role of mathematics in programming is, in general, nil. On a day-in, day-out basis someone developing software does not use "mathematics" (which I'll define as anything more complex than basic algebra) at all. Now and then you'll need to use something more "math-ey" - but it seldom rises beyond trigonometry. In my career as a software developer I've used calculus TWICE - and in at least one of the cases I could have used trig, but it was easier to use calculus when I recognized that I needed the integral (area under the curve) of a known function. $\endgroup$
Commented Feb 16, 2016 at 2:59$\begingroup$ @Pseudonym "The relationship of mathematics to programming is the same as the relationship of chemistry to chemical engineering, or physics to mechanical engineering" -- I disagree. Mathematics is to CS the way mathematics is to physics. CS is to software engineering the way physics is to mechanical/electrical/. engineering. $\endgroup$
Commented Feb 16, 2016 at 10:51$\begingroup$ @BobJarvis If you've ever written a recursive function and convinced yourself through thinking (as opposed to testing) that it always terminats, you've probably engaged in (informal) mathematics. If you've ever optimized SQL queries, you've probably used rules of relational algebra without realizing you did so. (And that's ignoring that compilers are magnificent works of mathematics, CS and engineering.) $\endgroup$
Commented Feb 16, 2016 at 10:52You don't need any math to write a Hello World or a very simple website.
You will need to know some discrete mathematics and algorithm analysis to write a program that finds a route between two cities.
You will need to know matrix transformations and quaternions to write a game engine.
You will need to know a lot about all kinds of mathematical fields to write the next Wolfram Mathematica.
What I'm trying to say, what fields of mathematics you will need to know and to what degree will depend a lot on what kind of programs do you want to write. But the ones that tend to be most widely useful are data structures, algorithms and their analysis.
answered Feb 15, 2016 at 22:33 1,866 14 14 silver badges 15 15 bronze badges$\begingroup$ This is a good answer. I'd say that probability theory is probably the biggest mathematical subject you've missed, as some understanding of it is essential if you're going to write any kind of randomized algorithm. Those are important because many problems are hard to solve exactly so you have to use some sort of (typically randomized) approximation. $\endgroup$
Commented Feb 15, 2016 at 23:33$\begingroup$ Another big one - encryption relies on mathematical operations of very large primary numbers $\endgroup$
Commented Feb 16, 2016 at 4:32$\begingroup$ Don't forget machine learning often involves probability or regression etc. $\endgroup$
Commented Feb 16, 2016 at 5:26$\begingroup$ Thank you and thank you all for the answers. I am just approaching to the world of programming which fascinate me quite a lot though. I am going to post another question, more specific, with an example of I program I would like to try to write as an exercise. $\endgroup$
Commented Feb 21, 2016 at 18:21 $\begingroup$You pose two questions.
Quite fundamental. It is the universe of computers and programs. I mean no exaggeration. It describes the framework in which they exists. It provides the tools to analyze computer programs, e.g. it is used to prove the correctness of computer programs, completeness, all sorts of other properties. It is important to know that a program will work as expected, or will finish. Even a simple "hello world". You can really break it down and prove it, to the logical level. There are formal definitions of what a program is, and what a computer is.
Unavoidable? None. Just as you don't need physics and engineering to build simple stuff.
Useful? Depends, and opinionated. The beauty of it is, to abstract and reuse tools. Some people create algorithms, some people use them to write libraries, some people use them to write services or games. Math is useful on a pretty low level, unless it is directly related to the task that a program is solving.
I would say, that fields that give a nice set of general soft skills useful for programming are logic, combinatorics and algebra, because they develop the ability to complex abstract thinking, organize things and transforming problems. I'd say skills that are very useful in seeing a "bigger picture". It's always nice to spot common functionality, reduce complex problems/tasks and avoid caveats as a programmer.