clive
- 118
- 0
I have to expand a plane wave in spherical waves by using
e^{i\vec{k}\cdot\vec{r}}=\sum_{n=0}^{\infty}i^n (2n+1)P_n(cos \theta) j_n(kr)
I wrote a MATLAB code (pasted below) in order to check this by plotting the two sides of the eq above. The graphs are similar but different. I do not know what is wrong with this ... I suppose there are some missing coefficients somewhere...?
clear all;
close all;
clc;
kr=0.1*i+6;
x=linspace(-1, 1, 100);
for(ii=1:100)
F_plane(ii)=exp(i*abs(kr)*x(ii));
end
for(ii=1:100)
F_approx(ii)=0;
for(order=0:150)
ASSOCLEG=legendre(order, x(ii));
F_approx(ii)=F_approx(ii)+i^order*(2*order+1)*besselj(order, abs(kr))*ASSOCLEG(1);
end
end
plot(x, real(F_plane), 'or', x, imag(F_plane), 'ob', x, real(F_approx), '-r', x, imag(F_approx), '-b')
e^{i\vec{k}\cdot\vec{r}}=\sum_{n=0}^{\infty}i^n (2n+1)P_n(cos \theta) j_n(kr)
I wrote a MATLAB code (pasted below) in order to check this by plotting the two sides of the eq above. The graphs are similar but different. I do not know what is wrong with this ... I suppose there are some missing coefficients somewhere...?
clear all;
close all;
clc;
kr=0.1*i+6;
x=linspace(-1, 1, 100);
for(ii=1:100)
F_plane(ii)=exp(i*abs(kr)*x(ii));
end
for(ii=1:100)
F_approx(ii)=0;
for(order=0:150)
ASSOCLEG=legendre(order, x(ii));
F_approx(ii)=F_approx(ii)+i^order*(2*order+1)*besselj(order, abs(kr))*ASSOCLEG(1);
end
end
plot(x, real(F_plane), 'or', x, imag(F_plane), 'ob', x, real(F_approx), '-r', x, imag(F_approx), '-b')
Last edited: