Suppose you are working on something in a programming language (in my case, C++) that is math-related. Now, let's suppose that there was a numeric methods concept are having questions on, so you decide to "pull it off to the side" to write some code for that concept. Furthermore, let's suppose that the results of that program are unexpected (mathematically, you expect it to do something, but instead, it does the complete opposite). Should the question be posed here with a link to the code, and the math formulae you used in the code, and why you think the formulae should work, or should it instead be asked somewhere else (like StackOverflow)?

• One key aspect is to give a minimal comprehensible excerpt of the code and to explain it well in English. On MSE, as opposed to SO, you're likely to find more people fluent in Matlab, Mathematica, and Maple than in C++. You may even find more Haskell and Coq programmers than C++ ones. So a bunch of C++-specific details will probably go over a lot of heads. That said, there are definitely people around here who speak the language and others who can get the gist of well-written code. Jan 5 '14 at 3:11

My $\$.02\$: If your question is a mathematical one, and not simply a syntax or a question about the language that you're using, then it's on-topic. This assumes that the primary focus is on the mathematical model, and not the program itself. So asking about unexpected results from a numerical example is perfectly fine.