9

I am not the best in maths, not very horrid either, but lower than the average, I've always been thinking to improve my maths, but schools and books didn't do the job because I get bored too fast. The only thing I don't get bored with is coding and gaming, so I thought what if coding a program that solves mathematical problems will help me understand maths better, most of these problems are limits (calculus), functions, Differential calculus, and some other subjects (I already said am not that good) similar to the previous noted.

My question is: Am I able to achieve a better knowledge in maths if I do some specific program coding, and if possible, is physics possible that way too? Or am I wrong and Maths should be learned before programming to help improve my coding?

P.S : C++ is the preferred language.

gnat
  • 21,442
  • 29
  • 112
  • 288
SAFAD
  • 485
  • 2
  • 5
  • 14
  • 5
    It worked the other way around for me. I learned computer programming to help me do work in graduate level statistics classes better. I found I liked programming better than stats and changed my career direction. – jfrankcarr Jan 25 '12 at 17:33
  • possible duplicate of [Do we have to learn Mathematics to be a good Programmer?](http://programmers.stackexchange.com/questions/55481/do-we-have-to-learn-mathematics-to-be-a-good-programmer) – gnat Jul 20 '13 at 20:02
  • relevant: http://steve-yegge.blogspot.co.uk/2006/03/math-for-programmers.html – jk. Oct 31 '13 at 17:11
  • There is no Royal Road to mathematics, Sir. – Karl Oct 31 '13 at 18:22

12 Answers12

15

You will only learn math or physics from programming if you actually use the programming to solve math and physics problems, although functional languages like Haskell have concepts in them that are very "mathy". I would suggest going to a web site like Kahn Academy or Project Euler. Solve the problems on there using code, and you'll improve both your coding skills and math skills at the same time.

Matthew Flynn
  • 13,345
  • 2
  • 38
  • 57
Mike Cellini
  • 1,865
  • 10
  • 19
  • 5
    +1 for both resources. I do have to say, though, I **hated** calculus the first time through. Never did that well at it, either. Since learning Lisp, it *just makes sense*. Kinda fun, too. – Jason Lewis Jan 25 '12 at 23:11
  • 1
    If you want to give Haskell a try, you can read "The Haskell road to Logic, Maths and Programming": the book teaches Haskell, to do mathematics, and introduces all the mathematical concepts along the way. However, it focuses on mathematical logic, number theory, and some elementary algebra. Calculus is only mentionned at the very end, if you managed to go through everything else. – Vincent Zoonekynd Jan 26 '12 at 01:23
  • I'd also suggest specialised CAS languages, like Mathematica (expensive!), Maxima or Axiom (free). Once you get the idea of term rewriting, rules and strategies, the whole of the mathematics would start to make sense. – SK-logic Jan 26 '12 at 08:57
  • I have personally found Khan Academy very helpful at filling in the gaps in my math knowledge. – jonners99 Oct 31 '13 at 13:01
  • @Jason Lewis - If your problem is more teaching style than the material, and you want full courses, I the MIT OpenCourseware courses are excellent for many math topics, including calculus and linear algebra. Not practical for just revising one specific topic, though. I particularly liked the linear algebra course. MIT OpenCourseware is also very good for some computer science topics, of course - especially the two algorithms and data structures courses. There has never been a better time for educating yourself at your own pace with excellent free materials. –  Oct 31 '13 at 18:19
5

Obviously you should learn maths through programming. If you attempt to simulate physical objects you will need to learn all sorts of physics and maths, and you will enjoy it.

kevin cline
  • 33,608
  • 3
  • 71
  • 142
4

This is my take...

Programming Will Help Test Your KNOWLEDGE

When I was in high school and middle school, I would program my calculators to do the monotonous math for me. Some people claimed it was cheating, but I always argued that I wouldn't be able to write the programs if I didn't truly understand the math.

For instance, let's say you wanted to create a small program to compute the C value, given A and B, within the Pythagorean theorem. How do we do it? Well, we know that:

A^2 + B^2 = C^2

So to solve for C, we have:

C = SQRT(A^2 + B^2)

Therefore, the program might be something like (assuming proper headers, this is a bare bones example):

cout << "Enter value for A: " 
cin << valA;
cout << "Enter value for B: "
cin << valB;

float valC = sqrt(pow(valA, 2) + pow(valB, 2))
cout << "C = " << valC << "\n";

HOWEVER...

Where and How Do You Acquire Said Knowledge?

In the previous example, we needed to know how to solve for C within the equation A^2 + B^2 = C^2. If we didn't know to square root both sides to find C, how could we solve the problem?

IMO, it boils down to: programming will not TEACH you math absolutely, but it WILL IMPROVE the skills you acquire.

skippr
  • 293
  • 2
  • 5
  • yes, I got your point and I agree with it,based on your answer, I will learn maths when I solve problems in programming, however I won't be able to solve them without knowledge thus I would have to search for solution and that is what will teach me maths... – SAFAD Jan 25 '12 at 20:16
2

The SICP book has a very nice section on math. But I would suggest that you try to take linear algebra, discrete mathematics, and The Calculus at a minimum, if you learn only from writing programs your education is likely to be very deep, but not very broad.

gam3
  • 783
  • 6
  • 13
2

I think they go hand in hand. A solid grounding in mathematical techniques will open up options in programming you wouldn't have otherwise, meanwhile programming can open up interesting avenues of mathematical study.

I've recently started using wxMaxima, a nice graphical front-end to the excellent open source Maxima Computer Algebra System (aka a CAS, like the commercial Maple or Mathematica systems).

It won't teach you anything about maths on it's own, but it will certainly make playing around with maths more interesting and fun, that in itself could encourage you to learn more.

Mark Booth
  • 14,214
  • 3
  • 40
  • 79
2

You don't need much math for "programming".

You need math for "computer science".

If you plan to use pre-existing library solutions for everything, then you probably don't care how they work. But if you plan to make your own algorithms and data structures, you will need to know math, as CS is heavily math based.

user541686
  • 8,074
  • 8
  • 38
  • 49
1

Have a look at matlab. Its a language designed for doing mathematical functions in code.

a numerical computing environment and fourth-generation programming language... MATLAB allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages...

Although MATLAB is intended primarily for numerical computing, an optional toolbox uses the MuPAD symbolic engine, allowing access to symbolic computing capabilities. An additional package, Simulink, adds graphical multi-domain simulation and Model-Based Design for dynamic and embedded systems...

gnat
  • 21,442
  • 29
  • 112
  • 288
Tom Squires
  • 17,695
  • 11
  • 67
  • 88
  • matlab is only beneficial when the programmer has a sound mathematical knowledge beforehand and it is limited to a certain domain of math. – wirrbel Jul 20 '13 at 19:41
1

If you're interested in working in AI, data processing, physics simulation or graphics then you need maths. Conversely, if you're not, then I reckon you don't. It's a case of use it or lose it, why learn French if you don't want to live in France? There are plenty of problem domains that just require conditional logic.

Having said that, there's a natural incline in programming towards mathematics , and it's going to do you nothing but good to gain some understanding of it.

sunwukung
  • 2,275
  • 1
  • 17
  • 29
1

Mathematics is a science with a very broad domain. There are different kinds of math that have explicitly nothing at all in common (apart from being math).

Now programming is often associated with math because computers compute and calculate, most fundamentally they do this with integer or floating point datatypes in discrete steps.

There are fields of math that you can study by programming by "approximating" mathematics in a program. Lets say you study differential calculus and calculate numerical values for small intervals thus "emulating" the limit of the "pure" math.

Other aspects of programming are easily mapped to math (maybe not part of your high school math class but still valuable math that does not happen to be part of a traditional curriculum). Type theory for example -- or mathematical induction.

Often the only way to reason about "correctness" of a piece of code is mathematical induction for example. This kind of reasoning can be seen especially in functional languages (recursion, etc.).

I.e. there are many ways to learn math while programming, but not all math is easily approachable in the computational model of our computers and programming languages.

wirrbel
  • 3,018
  • 2
  • 21
  • 33
0

I couldn't find the blog entry but I recall a designer "type" from the late pre first bubble-burst era (before '01-ish) who blogged about discovering a love of math through becoming a web developer and realizing that he was actually quite good at it even though he'd always failed miserably in high school and had assumed he just wasn't somebody who would ever be any good at math and then pegged himself as an artsy type.

