Solving partial differential equation numerically

Click For Summary
The discussion revolves around the self-teaching efforts to solve a first-order partial differential equation (PDE) numerically using finite differences. The user has defined the function f(x,y) = sin(x-y) and derived the PDE ∂f/∂x + ∂f/∂y = 0, along with boundary conditions. They have opted for centered differences with equal spacings in the x and y directions, leading to a discretized equation. However, upon constructing the matrix to solve the linear system, they encounter a singular matrix issue. The user seeks clarification on whether their setup is correct or if the numerical method is inappropriate for the first-order PDE. They also reference second-order PDEs related to circular drum vibrations, indicating a desire for insights into their first-order problem. The key concern is the singularity of the matrix and the validity of the numerical approach for the defined PDE.
Telemachus
Messages
820
Reaction score
30
Hi there. I am trying to self teach how to solve partial differential equations numerically using finite differences. I know this is a complex field, that requires much more knowledge of the theory than what I actually know, but anyway I wanted to try.

Anyway, I've tried to build my own differential equation, probably naively. I wanted to solve a first order partial differential equation, so I thought of taking the function:

##f(x,y)=sin(x-y)##

And then, taking derivatives I build the differential equation:

##\displaystyle \frac{\partial f(x,y)}{\partial x}+\frac{\partial f(x,y)}{\partial y}=0##, and I considered the interval ##0\leq x \leq 1, 0\leq y \leq 1##

Then I considered the boundary conditions ##f(0,y)=\sin(-y)##, ##f(1,y)=\sin(1-y)##,##f(x,0)=\sin(x)## and ##f(x,1)=\sin(x-1)##.I think that everything is correct until here, but I'm not sure, if anything is wrong please tell me.

Then I considered centered differences (I needed for centered difference to have the previous and forward steps in the equation, in order to propagate the solution from the boundaries). I've considered equal spacings in the y and x directions, with ##x_i=i\Delta x=ih##, ##y_j=j\Delta y=j h##, and ##h=\frac{1}{N+1}##, with N being the number of interior points in each axis, being ##(x_0,y_j),(x_{N+1},y_j)## and ##(x_i,y_0),(x_i,y_{N+1})## the points situated at the boundaries of the domain.

Under this conditions I've arrived to the set of equations:

##u_{i+1,j}-u_{i-1,j}+u_{i,j+1}-u_{i,j-1}=0##

Where I thought that ##u_{i,j}\sim f(x_i,y_j)##

Then the discretized version of the boundary conditions would look like: ##u_{0,j}=\sin(-jh)##, ##u_{N+1,j}=\sin(1-jh)##, ##u_{i,0}=\sin(ih)## and ##u_{i,N+1}=\sin(ih-1)##.

But when I build the matrix and solve the linear system I get the result that the matrix is singular. So what would be the correct approach to this problem?
 
Technology news on Phys.org
Yes, but those are second order. I was interested in solving a first order partial differential equation. Is anything wrong with the problem I set up? is it just that the numerical approach isn't proper for this equation or I did something else wrong?
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 21 ·
Replies
21
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
Replies
31
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 3 ·
Replies
3
Views
874