# Exiting CrossSlidingDiscontinuity in NDSolve to follow equilibrium curve

Mathematica Asked on December 3, 2020

I am trying to figure out how to get the solution curve to an NDSolve to slide along once it reaches a boundary and then to exit the CrossSlidingDiscontinuity once it reaches an equilbrium curve and follow the equilibrium curve back within a set boundary.

If the x[t] solution curve reaches the boundary edge on this interval [0,1] I needed it to slide along this boundary, hence I used CrossSlidingDiscontinuity. However once, the solution reaches the yellow equilibrium sine curve, I need it to exit the sliding discontinuity and follow the equilibrium curve. I tried using EventLocator (in the code below). It manages to fall back within [0,1] but does not follow the equilibrium sine curve. I attached the image of the plot below.

I also tried using two WhenEvents (one for when x[t] reaches 1 triggering the sliding and one where x[t] reaches the sine curve triggering to follow the sine curve) but only the sliding WhenEvent was triggered.

Here is my code:

normalDE2[x_, t_] := -(x + 1/2)*(x - 1/2)*(x - (1 + .1*Sin[t]));

testDE3[x_?NumberQ, t_] :=
If[0 < x < 1, normalDE2[x, t], -1*normalDE2[x, t]];

sol4 = NDSolve[{x'[t] == testDE3[x[t], t], x[0] == .75,
WhenEvent[{x[t] == 1, x[t] == 0},
{Print[t],"CrossSlidingDiscontinuity"}]},
x, {t, 0, 10},
Method -> {"EventLocator", "Event" -> {x[t] - (1 +.1*Sin[t])},
"EventAction" :> {{x[t] -> (1 + .1*Sin[t])}}}];

Plot[{x[t] /. sol4, (1 + .1*Sin[t])}, {t, 0, 10},
Frame -> True, GridLines -> Automatic]


Plot Image

## Related Questions

### Making histogram from a vector

1  Asked on June 24, 2021 by physmath

### Table Glitch / Error with binary data

0  Asked on June 23, 2021 by atlasgeo

### Separating list with nested sublists of different lengths

1  Asked on June 23, 2021

### The fastest way of raising indices of high rank tensor

2  Asked on June 23, 2021

### How to set a background color for a cell style via a command?

2  Asked on June 23, 2021 by ama

### Is there a Mathematica CUDA ode solver?

0  Asked on June 23, 2021

### Search in a Dataset

0  Asked on June 22, 2021 by andr-paschold

### How can I reduce the error estimate of numerical integration in Mathematica?

1  Asked on June 22, 2021 by pedro-morales

### Testing equivalence of analytical expressions like $x^2 -x == x(x-1)$

2  Asked on June 22, 2021

### how to construct a fancy bar chart

1  Asked on June 22, 2021

### Some doubts about symbolic equations in Wolfram Mathematica

1  Asked on June 22, 2021 by skyhawk

### How to make a table from two lists?

5  Asked on June 22, 2021 by user2895279

### How to use _Complex types in CUDAFunctionLoad?

0  Asked on June 22, 2021

### How to use export and schedule tasks to backup entire contents of an notebook at regular time intervals?

0  Asked on June 21, 2021

### Stationarity Check of TimeSeries

0  Asked on June 21, 2021 by curiousdatascientist

### prepend a column to grid

1  Asked on June 21, 2021

### Given a PGP public key, how can I extract its PGP fingerprint in hex, using v12.0?

1  Asked on June 21, 2021 by ool

### Non-linear equation

2  Asked on June 20, 2021 by armin-sharafi

### CharacterTable for symmetric groups $S_n$ with large $n$

1  Asked on June 20, 2021

### Why does Solve give me an expression with root in it for this equation?

1  Asked on June 20, 2021