I want to solve the following equation, which has a complex part:
$\frac{\partial^2 y(x)}{\partial^2 x}-B(x)\frac{\partial y(x)}{\partial x}-i*A(x)y(x)=0$
I tried Runge-Kutta 4th order method, but it does not provide me with the correct result. I assume:
$f(x,y,z) = z$
$g(x,y,z) = B(x)z+i*A(x)y$
Where A(x) and B(x) are real values, while starting points are as follows:
$y(x_0)=10$
$z(x_0)=-0.1$
The solution should have shape as red curve, marked as 10GHz: Solution
I have used following Matlab code for this problem:
close all; clear variables;
h=0.01e-6; % step size
x = (-5e-6):h:(20e-6);
y = zeros(1,length(x));
z = zeros(1,length(x));
y(1) = 10; % y at x=-5e-6
z(1) = -1e-1; % dy/dx at x=-5e-6
dWdx = @(x) 2.3139e+13 * exp((-x.^2)/(2e-12));
W = @(x) integral(dWdx,-100e-6,x);
A = @(x) 7.8957e+03 *W(x);
B = @(x) 1/W(x)*dWdx(x);
f = @(x,y,z) z;
g = @(x,y,z) B(x)*z+ 1i*A(x)*y;
N=length(x);
for j=1:(N-1)
k0 = h*f(x(j),y(j),z(j));
L0 = h*g(x(j),y(j),z(j));
k1= h*f(x(j)+0.5*h,y(j)+0.5*k0,z(j)+0.5*L0);
L1= h*g(x(j)+0.5*h,y(j)+0.5*k0,z(j)+0.5*L0);
k2= h*f(x(j)+0.5*h,y(j)+0.5*k1,z(j)+0.5*L1);
L2= h*g(x(j)+0.5*h,y(j)+0.5*k1,z(j)+0.5*L1);
k3= h*f(x(j)+1*h,y(j)+1*k2,z(j)+1*L2);
L3= h*g(x(j)+1*h,y(j)+1*k2,z(j)+1*L2);
y(j+1)=y(j)+1/6*(k0+2*k1+2*k2+k3);
z(j+1)=z(j)+1/6*(L0+2*L1+2*L2+L3);
end
figure();
% plot(x,y./max(y));
plot(x,y);
xlim([-5 20]*1e-6);
grid on; hold on;
However, i dont get result even with proper shape. can someone help me either by transforming this equation to more "friendly" form or propose other method of solving this equation? Cheers