m11 = 1/(500 - s);
m22 = -m11;
m12 = I*1/(400 - s);
m21 = -m12; Vi=0; si=1; sf=3000;
Gammaad = Abs[m11]/Abs[m12];
{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?

  • $\begingroup$ Have you tried searching this site for the error you received? There are many questions on stiff systems $\endgroup$
    – MarcoB
    Apr 13, 2023 at 12:22
  • 1
    $\begingroup$ Please update your thread to include values of Vi, si and sf $\endgroup$
    – josh
    Apr 13, 2023 at 12:40
  • $\begingroup$ 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. $\endgroup$
    – Michael E2
    Apr 13, 2023 at 13:01
  • $\begingroup$ 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. $\endgroup$
    – Xzy
    Apr 13, 2023 at 13:55
  • 1
    $\begingroup$ FWIW, DSolve will solve the system exactly. $\endgroup$
    – Michael E2
    Apr 13, 2023 at 16:02

1 Answer 1


One cannot integrate the equation over s=400 because the derivative has a pole there

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

But the equation is solvable without the initial values in terms of Hypergeometric functions. Since the equations are linear, its easy to fit the two constants C[1], C[2] such that the initial values are met.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.