function U = lp_bexact(X, Y) % LP_BEXACT Ground truth for the interior Dirichlet problem on a curve. % % A sum of point sources placed outside the curve, % % u(z) = sum_k c_k log|z - z_k| , % % which is harmonic everywhere except at the sources and therefore harmonic on % the whole of the interior. Its trace on the curve is the Dirichlet data, and % it is the exact solution by construction, to full precision at every point. zk = [1.8 + 0.9i, -1.5 - 1.7i, 0.2 + 2.4i]; ck = [1.0, -0.7, 0.5]; U = zeros(size(X)); for k = 1:numel(zk) U = U + ck(k) * 0.5 * log((X - real(zk(k))).^2 + (Y - imag(zk(k))).^2); end end