Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a problem in using EventLocator in Mathematica 9. However, this error doesn't show up in Mathematica 8 on my labtop.

My code is,

η=G[x[n],y[n]];

pde = {x''[n] == -(1 - (x'[n]^2 + y'[n]^2)/(4*x[n]^2))*(3*x'[n] + 
        2*x[n]^2*\!\(
\*SubscriptBox[\(\[PartialD]\), \(x[n]\)]V\)/V) + (x'[n]^2 - y'[n]^2)/
     x[n], y''[n] == -(1 - (x'[n]^2 + y'[n]^2)/(4*x[n]^2))*(3*y'[n] + 
        2*x[n]^2*\!\(
\*SubscriptBox[\(\[PartialD]\), \(y[n]\)]V\)/V) + 
     2*(x'[n]*y'[n])/x[n]};
bc = {x[0] == saddle, y[0] == 0.01, x'[0] == 0, y'[0] == 0};
Sol = NDSolve[{pde, bc}, {x, y}, {n, 0, 1000}, MaxSteps -> 50000, 
  AccuracyGoal -> Automatic, 
  Method -> {"EventLocator", "Event" -> η - 1, 
    "EventCondition" -> (n > 60)}]

The error message is,

NDSolve::evboo: The value of the event function at n = 61.76853457162405` was not True or False. When not True, the value will be considered as False. >>

This is quite strange as there is no problem in running this on Mathematica 8.

share|improve this question
    
Thanks for editing it in a nice format. How can I post my codes in that way? (It is my first time uploading codes) –  mastrok Jan 13 at 8:47
    
mastrok, welcome to the site, and thank you for caring about the formatting of your posts. On every edit box there is a small yellow circle with white "?" in it; click that to bring up an editing help bar. Clicking "Code" on that bar will bring up a guide for formatting code. Also see mathematica.stackexchange.com/editing-help (The same as the "advanced help" link on that bar.) More directly there are a series of buttons above the editing box; fifth in from the left is a "{ }" button which will format a selection as code, or you can just press Ctrl+K. –  Mr.Wizard Jan 13 at 8:53
    
Er… where's the definition of V and G and saddle? –  xzczd Jan 14 at 3:03
    
V and G are smooth function of x and y (their expressions are quite long). I was trying to solve the equations of motions of a dynamical system. V can be regarded as some potential while G is a function calculating a geometrical property of V. saddle is the saddle point of V. This code works on my laptop (mathematica 8) but fails on my desktop (version 9) –  mastrok Jan 14 at 6:11
    
Without a complete code sample, it'll be hard for others to figure out the reason… If the original definitions of V and G are really long, you can provide a simplified version reproducing your problem. BTW, if you add @xzczd at the beginning of the comment, I'll get a remind. –  xzczd Feb 4 at 6:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.