Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #12534 > unrolled thread
| Started by | barandiaran.juan@gmail.com |
|---|---|
| First post | 2012-12-03 08:31 +0000 |
| Last post | 2012-12-18 07:35 +0000 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Find all roots of an interpolating function (solution of a barandiaran.juan@gmail.com - 2012-12-03 08:31 +0000
Re: Find all roots of an interpolating function (solution of a JBB <barandiaran.juan@gmail.com> - 2012-12-18 07:35 +0000
Re: Find all roots of an interpolating function (solution of a JBB <barandiaran.juan@gmail.com> - 2012-12-18 07:35 +0000
| From | barandiaran.juan@gmail.com |
|---|---|
| Date | 2012-12-03 08:31 +0000 |
| Subject | Find all roots of an interpolating function (solution of a |
| Message-ID | <k9ho08$po$1@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[0] == Pi/3, x'[0] == 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
[toc] | [next] | [standalone]
| From | JBB <barandiaran.juan@gmail.com> |
|---|---|
| Date | 2012-12-18 07:35 +0000 |
| Message-ID | <kap6b8$45m$1@smc.vnet.net> |
| In reply to | #12534 |
Just for the record in case somebody else looks for the same question, here are some very interesting answers to this question: http://mathematica.stackexchange.com/questions/16439/find-all-roots-of-an-interpolating-function-solution-to-a-differential-equation
[toc] | [prev] | [next] | [standalone]
| From | JBB <barandiaran.juan@gmail.com> |
|---|---|
| Date | 2012-12-18 07:35 +0000 |
| Message-ID | <kap6bd$45r$1@smc.vnet.net> |
| In reply to | #12534 |
Oooopss, and the answer is also in the Mathematica tutorial: searching the Documentation Center of the help menu for "tutorial/NDSolveEventLocator" JBB
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web