Solving overdetermined PDEs with DSolve or NDSolve

I was using Mathematica 11.1 to solve a PDE system numerically, but it told me that the system is overdetermined. So I tried a much simpler one. Here is the input.

s1 = NDSolve[{D[u[x, y], x, x] + D[u[x, y], y, y] == 0,
D[u[x, y], x, y] == 0,
u[x, 0.5] == 0.5*x, (D[u[x,y],x]/.y->0.5)==0.5,(D[u[x,y],y]/.y->0.5)==0},
u[x, y], {x, 0, 1}, {y, 0, 1}]

However it didn't work and the output was

NDSolve::deqn: Equation or list of equations expected instead of
(D[u[x,y],x]/.y->0.5)==0.5,(D[u[x,y],y]/.y->0.5)==0 in the first argument
{(u^(0,2))[x,y]+(u^(2,0))[x,y]==0,(u^(1,1))[x,y]==0,u[x,0.5]==0.5 x,
(D[u[x,y],x]/.y->0.5)==0.5,(D[u[x,y],y]/.y->0.5)==0}.

Another question, if I input

s3 = DSolve[{D[f[x, y], x, x] + D[f[x, y], y, y] == 0,
f[x, 0.5] == 0.5*x, (D[f[x, y], x] /. y -> 0.5) ==
0.5, (D[f[x, y], y] /. y -> 0.5) == 0},
f[x, y], {x, 0, 1}, {y, 0, 1}]

then the output is the same as the input and I get nothing useful. However, f[x,y]=0.5x is a solution. Why can not Mathematica give me this solution? How can I deal with these situations?

• Running your code for s1 on a fresh kernel also returns the "overdetermined" error. Which makes sense, because the system is overdetermined: it has two second-order equations for $u$ defined in the interior. May 21 '18 at 13:07

Given the enormous number of methods available for solving differential equations symbolically, it should not be surprising that DSolve does not know all of them. Indeed, searching Mathematica.StackExchange uncovers many examples, at least two of which seem relevant here, 163482 and 155758. So, DSolve cannot solve for s3 without assistance. Moreover, given that it cannot do so, it naturally assumes that s1, which adds a PDE to the s3 system, must be overdetermined.

The assistance required for DSolve to obtain the solution given in the question, 0.5 x, is as follows. First, verify that 0.5 x really solves both the s1 and s3 systems. For s1 (with u replaced by f for notational consistency),

{D[f[x, y], x, x] + D[f[x, y], y, y] == 0, D[f[x, y], x, y] == 0,
f[x, 0.5] == 0.5*x, (D[f[x, y], x] /. y -> 0.5) == 0.5,
(D[f[x, y], y] /. y -> 0.5) == 0} /. f -> Function[{x, y}, 0.5*x]
(* {True, True, True, True, True} *)

Similarly, the s3 systems yields {True, True, True, True}.

The solution, 0.5 x, can be derived using Mathematica as follows. First, solve the s3 system with no boundary conditions.

DSolve[{D[f[x, y], x, x] + D[f[x, y], y, y] == 0}, f, {x, 0, 1}, {y, 0, 1}][[1, 1]]
(* f -> Function[{x, y}, C[I x + y] + C[-I x + y]] *)

and insert it into the s1 system.

{D[f[x, y], x, x] + D[f[x, y], y, y] == 0, D[f[x, y], x, y] == 0,
f[x, 0.5] == 0.5*x, (D[f[x, y], x] /. y -> 0.5) == 0.5,
(D[f[x, y], y] /. y -> 0.5) == 0} /. %
(* {True,
C'[0.5 + I x] + C'[0.5 - I x] == 0,
C[0.5 + I x] + C[0.5 - I x] == 0.5 x,
C'[0.5 + I x] - I C'[0.5 - I x] == 0.5,
C'[0.5 + I x] + C'[0.5 - I x] == 0} *)

Note that the second and fifth terms are identical, again indicating that the s1 and s3 systems are, indeed, equivalent. Next, eliminate True and the redundant term from the list and bring all parts of each equation to the left side for convenience to obtain.

eqs = Subtract @@@ (% // Union // Rest)
(* {-0.5 x + C[0.5 + I x] + C[0.5 - I x],
-0.5 + I C'[0.5 + I x] - I C'[0.5 - I x],
C'[0.5 + I x] + C'[0.5 - I x]} *)

Now, solve systematically for C and C.

Expand[eqs[] + I eqs[]];
sc1 = Simplify[DSolve[(% /. (0.5 + I x) -> z) == 0, C[z], z,
GeneratedParameters -> C1] /. z -> (0.5 + I x)][[1, 1]]
(* C[0.5 + I x] -> (0. - 0.125 I) + (0.25 + 0. I) x + C1 *)

Expand[eqs[] - I eqs[]];
sc2 = Simplify[DSolve[(% /. (0.5 - I x) -> z) == 0, C[z], z,
GeneratedParameters -> C2] /. z -> (0.5 - I x)][[1, 1]]
(* C[0.5 - I x] -> (0. + 0.125 I) + (0.25 + 0. I) x + C2 *)

eqs[] /. {sc1, sc2} /. (0. + 0. I) -> 0
(* C1 + C2 *)

Thus, the two additional constants C1 and C2 sum to zero.

ComplexExpand[(C[I x + y] + C[-I x + y]) /. y -> 0.5 /. {sc1, sc2}]
/. (0. + 0. I) -> 0 /. % -> 0
(* 0.5 x *)

Perhaps, this systematic solution of the toy problems in the question will be of help in solving conceptually similar but more difficult problems.