# Learn Math Via Programming?

April 13, 2009 4:59 PM Subscribe

I have always been horrible at math, but somehow a great programmer. I have found that writing a computer program that demonstrates a certain mathematical concept enables me to better understand the concept. I'm a psych major and I brought this up once in the research lab I've been working in. My prof said he recalls that someone did research and/or created a system in which a student writes a computer program that is pertinent to a certain mathematical concept and upon completion is given the regular math problem (as it would appear in a math class). This enables the student to better understand the math problem, solve, and learn math. Has anyone heard of this or anything similar? A learning system such as this would be a blessing to my education.
Thanks.

I consider myself to have the very same problem. I would love to find a learning system based on the approach you describe, but I'm not currently aware of anything similar to that. One specific example I might suggest is to read about the history/development of the Processing language. The 2 inventors wanted/needed to create a programming language that would appeal to both analytical thinking programmers and to visual thinking artists.

posted by jmnugent at 5:24 PM on April 13, 2009

posted by jmnugent at 5:24 PM on April 13, 2009

This is just another way of saying that to really understand something, you need to be able to teach it.

- Following along in class is one level of understanding

- Being able to apply what you've learned to solve few problems is another

- Being able to teach someone else how the system works is even harder.

When you're programming, you're essentially teaching the computer. To do so, you have to understand the approach quite well.

posted by chrisamiller at 5:33 PM on April 13, 2009 [4 favorites]

- Following along in class is one level of understanding

- Being able to apply what you've learned to solve few problems is another

- Being able to teach someone else how the system works is even harder.

When you're programming, you're essentially teaching the computer. To do so, you have to understand the approach quite well.

posted by chrisamiller at 5:33 PM on April 13, 2009 [4 favorites]

Jeff "Coding Horror" Atwood recently covered this topic in his article Should Competent Programmers be "Mathematically Inclined"?

posted by furtive at 5:33 PM on April 13, 2009 [2 favorites]

posted by furtive at 5:33 PM on April 13, 2009 [2 favorites]

I'm a good programmer, and I'm not particularly good at math (I only got 700 on the math SAT), and I will agree that writing code that implements an algorithm helps you to understand the algorithm.

I don't know that you need a "learning system such as this"; you just need to write code that implements the algorithm you're having a hard time wrapping your head around. (And perhaps a "cheat sheet" that reduces "special" mathematical notation to notation you already know.)

One thing you'll need to look out for, of course, is that certain values

posted by orthogonality at 6:39 PM on April 13, 2009

I don't know that you need a "learning system such as this"; you just need to write code that implements the algorithm you're having a hard time wrapping your head around. (And perhaps a "cheat sheet" that reduces "special" mathematical notation to notation you already know.)

One thing you'll need to look out for, of course, is that certain values

*e.g.*π, or infinities, or even 0.1 can't be precisely represented on a computer, which will lead to cases where you think you've gotten an answer when you've only gotten an approximation. Choice of programming language will also matter; certain languages make certain algorithms easier to represent.posted by orthogonality at 6:39 PM on April 13, 2009

orthogonality:

For some of us trying to learn programming, it seems like a catch-22. We aren't good at math, but (it seems like) everytime I ask for help, the flood of responses I get from seasoned programmers is: "Programming is logic...logic is all based on math...you need to go back and learn math."

I hope I'm paraphrasing fightoplankton's question correctly .... is there an approach to learn programming (that isnt math based) but will teach math-principles in non-traditional way so that I end up learning math without realizing it?

posted by jmnugent at 7:12 PM on April 13, 2009

For some of us trying to learn programming, it seems like a catch-22. We aren't good at math, but (it seems like) everytime I ask for help, the flood of responses I get from seasoned programmers is: "Programming is logic...logic is all based on math...you need to go back and learn math."

I hope I'm paraphrasing fightoplankton's question correctly .... is there an approach to learn programming (that isnt math based) but will teach math-principles in non-traditional way so that I end up learning math without realizing it?

posted by jmnugent at 7:12 PM on April 13, 2009

Interesting, I am the opposite: I'm more comfortable with math than I am with programming. I can do both, but feel more at home with math.

What sort of math would you like to learn? Trig? Calculus? Matrix algebra? Project Euler level math? Discrete math? There's a lot out there.

