Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Getting the value of the independent var from the dep.var using NDSolve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64085] Re: Getting the value of the independent var from the dep.var using NDSolve
  • From: marks at wolfram.com
  • Date: Wed, 1 Feb 2006 04:34:16 -0500 (EST)
  • References: <dptd4r$be$1@smc.vnet.net><dqsohb$bui$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

An event is located when a change in sign in the event function
is detected. For the function Sin[x] - 1, the sign is practically
always negative and the chance of hitting zero is infinitessimal.

You can construct an appropriate event function by looking for
a turning point by considering:

D[Sin[x] - 1, x]

Then it is possible to use the Direction option to restrict the
detection to points corresponding to a maximum:

In[1]:=
  NDSolve[{y'[x] == Cos[x], y[0] == 0}, y, {x, 0, 20},
    Method -> {EventLocator, "Event" -> Cos[x],
	  "EventAction" :> Sow[x], "Direction" -> -1}] // Reap

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

>    {{1.5708, 7.85398, 14.1372}}}

Mark Sofroniou,
Research and Development,
Wolfram Research.

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?


  • Prev by Date: Re: How to get range of InterpolatingFunction?
  • Next by Date: String Input and Variable Setting
  • Previous by thread: Re: How to get range of InterpolatingFunction?
  • Next by thread: String Input and Variable Setting