       Find all roots of an interpolating function (solution of a

• To: mathgroup at smc.vnet.net
• Subject: [mg128885] Find all roots of an interpolating function (solution of a
• From: barandiaran.juan at gmail.com
• Date: Sun, 2 Dec 2012 04:59:00 -0500 (EST)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-newout@smc.vnet.net
• Delivered-to: mathgroup-newsend@smc.vnet.net

```Hi,

I'm trying to find all the roots of the solution to a differential equation.
Using NSolve or Reduce I don't get the roots, so I'm using an iterative method which I found in physicsforums.com.
This method solves my problem, but you have to choose the increment and thus in some cases it might give headaches. I wonder if there is any more general approach.
Following is a sample code:

IN:= data = NDSolve[{1.09 x''[t] - 0.05 x'[t] + 1.1759 Sin[x[t]] == 0,
x == Pi/3, x' == 0}, x, {t, 0, 50}]
OUT:= {{x->InterpolatingFunction[{{0.,50.}},<>]}}

IN:=sol = NSolve[x'[t] == 0 /. data , t]
OUT:=NSolve::ifun: Inverse functions are being used by NSolve, so some solutions may not be found; use Reduce for complete solution information. >>
OUT:={{t->InverseFunction[InterpolatingFunction[{{0.,50.}},<>],1,1][0.]}}

IN:=sol = Reduce[x'[t] == 0 /. data , t]
OUT:=Reduce::inex: Reduce was unable to solve the system with inexact coefficients or the system obtained by direct rationalization of inexact numbers present in the system. Since many of the methods used by Reduce require exact input, providing Reduce with an exact version of the system may help.  >>
OUT:=Reduce[{InterpolatingFunction[{{0.,50.}},<>][t]==0},t]

IN:=
dt=0.1;
tmin=0.;
tmax=50.;

Union[Table[t/.FindRoot[x'[t]==0/.data ,{t,tInit,tmin,tmax}],{tInit,tmin+dt,tmax-dt,dt}],SameTest->(Abs[#1-#2]<10^-2&)]

OUT:={0., 3.26812, 6.58301, 9.95657, 13.4054, 16.9538, 20.6403, 24.533, \
28.7857, 34.2571}

Thanks and best regards,

JBB

```

• Prev by Date: OutputResponse issue
• Next by Date: Re: V9 !!!
• Previous by thread: Re: OutputResponse issue
• Next by thread: Re: Find all roots of an interpolating function (solution of a