Getting complex solution with Matlab ode45

40 Views Asked by At

I'm trying to solve such an ODE: $$U'(\alpha) = \frac{\alpha DU(\alpha) + A\alpha + C + \sqrt{BU(\alpha)}}{D(\alpha^2 - \alpha)}$$

with boundary condition $U(a) = 0.$

I have such a problem that if the solution of $y$ would have a complex component, such as $1.1462 + 0.0000i$. If I take the absolute value of the radicand, the generated solutions will no longer be complex. However, those solutions are not what I desire. Is there anything I can do to avoid this?

My Matlab code is like:

clearvars;
A=-4.32;
B=4;
C=1.2;
D=0.8;

a=0.2778;
odefun_mon_pc1=@(t,y) (t*D*y+A*t+C+sqrt(B*y))/((t*t-t)*D);
tspan2=[a 0.99];
options=odeset('Reltol',1e-10);
[t,y]=ode45(odefun_mon_pc1,tspan2,0.0001,options);
h_pc_mon=plot(t,y,'--blue','linewidth',1);