No not me. I was just lazy. I have to relearn trig occasionally but that's about it.

IMO, you can write a lot of decent code without heavy math knowledge until you can't, basically.

What programming CAN do for anybody with a reasonable amount of interest in it, however, is help you get over the idea of whether you're this sort of person or that sort of person, and give you the tools you need to just try stuff out and discover on your own how far your interests will take you in a given field of study.

And of course everything we're doing is linked at the hip with math so you may discover you've already learned more than you realized when you do stuff like learn about what that backwards-e summation thingy is all about.

Erik Reppen
  • 6,243
  • 31
  • 34
0

Another option is to use your love of programming to drive your desire to learn math. Just about anything tends to become easier to learn if you are learning it with a specific problem you want to apply it to and math is no exception. You just need to figure out math heavy programming problems that interest you and use them as a reason to learn the associated math. Learning Linear Algebra so you can play with graphics for example, or probability and statistics for image processing/computer vision type stuff.

I think your mileage is going to vary on this since different people have different ways of learning things, but sitting down and learning math in the abstract for the sake of learning math has simply never worked for me.

Evicatos
  • 662
  • 6
  • 12
-2

Well, You can ask students to solve some geometry problems like to draw square, pentagon, hexagon and circle with Scratch. Challenge them to develop solutions and DON´T answer them about HOW to code it. Let them explore and test solutions. At least you can ask things like the angles sum in polygons. Then they can build the algorithms and their own categories.

gnat
  • 21,442
  • 29
  • 112
  • 288