Related
I'm taking a numerical analysis class in the fall with a heavily applied/programming bent. I have a so-so programming background (having taken a few classes and worked on Java programming in an internship) but I want to bone up my skills before I start this class. So my question is, what programming skills are useful for numerical analysis?
Are data structures, OOP, algorithms very important? Are there any resources you would recommend I go over before class starts?
Algorithms and data structures. Not so much OOP. In the numerical analysis course that I took in college, we did a lot of programming of algorithms in python and Matlab.
You would be best to use numpy and/or scipy if you want to do numerical analysis fast prototyping. The python tutorial for python 2.7 or version 3 is about 120 pages long and available from docs.python.org and very easy to pick up in a day. numpy and scipy take some learning.
The gains using OOP can be large but it takes a lot of skilling up. If I was using C++ I'd use Brian H. Flowers book which can give you a quick introduction to applied engineering and the first 5 chapters will give you the ability to write good C++ OOP classes with about 8 hours work including writing test scripts. The problem now is that many OOP packages are in the standard template libraries. Many people end up reinventing the wheel because they don't know what is available. This is why you might be better to just go for Python numpy or scipy or as suggested above, just use Matlab since most things are predefined. Both languages are good for fast prototyping, but if you are wanting to do quite involved things like produce finite element/finite difference meshes, you will need to go to the BLAS libraries of Dongarra.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
This is not a "is math required for programming?" question.
I always thought that for programming, a scary amount of complicated math would be involved (I only got as far as intermediate algebra in college because I'm bad with it).
However, I just got my first job as a developer and have found there is not a ton of math above basic arithmetic(as of yet). I also read on a question here in SO that math is more used to ensure the would-be developer can understand complex problems and solve them.
So I guess is there a different kind of programming where a math level above algebra is needed? My guess would be like geometry and other disciplines for video game programming where you create shapes in 3D and play with time and space in environments. What else requires a high level of math?
EDIT: Wow, lot of answers. One of which made me think of another similar question...say in programs like photoshop, what kind of math(or overall work) is involved in making something twist, crop, edit, and color things like images?
I think there are at least two types of answer to this question. Firstly, there are the sorts of programming which is problems which come from a field where maths is important. These include:
finance
science research, e.g. physical modelling
engineering implementations, e.g. stress analysis, chemical engineering
experimental science, e.g. physics, psychology
mathematics itself
cryptography
image processing
signal processing
And then there are the sorts of programming where the target is not necessarily mathematical, but the process of achieving that target needs some maths. These include:
games
optimisation processes
high-complexity systems, e.g. flight control software
high-availability systems, e.g. industrial process monitoring and/or safety
complex data transformations, e.g. compiler design
and so on. Various of these require various levels and aspects of mathematics.
Gaming and simulation are obvious answers. The math is not difficult, but it is clearly there.
For example, say you want to build some sort of asteroids game. You'll need to figure out the position of your space ship. That's an vector. Now you want the ship to travel in a certain direction a certain direction every frame. You'll need to add some sort of delta-x to x, and delta-y to y, so your motion is another vector: . In an asteroids game, you accelerate in the direction you're pointing, so whenever you hit the 'thrust' key, you'll need to calculate the delta of dx and dy, or an acceleration vector,
(yep, this is the same dx from calculus class, but now I'm building robot zombie opposums with it.)
But that's not all. If you act now, I'll throw in some trig. Normally you think of motion and acceleration as angle and distance(r and theta,) but the programming language normally needs these values in dx, dy format. Here's where you'll use some trig: dx = r * cos (theta) and dy = r * sin(theta)
But, let's say you want to have a planet with a gravitational pull? You'll need to approximate gravity in a way that gives you orbit behavior (elliptical orbits, firing changes the altitude of the other side of the orbit, and so on.) This is easiest to do if you understand Newton's law of universal gravitation: f = ((sqrt(m1 * m2))/d^2) * G. This tels you how much 'planetward' force to add to your ship every frame.Multiply this value by a normalized vector pointing from the spaceship to the planet, and add that as a new motion vector.
Believe it or not, I encourage people who don't like math to take game programming courses. Often they discover that math can be (dare I say it) kind of fun when they're using it on problems that involve exploding cows in space.
As another example, think about optimizing a sound wave. The analog wave has an infinite number of points. It's impossible to store them all in a digital signal, so we break the audio signal into a large number of small segments, then measure every segment. If we want a perfect representation, grab an infinitely large number of infinitely small time slices.
Draw this out, and you've created the Riemann sum, the foundational idea of Integration (and in fact of Calculus)
One more example:
A friend of mine (a biology professor) was trying to build a 'sim city'-style simulation of a lake ecosystem. He was a decent programmer, but he got all bogged down in the various calculations. He wanted the user to vary usage of the lake (outboard motors, fishing restrictions, and dumping restrictions) and then to see how that affected levels of Nitrogen and other key elements.
He tried all kinds of crazy if-then structures with nested conditions and ugly Boolean logic, but never had a clean solution.
We took actual data, ran it through Excel, and found a trendline that accurately reflected his data with a simple logarithmic formula.
Hundreds of lines of messy code were replaced with a simple formula.
Here's a few general places:
Graphics
Cryptography
Statistics
Compression
Optimization
There are also a lot of specific problem areas where complex math is required, but this is due more to the nature of the program and less about programming in general. Things like financial applications fall into this.
Any kind of numerical analysis, like in geophysics or petroleum exploration.
I once built a tool for accident investigators that required a lot of trigonometry.
In commercial programming, not so much math as arithmetic.
All programming requires math. I think that the difference between people with mathematical backgrounds and people with programming backgrounds is how they approach and answer problems. However, if you are advancing your programming skills you are likely unknowingly advancing your mathematical skills as well (and vise versa).
If you abstractly look at both programming and mathematics you'll see they're identical in their approaches: they both strive to answer problems using very fundamental building blocks.
There is a pretty famous essay by Edsger W. Dijkstra which he attempts to answer your exact question. It is called: On the Interplay Between Mathematics and Programming.
Game programming (especially 3-D, as you mentioned) has a lot of "more advanced" math. For that matter, any projects where you're modeling a system (e.g. physics simulation).
Crypto also uses different forms of math.
Robotics requires hardcore matrices, and AI requires all kinds of math.
Quite alot of complex(ish) math in the Finance sector. Other than that and Trig for 3d I can't honestly think of much else.
Im sure there are some though.
Many seemingly non-mathematical industries such as Pharmaceuticals (eg. BioInformatics), Agriculture, Marketing and in general, any "Business Intelligence" relies heavily on statistics. System performance, routing, scheduling, fault tolerance -- the list goes on....
Digital signal processing and AI/simulation/agents are others.
Animation via code, especially when you try to model real physics, also needs math.
I'm a Mathematics graduate and I have to say that the only places where I've really seen any Maths being used (above very basic arithmetic) is understanding / simplifying logical statements, so for example things like the equivalence of these two statements:
(!something) && (!otherThing)
!(something || otherThing)
Apart from that the only time that you would need more complex Maths is when you are working with computer graphics or some subject which is Maths based (e.g. finance or computations) - in which case knowing the Maths is more about understanding your subject than it is about the actual programming.
I work on software that's rather similar to CAD software, and a good grasp of geometry and at least an idea of computational geometry is necessary.
I work in computational chemistry. You need a lot of linear algebra and general understanding of techniques such as Taylor expansion, integrals, gradients, Hessians, Fourier transformation (and in general, expansion on a basis set), differential equations. It's not terribly complex math, but you have to know it.
Statistics is used heavily in businesses performing Quality Assurance and Quality Analysis. My first development job was on a contract at the USDA; these were standard "line-of-business" applications except their line-of-business happened to involve a lot of statistical analysis!
Image compression and image recognition both use Fourier series (including classic sine wave series and other orthogonal series such as wavelet transformations) which has some pretty heavy theory usually not covered until a graduate level course in mathematics or engineering.
Non-linear optimization, constrained optimization, and system estimation using hidden models likewise use a significant amount of advanced mathematical analysis.
Computer science is math. Programming is programmers job. They are related, but the two areas don't exactly overlap, so I see the point of your question.
Scientific computing and numerical analysis obviously require a solid base of linear algebra, geometry, advanced calculus and maybe more. And the whole study of algorithm, data structures and their complexity and properties makes use of discrete mathematics, graph theory, as well as calculus and probability. Behind the simple JPEG standard there's a lot of information theory, coding theory, fourier analysis... And these are only some examples.
Although a computer scientist could even work an entire life without writing down a single line of code, as well as the best programmer in the world could know just a little of math, the fact is that computers perform algorithms. And algorithms require math. I suggest you to take a look at Donald Knuth's "The Art of Computer Programming" to have an idea of what is underneath the "simple" programming thing.
I got my masters degree in meteorology, and I can tell you for that field and other applied physics fields, the kind of coding you will be doing requires an immense amount of mathematics. A lot of what you are coding are things like time differential of equations.
For things like writing code for games, however, you're not always going to be doing a lot math in your code. Gaming requires lots of logic. The part of game coding where math comes in is when you have write physics engines and things like that.
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
How to improve my math skills to become a better programmer
Basic Math Book for a Programmer
I've had quite a weird career till now.
First I graduated from a medical school. Then I went into marketing (pharmaceuticals).
And then umm, after some time, I decided to go for my (till then) hobby and became a "professional" programmer.
I've been quite successful at this ever since. I have quite some languages "under my belt". I earn not bad and I have been involved in the opensource community quite heavily.
The thing is that I suck at math :). Well, not totally of course, as I get my work done. But I don't know how much I suck. And I don't know how to find out.
Math has never really been of any priority during my middle/high school years. I only picked as little as I could afford, because I was always getting ready to go for Medicine. Of course I know the basics of algebra. Things like "normal" and square equations. Also the basics of geometry. But well, there are things that I have missed.
And lately I am being fascinated by things like probability theory, infinity, chaos/order etc. But every time I try to learn something about these topics, I hit a wall of terminology, special symbols, and some special kind of thinking, that is quite like mine (a programmer), but also a lot different (and appears weird to me).
So, what kinds of books would you recommend me? It's very hard to find something suitable. All that I find are either too easy (and boring) or totally impenetrable.
Assuming you have your basic algebra down, I'd start with single variable calculus. I've used several calc books, and found Larson's to be the best. Hope you can find it at a library.
Move on to linear algebra shortly after. This book is free and very good.
Don't worry about mastering everything, you'll probably want to come back to linear algebra.
Then find a book that emphasizes proofs, sets, relations, functions, and axioms. I liked Analysis with an introduction to proof by Lay. Learn proof by induction especially well.
From here, you should be able to break that impenetrable wall you've found yourself against. You will be armed with the terminology to read just about any undergraduate mathematics textbook.
I recommend graph theory, combinatorics, and linear algebra, for their applications in computer science.
Good luck!
Of course I know the basics of
algebra. Things like "normal" and
square equations. Also the basics of
geometry. But well, there are things
that I have missed. And lately I am
being fascinated by things like
probability theory, infinity,
chaos/order etc.
I find that mathematics is a one-way door: if you don't get through early, it's hard to go back. It's not impossible to pick up, but it is more difficult without discipline.
The key is doing problems. You don't just read math books - you do problems to work the mechanics into your brain. If you're just reading, I'd say it's impossible to learn it.
Best to go back to what you know and work up. If you feel okay about basic algebra and geometry, start thinking about intro calculus or statistics. Start with the basic stuff: one variable differential and/or integral calculus or statistics. Do a lot of problems and get comfortable.
If you're a computer scientist, you'll find discrete math, graphs, numerical methods, and linear algebra helpful.
Don't expect to do it quickly, especially if you're casual about it.
I'd recommend two wonderful resources:
Verzani - Using R for Introductory Statistics
Gil Strang MIT Linear Algebra
Both are free; both are excellent.
You might check out some of the free course material available online from MIT.
The basics:
Basic understanding of real and complex numbers, functions, sets etc.
(Real) analysis in one variable
(Real) linear algebra
(Real) analysis in several variables
Discrete mathematics
Vector calculus
Complex analysis
Complex linear algebra
Statistics and probability theory
More advanced stuff:
Abstract algebra
Fourier analysis (much more important than one may think) (Basic video course from Stanford)
Transform theory (other than Fourier analysis)
Differential geometry
Functional analysis
Partial differential equations
Non-linear phenomena and chaos
Investigate available math classes at a local junior college. Typically, they offer them during the day for enrolled students but they sometimes have night classes as well. Talk to the professor to see if your math skills are sufficient for the class before enrolling, however, or you'll be struggling right out of the gate.
What are some of the better libraries for large sparse iterative (conjugate gradient, MINRES, GMRES, etc.) linear algebra system solving? I've often coded my own routines, but I'm interested to know which "off-the-shelf" packages people prefer. I've heard of PETSc, TAUCS, IML++, and a few others. I'm wondering how these stack up, and what else is out there. My preference is for ease of use, and freely available software.
Victor Eijkhout's Overview of Iterative Linear System Solver Packages would probably be a good place to start.
You may also wish to look at Trilinos
http://trilinos.sandia.gov/
It is designed by some great software craftsman, using modern
design techniques.
Moreover, from within Trilinos, you can call PetsC if you desire.
NIST has some sparse Linear Algebra software you can download
here: http://math.nist.gov/sparselib++/ and here: http://math.nist.gov/spblas/
I haven't used those packages myself, but I've heard good things about them.
http://www.cise.ufl.edu/research/sparse/umfpack/
UMFPACK is a set of routines for
solving unsymmetric sparse linear
systems, Ax=b, using the Unsymmetric
MultiFrontal method. Written in
ANSI/ISO C, with a MATLAB (Version 6.0
and later) interface. Appears as a
built-in routine (for lu, backslash,
and forward slash) in MATLAB. Includes
a MATLAB interface, a C-callable
interface, and a Fortran-callable
interface. Note that "UMFPACK" is
pronounced in two syllables, "Umph
Pack". It is not "You Em Ef Pack".
I'm using it for FEM code.
I would check out Microsoft's Solver Foundation. It's free to cheap for even pretty big problems. The unlimited version is industrial strength and is based on Gurobi and of course isn't cheap.
http://code.msdn.microsoft.com/solverfoundation
Given my previous questions about the the usage of AMPL.
Are there any other programming/scripting languages that are strictly meant for mathmatical processing?
For example: Matlab (it does deviate a bit from a mathematical structure, but its close enough), Mathematica, and AMPL
R / S+ for statistical computing
Other stat languages: SAS, SPSS, STATA, GAUSS, etc.
Octave, an open source clone of Matlab
Fortress, "a language for high-performance computation that provides abstraction and type safety on par with modern programming language principles."
Maple
Maxima
There's always APL, with its builtin matrix operators. Modern APL even supports .NET.
R, Numpy/scipy for Python, Maple, Yacas, even Fortran.
This may be only of historical significance, but Fortan (The IBM Mathematical Formula Translating System) is especially suited to numeric computation and scientific computing.
OPL (Optimization Programming Language) is one of the most comprehensive modelling languages for Mathematical Programming. You can do Linear Programming (LP), Mixed Integer Programming (MIP), Quadratic Programming (QP), Constraint Programming (CP), MIQP, etc.
IBM-ILOG CPLEX Optimization Studio uses this language.
Maple for symbolic math (similar to Mathematica).
SAS, SPSS, R for statistics.
The Operation Research / Management Science magazine has a yearly survey of Simulation Software, and while I can't find the link I believe they have one yearly survey on optimization packages, such as AMPL you are quoting.
Sage is basically Python with a load of packages and a few language extensions put into a "notebook" interface like that of Mathematica. It has interfaces to all sorts of computer algebra systems. And with Numpy and Scipy (which are included) it's a fine replacement for Matlab. And it's open source and actively developed.
Given your previous question, I assume you are looking for an alternative to commercial mathematics packages. If so, you should try Sage, it is open source and is a unified front end for almost all of the open source mathematics/sci.calc. packages out there (list).
The way it works, is that it uses your web browser as a graphical front end for displaying, editing and evaluating Mathematica style notebooks (it is also possible to just use the command line). All the dirty work, such as selecting the appropriate package for the situation, is done transparently in the background.
Sage uses Python as it's main language / syntax, so it's fairly easy to learn, and if you have old Python scripts, they should work straight out of the box. If I didn't have access to a Mathematica license, I would definitely use this.
Interactive Data Language (IDL) is a proprietary language used in astronomy, medicine and other sciences at least in part because of its built-in array operations and mathematical library.
As this question is still open and well indexed in Google, I would definitively add to the list the Julia language.
Aside the technical aspects that make shine this high level/high performance new language, an important consideration is that the community of developers/users is clearly biased toward mathematicians.