36
$\begingroup$

I was wondering if it's OK to ask about the implementation of a mathematical function in code?

Really do not know if I should ask in StackOverflow or math.stackexchange.

$\endgroup$
2
  • 6
    $\begingroup$ Such issues might be better addressed at sister site SciComp.SE (on scientific computation). I've replied to such questions both here and there at an algorithmic level (and at SO as well). How much you intended to emphasize actual coding is key to whether Math.SE is suitable. Do some searching for the mathematical function at issue, and you may find someone has already asked about it. $\endgroup$
    – hardmath
    Commented May 27, 2019 at 17:55
  • 2
    $\begingroup$ For code in the Wolfram Language, Mathematica.SE is available. $\endgroup$
    – TheSimpliFire Mod
    Commented May 28, 2019 at 12:54

1 Answer 1

66
$\begingroup$

My view has always been that programming questions are very much borderline. Here is the border, as I see it.

  1. Your question is about the mathematics of the algorithm. This could be about a specific implementation, but the question has to be mathematical. That question is on-topic here.

  2. Your question is about the implementation of your code. It is about the language, your use of the language, or some problems related to the process of implementing the algorithm, rather than its design. This question is not on-topic here and should be asked elsewhere.

$\endgroup$
6
  • 1
    $\begingroup$ Thank you, that makes sense. $\endgroup$
    – SHM
    Commented May 27, 2019 at 8:17
  • 11
    $\begingroup$ This is exactly how I've been thinking of it as well. $\endgroup$
    – davidlowryduda Mod
    Commented May 27, 2019 at 12:07
  • 13
    $\begingroup$ The tricky area is when the questioner doesn't know whether their mistake was in the mathematics or the code. When this happens, I prefer to err on the side of allowing it even if coding was the issue, if only because "actually, your maths was right after all" is often the right answer to code-free questions that we accept. $\endgroup$
    – J.G.
    Commented Jun 1, 2019 at 21:59
  • 3
    $\begingroup$ BTW, particularly for novice questions, I often include some code with my answer, so that they can see the answer "working in practice" (and so that I can point out some subtleties as we go from math to code, like "don't test against floating-point zero"). $\endgroup$ Commented Jun 4, 2019 at 1:54
  • $\begingroup$ Aka don't ask about PARI/GP and forsquarefree, or isprime, or sqrtint, or logint, etc. $\endgroup$
    – user645636
    Commented Jun 5, 2019 at 19:57
  • $\begingroup$ I think this hits the nail on the round flat part. $\endgroup$
    – MJD
    Commented Jun 8, 2019 at 14:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .