Re: recording singularities of NDSolve

• To: mathgroup at smc.vnet.net
• Subject: [mg80529] Re: recording singularities of NDSolve
• From: Peter Pein <petsie at dordos.net>
• Date: Fri, 24 Aug 2007 02:03:34 -0400 (EDT)
• References: <fajnb6\$pcs\$1@smc.vnet.net>

```Judith Bunder schrieb:
> Hi,
>
> I have to solve a system of simultaneous equations and I have to solve them
> several times with varying initial conditions. I use something like this:
>
> Do[{c1 = i/imax, c2 = j /jmax,
>     sol[i, j] = First@NDSolve[eqns, coup, {t, 0,
>      100}]}, {j, 1, 5}, {i, 1, 5}]
>
> So, I solve the the problem 25 times with 5 different j values and 5 different
> i values. The variables c1 and c2 are the variable initial conditions. I have
> no problems with this part.
>
> My problem is, sometimes the solution diverges. This is good, I'm looking for
> divergent points. But, I want some method of recording where the solution
> diverges. I get the warning messages:
>
> NDSolve::ndsz At t=18.28484703670573` step size is effectively zero;
> singularity or stiff system suspected.
>
> so I could manually record this value of t. But, this isn't practical as
> several of my 25 solutions are usually divergent (and I also need to record
> the value of i and j). Is there any way to define something like t-div[i,j]
> which will record all these points where my solution diverges?
>
> Judy
>

Hi Judy,

you'll find the questionable value as f[[1,1,2]] where f is the
InterpolatingFunction object:

In[1]:=
Check[result = g /. First[NDSolve[{Derivative[1][g][x] == g[x]^2,
g[0] == 1}, g, {x, 0, 2}]],
Print["suspected singularity at x=", result[[1,1,2]] ]
]

NDSolve::ndsz :
At x == 0.9999997907551139`, step size is effectively zero; singularity
or stiff system suspected. More...

>From In[1]:=
"suspected singularity at x="0.9999997907551139

Out[1]=
InterpolatingFunction[{{0.,1.}},<>]

Note that NDSolve shall find a solution for 0<=x<=2. But because
x->1/(1-x) has got a singularity at x0=1 it integrates the equation as
it can and you can see from the output that result[[1]] is {{0.,1.}} and
therefore result[[1,1,2]] is the upper bound of the interval for which a
solution has been found.

HTH,
Peter

```

• Prev by Date: Re: FWHM, InterpolationFunction & Solve
• Next by Date: Re: Re: ParametricPlot3D from 5.2 to 6.0
• Previous by thread: Re: recording singularities of NDSolve
• Next by thread: Feature request