% Analyzing the modified wavenumbers for various finite-difference formulae
% Written by Bartosz Protas for the course MATH745 (January 2004)
echo off, clc
clear all
 

N = 1e+5;
h = 2.0 * pi / N;
kmax = N / 2;
k = (1:kmax);

W(1,:) = sin(h*k) / h;
W(2,:) = (4.0*sin(h*k)/3.0 - sin(2.0*h*k)/6.0) / h;
W(3,:) = 3.0 * sin(h*k) ./ (2.0 * h + h * cos(h*k));

figure(1); plot(k,k,k,W(1,:),k,W(2,:),k,W(3,:));
legend('Exact','2nd ord central difference',...
       '4th ord central difference','4th ord Pade');
