# Mathematical LogicNumerical AnalysisUndergraduate MathAlgebra HelpRecreational Math M

1. Jul 17, 2011

### kriss2

Hi
a want to code implicite scheme for PDEs
u_t =a laplace u + L p_t
p_t = laplace p + u

pls help
I made a classical FEM discretization, but i dont know how to programe it.

(u(n+1)ij - un)/t = a ((u(n+1)(i-1j) -2 u(n+1)(ij) +u(n+1)(i+1 j))
/x2 + (u(n+1)(i j-1)-2u(n+1)(ij) + u(n+1)( i j+1 )/y2) +L (p(n+1)
-pn)/t

(p(n+1)ij - pn)/t = ((p(n+1)(i-1j) -2 p(n+1)(ij) +p(n+1)(i+1 j))
/x2 + p(n+1)(i j-1)-2p(n+1)(ij) + p(n+1)( i j+1 )/y2) + un

2. Jul 17, 2011

### pmsrw3

Re: Mathematical LogicNumerical AnalysisUndergraduate MathAlgebra HelpRecreational Ma

Well, it's not simple. What kind of help are you looking for? "i dont know how to programe it" is pretty broad. Do you want to know how to program a computer? Or are you asking how to efficiently solve a banded system of linear equations? Or what?

3. Jul 18, 2011

### kriss2

Re: Mathematical LogicNumerical AnalysisUndergraduate MathAlgebra HelpRecreational Ma

I have explicite method and I need something similar for implicite metod

k=1:T
Pold=P;
Uold=U;
i=2:X-1;
j=2:Y-1;
P(i,j)=Pold(i,j) ...
+ ((Pold(i-1,j)-2*Pold(i,j)+Pold(i+1,j))/X^2 ...
+ (Pold(i,j-1)-2*Pold(i,j)+Pold(i,j+1))/Y^2)*tau ...
+ Uold(i,j)

U(i,j)=Uold(i,j)+ ...
a *( (Uold(i-1,j)-2*Uold(i,j)+Uold(i+1,j))/X^2 ...
+ (Uold(i,j-1)-2*Uold(i,j)+Uold(i,j+1))/Y^2) ...
+ L*(P(i,j) - Pold(i,j));

figure(1)
Pcolor(U)
caxis([0 1.2])
colorbar

end

4. Jul 18, 2011

### pmsrw3

Re: Mathematical LogicNumerical AnalysisUndergraduate MathAlgebra HelpRecreational Ma

OK. For every i,j, you have an equation relating uij and pij at time n+1 to their values at time n. Let's suppose you have an m x m grid -- then these, together with the boundary conditions, give you 2m^2 equations in 2m^2 unknowns. You need to solve that big system of linear equations.

There are a few different algorithms for solving systems of linear equations. Good programming practice forbids re-inventing the wheel, and at this point you should find a library available for your software environment and use it. In particular, you want algorithms and libraries for "sparse" or "banded" matrices. Systems like this give very big matrices (e.g., if you're working on a 30 x 30 grid, you'll have an 1800 x 1800 matrix), most of whose elements are 0. A sparse matrix library will represent this matrix compactly (i.e., without using up 3240000 reals in your memory) and will solve it efficiently. Solving a general system of linear equations is O(n^3), but algorithms designed for sparse systems will do it in O(N), where N is the number of non-zero elements. This is a big deal for practical applications.

Last edited: Jul 18, 2011