8
$\begingroup$

Laplace equation:

$\frac{\partial ^2u(x,y)}{\partial x^2}+\frac{\partial ^2u(x,y)}{\partial y^2}=0$

with Dirichlet boundary conditions:

$u(0,y)=\sin (3 \pi y)\\u(1,y)=0\\u(x,0)=0\\u(x,1)=\sin (4 \pi x)\\(x,y)\in \Omega,\space\space\Omega=[0,1]\times[0,1]$

Following code returns sum of zeroes

DSolve[{
D[u[x, y], {x, 2}] + D[u[x, y], {y, 2}] == 0,
u[0, y] == Sin[3*Pi*y],
u[1, y] == 0,
u[x, 0] == 0,
u[x, 1] == Sin[4*Pi*x]}, 
u[x, y], {x, y} \[Element] Rectangle[{0, 0}, {1, 1}]]

(* {{ u[x, y] -> Inactive[Sum][0, {K[1], 1, ∞}] }} *)

I know closed-form solution

$u(x,y)=\frac{\sinh (3 \pi (1-x)) \sin (3 \pi y)}{\sinh (3 \pi )}+\frac{\sin (4 \pi x) \sinh (4 \pi y)}{\sinh (4 \pi )}$

$\endgroup$
5
  • 1
    $\begingroup$ Well, that's... strange. This may be a bug; what version of MM are you using? (I can reproduce this behavior on MM 10.4.1 on a Mac.) $\endgroup$ Nov 28, 2016 at 15:38
  • $\begingroup$ @MichaelSeifert I'm using 11 version. If I remember correctly, v10 DSolve cannot solve over the region $\endgroup$
    – xhF731
    Nov 28, 2016 at 15:57
  • $\begingroup$ while NDSolve works perfectly... $\endgroup$
    – Stitch
    Nov 29, 2016 at 2:25
  • 1
    $\begingroup$ well, i think we can consider it a bug. $\endgroup$ Nov 29, 2016 at 21:14
  • 3
    $\begingroup$ I recommend that you send this to Wolfram, Inc as a bug to be fixed. DSolve is a very buggy function, and we need to encourage Wolfram, Inc to fix it. $\endgroup$
    – bbgodfrey
    Nov 30, 2016 at 4:22

2 Answers 2

1
$\begingroup$

With

$Version
(* 11.1.1 for Microsoft Windows (64-bit) (April 18, 2017) *)

the code in the question now returns

(* Inactive[Sum]
   [Csch[Pi*K[1]]*DiscreteDelta[-3 + K[1]]*Sin[Pi*y*K[1]]*Sinh[Pi*(1 - x)*K[1]] + 
    Csch[Pi*K[1]]*DiscreteDelta[-4 + K[1]]*Sin[Pi*x*K[1]]*Sinh[Pi*y*K[1]], 
   {K[1], 1, Infinity}] *)

The nonzero terms correspond to K[1] == 3 and K[1] == 4. The simplest way to extract them is

(%[[1]] /. K[1] -> 3) + (%[[1]] /. K[1] -> 4)
(* Csch[3 π] Sin[3 π y] Sinh[3 π (1 - x)] + Csch[4 π] Sin[4 π x] Sinh[4 π y] *)

Activate also works but requires additional steps to simplify the result.

Evidently, the DSolve bug has been fixed for the code in question.

Addendum

As I noted in a comment on the answer by David Baghdasaryan, Piecewise does not seem to function as one might hope when only one of two variables is included in its conditions. This can be circumvented by including both variables, for instance by

Piecewise[{{Sin[3*Pi*y], x == 0 && 0 < y < 1}, {0, x == 1 && 0 < y < 1}, 
    {0, y == 0 && 0 < x < 1}, {Sin[4*Pi*x], y == 1 && 0 < x < 1}}, 0]

But, inserting this expression into dcond leads to the same nonsense answer that was cited in the original question.

(* {{u[x, y] -> Inactive[Sum][0, {K[1], 1, Infinity}]}} *)

I do not know whether this qualifies as a bug.

$\endgroup$
0
$\begingroup$

I think you should use DirichletCondition function to specify boundary conditions in this case. This is probably first solution:

 leqn = Laplacian[u[x, y],{x, y}] == 0;
dcond = DirichletCondition[
   u[x, y] == 
    Piecewise[{{Sin[3*Pi*y], x == 0}, {0, x == 1}, {0, 
       y == 0}, {Sin[4*Pi*x], y == 1}}, 0], True];
omega = Rectangle[{0, 0}, {1, 1}];
(sol = FullSimplify@
   DSolve[{leqn, dcond}, u[x, y], {x, y} \[Element] omega])

However, I still don't know why it is ignoring the second solution.

$\endgroup$
1
  • $\begingroup$ Piecewise is returning only the first expression, Sin[3*Pi*y] (for x == 0) and zero otherwise. Reverse the order of the terms in Piecewise, and it will instead return only Sin[4*Pi*x] (for y == 1) and zero otherwise. $\endgroup$
    – bbgodfrey
    May 5, 2017 at 0:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.