       NDSolve bug?

• To: mathgroup at smc.vnet.net
• Subject: [mg127730] NDSolve bug?
• From: Nick Broderick <crazychessman at msn.com>
• Date: Fri, 17 Aug 2012 03:44:44 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-newout@smc.vnet.net
• Delivered-to: mathgroup-newsend@smc.vnet.net

```I am using NDSolve to simulate the motion of a particle under linear drag and constant acceleration directed such that the particle is always forced back towards the origin. There are two drag constants: one is applied when the particle moves back towards centre, the other when it is moving away from the origin. The particle experiences no acceleration or drag when it sits precisely on the origin. This creates five subcases in my equation of motion. (g, b and c are always positive, x0 and v0 are initial position and velocity, respectively.)

sol =
First[x /.
NDSolve[{x''[t] ==
Piecewise[{{-g - b*x'[t],
x[t] > 0 && x'[t] > 0}, {-g - c*x'[t],
x[t] > 0 && x'[t] <= 0}, {g - b*x'[t],
x[t] <= 0 && x'[t] <= 0}, {g - c*x'[t],
x[t] <= 0 && x'[t] > 0}}, 0], x' == v0,
x == x0}, x, {t, 0, T}, MaxSteps -> \[Infinity],
AccuracyGoal -> 3]];

In most cases for the calculation is fine. But when I try the special case x0=0 and v0=0 (or very small numbers, on the order of 10^0) my plot of the solution becomes almost chaotic. I thought the case x0=0 and v0=0 is covered by the default case in Piecewise so that the particle should not move at all under these conditions. What can I do to fix this?

```

• Prev by Date: Using a huge list of random numbers from random.org
• Next by Date: inverse function wrapper
• Previous by thread: Re: Using a huge list of random numbers from random.org
• Next by thread: Re: NDSolve bug?