% check WKB eigenvalue accuracy (against numerical shooting method via ODE45) % barnett 4/18/08 k = @(x) 2-x.^2; q = @(x) k(x).^2; b = 1; % end of interval n=1:30; % which eigenvalues to check l_wkb = (3*pi*n/5).^2; % WKB formula from worksheet l = []; figure; for j=1:numel(n) l(j) = fzero(@(l) shooting(l, q, b), l_wkb(j)); fprintf('l_WKB = %g\t l_EXACT = %g\t relative error = %g\n', ... l_wkb(j), l(j), (l_wkb(j)-l(j))/l(j)); [yend t y] = shooting(l(j), q, b); % get the eigenfunction subplot(5,6,j); plot(t, y(:,1), '-'); hline(0); drawnow; end figure; loglog(1./sqrt(l), (l_wkb-l)./l, '+'); xlabel('eps'); ylabel('rel err'); title('rel error vs eps = 1/l^{1/2}: appears to be O(eps^2)');