# How to handle this singularity？NDSolveValue::ndsz: At s == 399, step size is effectively zero; singularity or stiff system suspected

m11 = 1/(500 - s);
m22 = -m11;
m12 = I*1/(400 - s);
m21 = -m12; Vi=0; si=1; sf=3000;
{Aosol1, Aesol1} =
NDSolveValue[{I*Ao'[s] - (m11)*Ao[s] - (m12)*Ae[s] == 0,
I*Ae'[s] - (m21)*Ao[s] - (m22)*Ae[s] == 0, Ao[si] == Vi,
Ae[si] == Sqrt[1 - Vi^2]}, {Ao, Ae}, {s, si,
sf}]; // AbsoluteTiming


This error is reported as NDSolveValue::ndsz: At s == 399, step size is effectively zero; singularity or stiff system suspected. A singularity occurred at s=400 for m12, how should I handle it?

• Have you tried searching this site for the error you received? There are many questions on stiff systems Commented Apr 13, 2023 at 12:22
– josh
Commented Apr 13, 2023 at 12:40
• I have no problem up to s == 399.99999999618143, which is only a small step from s == 400. If you want to integrate past s == 400, you should explain more particularly how you want it done. It's not generally admitted in classical approaches. This simple approach is probably difficult here, since the system here is higher dimensional, nonautonomous, and one of the singularities is in the s-domain. Commented Apr 13, 2023 at 13:01
• I try add "Method -> {"FiniteElement", "MeshOptions" -> {"MaxCellMeasure" -> 1}}", it can solve this problem, but when the expression for m11 becomes very complex, this method calculates very slowly and even don't work. Is there any way to simplify the complex expression.
– Xzy
Commented Apr 13, 2023 at 13:55
• FWIW, DSolve will solve the system exactly. Commented Apr 13, 2023 at 16:02

I*Ao'[s] - 1/(500-s))*Ao[s] - I/(400-s)*Ae[s] == 0