The following problem is an exploration of what causes the error "Input is not an ordinary differential equation" in Mathematica as it seems to have changed from version 8 to version 9.
Specifically I have found that in Mathematica 9 I have come across the issue that
NDSolve[{x'[t] == 5, C'[t] == 5, x[0] == 1, C[0] == 1}, {x, C}, {t, 0, 100}]
gives the error, whereas in version 8 it does not. So something is up, but my question has more to do with if this is a bug in v8 or a bug in v9, that is, I get that C is a built in symbol: so is this error a correct catching of an input mistake? If so then
NDSolve[{C'[t] == 5, C[0] == 1}, C, {t, 0, 100}]
Should also give an error and it does not.
I really want to understand what is possibly going on, since as an ecologist I have to deal with equations that have C in them for "consumer" and I am forced to troubleshoot any issues that might come up with people not understanding the shadowing issue.
Clarification
It has been pointed out that it is bad coding style to use user defined symbols that start with a capital letter, as this will avoid clashes with Mathematica built-in definitions. That is fine, but does that matter?
What I am trying to ask more generally is whether the issue is that Mathematica is specifically checking for C and related symbols in NDSolve? Because I have no problems using symbols that have existing UpValues/DownValues as variable names (upper or lowercase) and even Protected in the exact same context.
What I want to try and understand is are there semantic reasons that this fails, ie could I cause the same error with user generated code? Or is this just a hard coded one off that Wolfram is doing for this case?
Further Clarification
If this is just an issue of using built-ins why can I use C in Solve and even DSolve! if it is an error in NDSolve? Again seems more and more like a specific check in NDSolve. For example
DSolve[{x'[t] == 5, C'[t] == 5, x[0] == 1, C[0] == 1}, {x, C}, t]
Gives back an answer ... so suddenly this same input string is valid ODE again?
Now there are other built-ins that have this behavior such as K and Slot. As a challenge to all that would just tell me to code differently (which I do ... this is a question of why Mathematica works this way) can you use any of the reasons that you given to make a user defined symbol that will trigger the same error? If not then I will conclude that Mathematica is specifically checking for such symbols and move on. But I want to be totally clear that this is not just a question about coding style but if there are differences between system symbols and user defined symbols in this context. What if I make a package that has defined symbols in it, will I ever be able to cause the same problem if a naive user shadows some of my imported symbols into their global context?
One interesting suggestion is that somehow NDSolve is introducing C or K or Slot when it processes the input and that is causing errors. If so then I should never be able to create this problem with user defined symbols, but I do not yet know if this is the correct idea.
Cworks in version 9 as well – Gabriel Dec 04 '12 at 08:31Cor any other symbol; this is no different to, for example, the fact that you cannot have a variable calledintin (the language) C. This does not break your code; the code was broken to begin with. It's just that in M9 your bug has consequences whereas it apparently didn't in the past. One would not, after all, think to name a variableIntegerPartorFor. – Oleksandr R. Dec 04 '12 at 09:37Creally a "reserved keyword" like in C? Seems more like a library function. It would be stupid to define my ownprintffunction and use it in C, but it certainly wouldn't give me an error for doing so. That is this seems to be more than a Shadowing issue like people seem to think. Can anyone define a symbol in Mathematica that gives the same error? – Gabriel Dec 04 '12 at 16:19Kgives the same error, for instance – acl Dec 04 '12 at 17:21Cis a protectedSystem`context symbol.C[1],C[2], etc. are used to denote constants automatically generated by the system, in particular byDSolve. UsingCin a differential equation is asking for trouble regardless of version. – Szabolcs Dec 04 '12 at 21:41ProtectedSymbols, that work. Maybe I need to rewrite this as a challenge to create a user defined symbol that will causeNDSolveto give the specific error of "Input is not an ordinary differential equation" ... as I seem to have people just thinking about coding style. It really seems thatNDSolveis checking for these `System`` symbols – Gabriel Dec 04 '12 at 21:51DSolve. It's that whether or not you get an error, if you do useC, there's a chance your result is incorrect. ConsiderDSolve[f''[x]==f[x], f[x], x]andDSolve[C''[x]==C[x], C[x], x], and you'll see where things can go wrong. Because of how the language works, it would be difficult to protect the user against mistakes like this. The syntax colouring still gives a very clear warning that you must not useC,N,K, etc.Lwould be fine (notice it's undefined and blue). – Szabolcs Dec 04 '12 at 22:09Blockas a variable. Yes, it'll "work" (Solve[Block^2 == 1, Block]), but it's clear why someone who does use it might get burnt. The only protection Mathematica includes is against assigning values to these symbols, plus the syntax colouring. So unfortunately it's the user's responsibility not to use built-ins by accident. – Szabolcs Dec 04 '12 at 22:10Cin your equation by any System context symbol, even a user-created one (just enterSystem`Booto createBooin that context), you'll get the error for this particular equation. But not for another equation I tried. So this error is not just an additional safety net added in version 9 (because it is not consistently issued). – Szabolcs Dec 04 '12 at 22:27Booexample. This seems like the smoking gun for me that it is a bug and not a safety net. I can accept that and issue the bug report. – Gabriel Dec 04 '12 at 22:32