NDSolve and conditions

*To*: mathgroup at smc.vnet.net*Subject*: [mg125504] NDSolve and conditions*From*: Niles <niels.martinsen at gmail.com>*Date*: Fri, 16 Mar 2012 06:31:15 -0500 (EST)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com

Hi I wish to solve the following system of ODEs in Mathematica: x'' = -200y - x y' = -2 The equations describe the equations of motion for a particle moving in 2D. This is easily done using NDSolve: solution = NDSolve[{x''[t] == -200y[t]-x[t], y'[t] == -2, x[0] == 0, x'[0] == 100, y[0] == 0}, {x[t], y[t]}, {t, 0, 5}] Now, I need to solve this for a range of random initial velocities. However, there is the restriction that the particle has to stay within -5<y<5. If it goes beyond that, I can't use the solution and I want to discard it. Is there a way to implement this into NDSolve? Best wishes, Niles.