It may help to frame the math you'd like to learn in a computer science/programming framework. You could approach the math from a CS perspective, learn the basics, then implement it to cement your learning. Algorithms and data structures courses cover some of this. Doing a bit of computer graphics would help with trig and matrix algebra. Computational geometry is an awesome blend of math and computer science. Implementing the algorithms would definitely help your understanding.

posted by wiskunde at 7:40 PM on April 13, 2009

What sort of math would you like to learn? Trig? Calculus? Matrix algebra? Project Euler level math? Discrete math? There's a lot out there.

It may help to frame the math you'd like to learn in a computer science/programming framework. You could approach the math from a CS perspective, learn the basics, then implement it to cement your learning. Algorithms and data structures courses cover some of this. Doing a bit of computer graphics would help with trig and matrix algebra. Computational geometry is an awesome blend of math and computer science. Implementing the algorithms would definitely help your understanding.

posted by wiskunde at 7:40 PM on April 13, 2009

First of all I'm a little skeptical about whether or not you can be a

But I do think it should be possible to do quite a bit with computers, provided you know addition and subtraction, in order to figure out array indexes and loops (of course with collections these days you probably get away with using for-each style loops a lot of the time even)

They may be "seasoned" but they aren't very good. Either at programming or communication. Logic isn't "based" on math, it's its own branch of mathematics with it's own axioms. And unless you are designing digital logic circuits you don't ever have to think much about some of the advanced things you can do with Boolean algebra. It's pretty important if you

Every once in a while you do get something complicated where you have to think through the Boolean logic in an if statement.

When most people learn "math" they learn from following hierarchy: Arithmetic, Algebra, Trigonometry, Calculus, Differential Equations. Those things are great. But other then basic arithmetic, they don't really have anything to do with writing everyday programs.

The kind of math that is helpful for programming is what's called discrete math, basically math involving sets and whole numbers of things. And of course being able to understand the math involved in figuring out the runtime of algorithms is pretty important to writing efficient programs. If you get into really hardcore stuff like machine learning or physics simulations or 3d you need a lot of math, but at that point you're not really "programming" so much as "programming a computer to do math."

Basically what you have to do be able to do is think abstractly. The connection between math and programming is that being able to think about the complicated relationships between objects and functions and data and pointers in a program is like being able to figure out the complicated relationships between numbers and functions in math.

posted by delmoi at 7:48 PM on April 13, 2009

*great*programmer without being good at math. Great programmers write great programs, and if you don't know math, you'll never be able to come up with anything really intresting.But I do think it should be possible to do quite a bit with computers, provided you know addition and subtraction, in order to figure out array indexes and loops (of course with collections these days you probably get away with using for-each style loops a lot of the time even)

*I get from seasoned programmers is: "Programming is logic...logic is all based on math...you need to go back and learn math."*They may be "seasoned" but they aren't very good. Either at programming or communication. Logic isn't "based" on math, it's its own branch of mathematics with it's own axioms. And unless you are designing digital logic circuits you don't ever have to think much about some of the advanced things you can do with Boolean algebra. It's pretty important if you

**are**designing digital logic circuits though!Every once in a while you do get something complicated where you have to think through the Boolean logic in an if statement.

When most people learn "math" they learn from following hierarchy: Arithmetic, Algebra, Trigonometry, Calculus, Differential Equations. Those things are great. But other then basic arithmetic, they don't really have anything to do with writing everyday programs.

The kind of math that is helpful for programming is what's called discrete math, basically math involving sets and whole numbers of things. And of course being able to understand the math involved in figuring out the runtime of algorithms is pretty important to writing efficient programs. If you get into really hardcore stuff like machine learning or physics simulations or 3d you need a lot of math, but at that point you're not really "programming" so much as "programming a computer to do math."

Basically what you have to do be able to do is think abstractly. The connection between math and programming is that being able to think about the complicated relationships between objects and functions and data and pointers in a program is like being able to figure out the complicated relationships between numbers and functions in math.

posted by delmoi at 7:48 PM on April 13, 2009

You can be a good programmer w/out being "good" at math. I guess it depends on how you define good. I got a B in every math class I had to take in college, but to me good means you can visualize and understand things at a level I never did. (I met quite a few people who were good at math by any defn.)

To me programming is more like a trade, like carpentry or something.

That said, math skills certainly don't help, and math-phobia will certainly hinder you. I think the problem is, there are some types of abstraction that you can't really easily master via implementation, because by their very nature these are abstractions. It really depends on what type of math you're talking about. For finite stuff (proofs by recursive descent, that kind of thing), maybe you can implement an example or two to illustrate some proof. But something like the proof that square root of two isn't rational, not sure how you could code something that would make that clearer than it is.

