function result = Mie_abjv(m,x)



% Computes a matrix of Mie Coefficients, an, bn, 

% of orders n=1 to nmax, for given complex refractive-index

% ratio m=m'+im" and size parameter x=k0*a where k0= wave number in ambient 

% medium for spheres of radius a;

% Eq. (4.88) of Bohren and Huffman (1983), BEWI:TDD122

% using the recurrence relation (4.89) for Dn on p. 127 and 

% starting conditions as described in Appendix A.



%L=[200 bis 800]
M=dlmread('Brechungsindex.Gold3.txt');
L=M(:,1);
m=M(:,2);
a = 0.00000003;   % radius of sphere
k0=2*pi./L;
x=k0.*a; % size parameter 


z= m.*x;     % multipliziere elementeweise

n=1; nu = (n+0.5); % dipole mode n = 1



sx1=sqrt(0.5*pi*x);
sx2=sqrt(0.5*pi*z);

px1=sx1.*besselj(nu,x);  % spherical Bessel function
chx1=sx1.*bessely(nu,x);   %spherical Bessel function

px2=sx2.*besselj(nu,z);
chx2=sx2.*bessely(nu,z);

gsx1=px1+i*chx1;    % spherical Hankel function of second kind
gsx2=px2+i*chx2;

psi1=x.*px1;   % Riccarti - Bessel - Funktion
xi1=x.*gsx1;   % Riccarti - Bessel - Funktion

psi2=z.*px2;
xi2=z.*gsx2;


psidev1=diff(psi1,1);  %1. Ableitung der Riccarti-Bessel-Funktion
xidev1=diff(xi1,1);    %1. Ableitung der Riccarti-Bessel-Funktion

psidev2=diff(psi2,1);
xidev2=diff(xi2,1);
A=psi2.*psidev1;
an=((m.*psi2).*psidev1-psi1.*psidev2)/((m.*psi2).*xidev1-xi1.*psidev2);


da=dn./m+n./x; 

db=m.*dn+n./x;



an=(da.*px-p1x)./(da.*gsx-gs1x);

bn=(db.*px-p1x)./(db.*gsx-gs1x);



result=[an; bn];
end
