% This program was used to test helmsolve submissions. % DPO 05/2005 % Set parameters. n = 10; kappa = 5; % Generate the Laplacian matrix K using a program % derived from an earlier homework, and generate % a random true solution wtrue. % The right-hand side is then generated % to match K, kappa, and wtrue. [K,f,rhs,h] = laplace2d(n); wtrue = rand(n^2,1) rhs = K*wtrue - kappa^2*wtrue; % Call helmsolve. f = reshape(rhs,n,n); w = helmsolve(kappa,f); % Reshape the solution as a vector % and compute the norm of the residual and % the norm of the error. % Both of these norms should be very small. wlong = reshape(w,n^2,1); resid = norm(K*wlong - kappa^2*wlong -rhs) err = norm(wtrue-wlong) % The following line can be used for checking. %wtrue = (K -kappa^2*speye(n^2))\rhs;