Visualization can definitely help (some of the greatest mathematicians, Riemann for example, were super visual). Like Mobius transformations revealed. So perhaps you can get familiar w/ plotting tools and graph out the behavior of functions you're trying to understand?

posted by jcruelty at 10:31 PM on April 13, 2009

To me programming is more like a trade, like carpentry or something.

That said, math skills certainly don't help, and math-phobia will certainly hinder you. I think the problem is, there are some types of abstraction that you can't really easily master via implementation, because by their very nature these are abstractions. It really depends on what type of math you're talking about. For finite stuff (proofs by recursive descent, that kind of thing), maybe you can implement an example or two to illustrate some proof. But something like the proof that square root of two isn't rational, not sure how you could code something that would make that clearer than it is.

Visualization can definitely help (some of the greatest mathematicians, Riemann for example, were super visual). Like Mobius transformations revealed. So perhaps you can get familiar w/ plotting tools and graph out the behavior of functions you're trying to understand?

posted by jcruelty at 10:31 PM on April 13, 2009

p.s. if you're in psych i guess you'd need to have strong grasp of statistics? there's lots of cool stuff out there like this code snippet that approximates pi via random dart throwing. please provide more specifics if possible, this is an interesting question.

posted by jcruelty at 10:43 PM on April 13, 2009

posted by jcruelty at 10:43 PM on April 13, 2009

This is an interesting question, but I'd like to see it narrowed down some. As delmoi alluded to earlier, the sort of math that's usually taught in an introductory Computer Science curriculum is discrete mathematics. This looks almost nothing like any math you've seen up until college, for most students. Discrete mathematics is really the language of any algorithm on a computer, since computers are discrete automata.

Now what sort of math would you like to learn? In the sort of classes I TA and help teach (Numerical Linear Algebra, Scientific Computing), programming is a fundamental part of the curriculum, because we solve physical problems that are intractable without a computer. Indeed, I 'understand' some of this math better when I have programmed it, but there's a lot of hard math in proving that the algorithms will work and are correct that can be worked out with pen and paper.

If you're trying to learn statistics, there's a good free book on learning statistics with R (a free programming language for statistics that you should know if you are working in the field), it may be just what you're looking for: Introduction to Statistical Thought, by Michael Lavine.

posted by onalark at 6:52 AM on April 15, 2009 [3 favorites]

Now what sort of math would you like to learn? In the sort of classes I TA and help teach (Numerical Linear Algebra, Scientific Computing), programming is a fundamental part of the curriculum, because we solve physical problems that are intractable without a computer. Indeed, I 'understand' some of this math better when I have programmed it, but there's a lot of hard math in proving that the algorithms will work and are correct that can be worked out with pen and paper.

If you're trying to learn statistics, there's a good free book on learning statistics with R (a free programming language for statistics that you should know if you are working in the field), it may be just what you're looking for: Introduction to Statistical Thought, by Michael Lavine.

posted by onalark at 6:52 AM on April 15, 2009 [3 favorites]

You know, we teach math students algorithms all the time. Have we all forgotten how to multiply and divide?

What happens is that arithmetic has nice, simple algorithms, and more advanced maths are an exercise in proofs. This starts with algebra. When you solve an equation for X, you write down the original formula, as a given, and apply a series of logical transformations, with each intermediate statement being true.

The trouble is that this doesn't generalize. There is no good algorithm for proving everything. And a quick glance at extending the quadratic equation to higher order polynomials quickly ran outside my experience; I'm not confident one can even produce a general algorithm for "solve for x" under basic algebra.

posted by pwnguin at 6:31 PM on April 17, 2009

What happens is that arithmetic has nice, simple algorithms, and more advanced maths are an exercise in proofs. This starts with algebra. When you solve an equation for X, you write down the original formula, as a given, and apply a series of logical transformations, with each intermediate statement being true.

The trouble is that this doesn't generalize. There is no good algorithm for proving everything. And a quick glance at extending the quadratic equation to higher order polynomials quickly ran outside my experience; I'm not confident one can even produce a general algorithm for "solve for x" under basic algebra.

posted by pwnguin at 6:31 PM on April 17, 2009

This thread is closed to new comments.

posted by NucleophilicAttack at 5:07 PM on April 13, 2009 [1 favorite]