function bolgepakker

clear all;
N = 1200;
x = linspace(-30,30,N);
lambda0 = 1.0;
v0 = 1.0;
k0 = 2*pi/lambda0;
w0 = v0*k0;
a = 0.1;
% Antall fourierkomponenter (oddetall)
nk = 25;
for i = 1:nk
    k(i) = k0*(1+a*(2*i-nk-1)/(nk-1));
    w(i) = v0*k(i);
    % Gaussisk form ("klokkeform") i k-rommet
    b(i) = exp(-4*(2*i-nk-1)^2/(nk-1)^2);
end;
% Reflektert pakke
for i = 1:N
    yr(i)=0.25*exp(-0.1*(x(i)+15)^2)*cos(6*x(i));
    yt(i)=1.0*exp(-0.1*(x(i)-15)^2)*cos(3*x(i));
end;
tsum = 0.0;
rsum = 0.0;
for i = 1:N
    tsum = tsum + yt(i)^2;
    rsum = rsum + yr(i)^2;
end;
plot(x,yr,x,yt);
xlabel('Posisjon');
ylabel('Utsving');
forholdet = 2*rsum/tsum