12

Bug introduced in 3.0 or earlier and persisting through 13.2


I encountered this when trying to solve this problem with DSolve:

eqn = With[{p = p[x, y, t]}, D[p, t] == x D[p, x] + (1 - y) D[p, y] + 2 p]; 
DSolve[eqn, p, {t, x, y}]

DSolve::deqx: Supplied equations are not differential equations of the given functions.

(* Input returned *)

It's not surprising to see DSolve fails in solving PDEs… but why this warning? Even more shocking:

DSolve[eqn, p, {x, y, t}]
{{p -> Function[{x, y, t}, C[1][x (-1 + y), t + Log[x]]/x^2]}}

The result changed just because I reordered the independent variables (from {t, x, y} to {x, y, t}). Is this a bug?

bmf
  • 15,157
  • 2
  • 26
  • 63
xzczd
  • 65,995
  • 9
  • 163
  • 468
  • Very odd indeed; on mathematica 10 the first request is returned unevaluated. – chris Jul 22 '14 at 07:29
  • @chris Yeah, v9.0.1 and Wolfram Programming Cloud returned unevaluated after the warning, too. – xzczd Jul 22 '14 at 07:35
  • 2
    With Mathematica 5.2 I get exactly the same result (screenshot) as with versions 8.0.4 and 10.4 (OS Windows 7 x64). So the bug seems to be quite old... – Alexey Popkov Apr 17 '16 at 15:52
  • 1
    @AlexeyPopkov The bug has already been introduced in v3: https://i.stack.imgur.com/Zx2uD.png Version 2.1 isn't influenced, because DSolve can't seem to solve PDE at that time: https://i.stack.imgur.com/V1Se1.png – xzczd Dec 12 '19 at 04:34
  • Have you reported the bug to the support? – Alexey Popkov Dec 12 '19 at 06:22
  • @AlexeyPopkov I can't remember… I believe I have, but can't find the relevant e-mail. Not sure if it's because the support doesn't reply. – xzczd Dec 12 '19 at 06:40
  • If you change the second argument from p to p[x, y, t] you get a solution in a different form (in V12). It seems to solve the pde as if you had written p[t, x, y] instead of p[x, y, t]; since it returns an expression, the permutation of the arguments does not matter and you get a valid solution. – Michael E2 Dec 12 '19 at 15:09
  • @MichaelE2 Funny, and the behavior actually varies from v3 to v5: https://i.stack.imgur.com/ifxMj.png So perhaps someone attempted to fix the bug in the early days, but the result isn't that great. – xzczd Dec 12 '19 at 15:57
  • I think the problem here is that one of p for DSolve is outside With[ ], so author asks for pure function solution. Compare to With[{p = p[x, y, t]}, DSolve[D[p, t] == x D[p, x] + (1 - y) D[p, y] + 2 p, p, {t, x, y}]], which behaves as expected – Acus Dec 13 '19 at 07:14
  • @user18792 Yeah, that's what Michael E2 observed in his comment, and I think this should not be called a problem, because a single p rather than p[x, y, t] is valid and documented. – xzczd Dec 13 '19 at 08:56
  • @xzczd Yes I, of course, agree. The usage of With[ ], however is not a best way to demonstrate this bug. – Acus Dec 13 '19 at 11:38
  • @user18792 I think writing PDE with With is more readable. Actually this isn't orignal sample, I edited it yesterday. (You can check the edit history. ) I've edited the sample further, now it should be better. – xzczd Dec 13 '19 at 11:54
  • Now it is indeed much better. – Acus Dec 13 '19 at 12:29
  • I reordered the independent variables The order of independent variables must match the order they appear in the dependent variable. At least this is what I always made sure when I type the call. So if you write u[x,y,t], then it should be {x,y,t} also and if you write u[t,x,y] then it should be {t,x,y}. – Nasser Mar 18 '20 at 18:21
  • @Nasser Well, it's WRI that should fix the bug, or at least add proper warning and document if they finally decide to treat this behavior as a feature, isn't it? – xzczd Mar 19 '20 at 04:13
  • I agree with you that in theory the order should not matter, but I noticed long time ago that the order must match between how the variables appear in the dependent variables and in the call to DSolve. I just assumed it is by design. I do not think I've seen this documented anywhere if my memory is right. btw, in Maple, one does not even have to tell dsolve what is the dependent variable and what are the independent variables. It figures them out by parsing the ODE or the PDE itself. – Nasser Mar 19 '20 at 04:17
  • @Nasser Just tested the first 10 PDE examples in DSolve document. (Didn't test them all because it's really painful to do this on Wolfram cloud… ) The order matters in 5 of them. (3, 4, 6, 8, 10. ) – xzczd Mar 19 '20 at 04:55
  • 1
    Yes, the order matter but as you noticed, it is not all the time. There are cases where order does not matter. That is why I try to keep same order all the time. Please see why-dsolve-gives-different-answer-depending-on-order-of-variables-ux-t-vs where I said at the top and ordering the variables the same elsewhere – Nasser Mar 19 '20 at 05:03
  • 1
    There was also a bug in NDSolve posted recently where the order made mattered https://mathematica.stackexchange.com/questions/215945/unexpected-switch-of-partial-derivatives-when-differentiating-interpolatingfun/216021#216021 – Nasser Mar 19 '20 at 05:07

0 Answers0