APPOROXIMATE SOLUTION OF LAPLACE'S EQUATION
2 views (last 30 days)
Show older comments
PLEASE I HAVE THIS QUESTION:
APPROXIMATE THE SOLUTION OF LAPLACE'S EQUATION IN THE SQUARE ABCD FOR THE BOUNDARY CONDITIONS INDICATED BELOW WITH THE SPACING h=1/6 for the following values of the parameters.
α=0.9+0.1,k; k=0,1,2; β=1.01+0.02,n; n=0,1,2;
Carry out Iterations to within 10-²
J= 1 2 3 4 5 6
u/AD 0 17.28 29.05α 40.00 29.05β 17.28
u/BC 0 9.81 17.98 α 29.12 38.25 β 42.31
u/AB 0 0 0 0 0 0
u/DC 4.31 6.98 12.38 β 19.14 30.10 α 40.16
CAN YOU PLEASE HELP ME ON A PROGRAM TO GET IT SOLVED USING GAUSS SEIDEL I NEED TO SUBMIT IT IN 3 DAYS TIME, THANKS THESE ARE THE EQUATION I USED MANUALLY:
L1=0.25*(0+L6+L2+17.28)
L2=0.25*(L1+L7+L3+29.05α
L3=0.25*(L2+L8+L4+40)
L4=0.25*(L3+L9+L5+29.05β
L5=0.25*(L4+L10+6.98+17.28)
L6=0.25*(0+L11+L7+L1)
L7=0.25*(L6+L12+L8+L12)
L8=0.25*(L7+L13+L9+L3)
L9=0.25*(L8+L14+L10+L4)
L10=0.25*(L9+L15+12.38β+L5)
L11=0.25*(0+L16+L12+L6)
L12=0.25*(L11+L17+L13+L7)
L13=0.25*(L12+L18+L14+L8)
L14=0.25*(L13+L19+L15+L9)
L15=0.25*(L14+L20+19.14+L10)
L16=0.25*(0+L21+L17+L11)
L17=0.25*(L16+L22+L18+L12)
L18=0.25*(L17+L23+L19+L13)
L19=0.25*(L18+L24+L20+L14)
L20=0.25*(L19+L25+30.10α+L15)
L21=0.25*(0+0+L22+L16)
L22=0.25*(L21+9.81+L23+L17)
L23=0.25*(L22+17.98α+L24+L18)
L24=0.25*(L23+29.12+L25+L19)
L25=0.25*(L24+38.25β+40.16+L20)
2 Comments
Answers (1)
nick
on 14 Apr 2025
Hello Anie,
To approximate the solution of Laplace's equation using the Gauss-Seidel method in MATLAB, you can follow the steps below :
% Parameters
h = 1/6;
tol = 1e-2;
maxIter = 1000;
% Boundary conditions
uAD = [0, 17.28, 29.05, 40.00, 29.05, 17.28];
uBC = [0, 9.81, 17.98, 29.12, 38.25, 42.31];
uAB = [0, 0, 0, 0, 0, 0];
uDC = [4.31, 6.98, 12.38, 19.14, 30.10, 40.16];
% Initialize grid
L = zeros(5, 5);
alpha_values = 0.9 + 0.1 * (0:2);
beta_values = 1.01 + 0.02 * (0:2);
% Iterate over alpha and beta values
for alpha = alpha_values
for beta = beta_values
% Adjust boundary conditions with alpha and beta
uAD(3) = 29.05 * alpha;
uAD(5) = 29.05 * beta;
uBC(3) = 17.98 * alpha;
uBC(5) = 38.25 * beta;
uDC(3) = 12.38 * beta;
uDC(5) = 30.10 * alpha;
% Gauss-Seidel iteration
for iter = 1:maxIter
L_old = L;
for i = 1:5
for j = 1:5
if i == 1
top = uAB(j + 1);
else
top = L(i - 1, j);
end
if i == 5
bottom = uDC(j + 1);
else
bottom = L(i + 1, j);
end
if j == 1
left = uAD(i + 1);
else
left = L(i, j - 1);
end
if j == 5
right = uBC(i + 1);
else
right = L(i, j + 1);
end
L(i, j) = 0.25 * (top + bottom + left + right);
end
end
end
fprintf('Results for alpha=%.2f, beta=%.2f:\n', alpha, beta);
disp(L);
end
end
You can refer to the documentation by executing the following MATLAB Command Window to know more about MATLAB language fundamentals:
doc language-fundamentals
0 Comments
See Also
Categories
Find more on Numerical Integration and Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!