/ tutorials / laplace-dirichlet
Sign in
tutorials / laplace-dirichlet
laplace-dirichlet / src / matlab / lp_curve.m
25 lines · 827 BCodeBlameHistory
088be4cAn interactive tutorial on the Dirichlet problem, accuracy against costJeremy Magland 1function C = lp_curve(a, nlobe, t)
2% LP_CURVE A smooth closed curve and its first two derivatives.
3%
4% r(t) = 1 + a cos(nlobe t), x = r cos t, y = r sin t
5%
6% Returned as one matrix with columns [x y x' y' x'' y''] rather than as six
e5fc8c6An introduction and static figures, and the MATLAB written plainly againJeremy Magland 7% outputs: the callers want all six together and a single value keeps the
8% call sites short.
10% The curve is analytic and traversed counterclockwise, which is what makes the
11% trapezoid rule spectrally accurate on it and fixes the sign of the outward
12% normal (y', -x')/|(x', y')|.
13t = t(:);
14r = 1 + a * cos(nlobe * t);
15rp = -a * nlobe * sin(nlobe * t);
16rpp = -a * nlobe^2 * cos(nlobe * t);
17c = cos(t);
18s = sin(t);
19C = [r .* c, ...
20 r .* s, ...
21 rp .* c - r .* s, ...
22 rp .* s + r .* c, ...
23 rpp .* c - 2*rp .* s - r .* c, ...
24 rpp .* s + 2*rp .* c - r .* s];
25end
↑↓ move↵openescclose