/ tutorials / laplace-dirichlet
Sign in
tutorials / laplace-dirichlet
laplace-dirichlet / src / matlab / lp_lexact.m
37 lines · 1.4 KBCodeBlameHistory
088be4cAn interactive tutorial on the Dirichlet problem, accuracy against costJeremy Magland 1function U = lp_lexact(kind, X, Y)
2% LP_LEXACT Exact solutions on the L-shaped domain (-1,1)^2 minus the quadrant
3% x > 0, y < 0.
4%
5% The re-entrant corner sits at the origin, with interior angle 3*pi/2 between
6% the edge y = 0, x > 0 and the edge x = 0, y < 0. Measuring the angle from the
7% first of those, counterclockwise, the domain is 0 < theta < 3*pi/2, and
8%
9% s(r, theta) = r^(2/3) sin(2 theta / 3)
11% is harmonic there and vanishes on both edges of the corner. It is the slowest
12% decaying member of the family r^(2k/3) sin(2k theta/3) that a general
13% Dirichlet datum excites, and it is the reason the corner is a problem: s is
14% continuous, but its gradient is infinite at the origin and it has no second
15% derivative there, so every convergence rate derived from a Taylor expansion
16% is void.
18% 'sing' the singular function alone
19% 'smooth' log|z - z0| with z0 outside the domain: harmonic, and smooth right
20% up to the corner, so the corner costs nothing
21% 'both' the sum, which is the generic case
22z0 = 1.6 + 1.3i;
23th = atan2(Y, X);
24th(th < -1e-13) = th(th < -1e-13) + 2*pi; % theta in [0, 3*pi/2] on the domain
25r = sqrt(X.^2 + Y.^2);
26sing = r.^(2/3) .* sin(2*th/3);
27smooth = 0.5 * log((X - real(z0)).^2 + (Y - imag(z0)).^2);
29switch kind
30 case 'sing'
31 U = sing;
32 case 'smooth'
33 U = smooth;
34 otherwise
35 U = sing + smooth;
36end
37end
↑↓ move↵openescclose