Re: Re: Getting the value of the independent var from the dep.var using NDSolve
- To: mathgroup at smc.vnet.net
- Subject: [mg63918] Re: [mg63891] Re: Getting the value of the independent var from the dep.var using NDSolve
- From: Pratik Desai <pdesai1 at umbc.edu>
- Date: Sun, 22 Jan 2006 00:52:32 -0500 (EST)
- References: <dptd4r$be$1@smc.vnet.net><dq2rgc$n0o$1@smc.vnet.net> <200601210650.BAA11261@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Borut Levart wrote: >Commenting on the last comment, I would like to say: >- what a nice differential-equation platform NDSolve is, >- and that the above example fails to find the peaks of Sin[x]: > >NDSolve[ > { > y'[x] == Cos[x], > y[0] == 0}, y, {x, 0, 20}, > Method -> { > "EventLocator", > "Event" -> y[x] - 1, > "EventAction" :> Sow[x] > } > ] // Reap > >Why is that? >I guess the solver steps over the event, which in turn is not noticed. >But could any algorithm not miss that? > > > If one is not afraid to use trignometry, one can try this Clear[y,x] sol1=NDSolve[{y'[x] == Cos[x],y[0] == 0}, y, {x, 0, 20},Method -> {EventLocator,"Event" ->Cos[x], "EventAction":> Sow[{x, y[x]}]}] // Reap {{{y -> InterpolatingFunction[{{0., 20.}}, <>]}}, {{{1.5708, 1.}, {4.71239, -1.}, {7.85398, 1.}, {10.9956, -1.}, {14.1372, 1.}, {17.2788, -1.}}}} Pratik
- References:
- Re: Getting the value of the independent var from the dep.var using NDSolve
- From: "Borut Levart" <BoLe79@gmail.com>
- Re: Getting the value of the independent var from the dep.var using NDSolve