Using a curve as an attracting manifold
This is a math post.
I was wondering how easy it is to build a dynamical system with a user-defined attracting curve, e.g., a sine wave. You pick a point and if it starts on the curve, then it remains there, otherwise it smoothly gets attracted to the curve as increases.
I don't recall where I first saw this, but I think it's a standard construction.
Let's say is our function and the curve of interest is , where . Since we want to build a dynamical system, we will assume that and depend on . To simplify matters, we assume , i.e., constant speed on the x axis and movement from left to right. Now we just need to find the right behavior for .
How to get to behave the way we want?
We can first define . We would want to be decreasing when and increasing when . An easy way to do this: fix a and require that
which is an ODE with solution . This immediately gives
As time passes, "forgets" the initial deviation and behaves like . How quickly that happens depends on the magnitude of .
And so we indeed have a deviation that keeps
with target manifold (here ).

In the plot above, the white curve is . The rest of the colorful curves are the trajectories of random points -- over time they converge to (as they should, by construction). You can also see the vector field as little arrows -- this shows how a point should move over time.
Extending to variable gain
We can also let be a function of :
The same deviation variable satisfies
so
which means:
In this case the memory of the initial deviation does not have to go away, i.e., we could pick so that we never quite stabilize.
Extending to generic curves in
As long as the curve is reasonable (smooth and without sharp corners), we can define a vector field that has the curve as a stable manifold. That more or less follows the previous ideas.
Find the manifold given the vector field
What if we have a vector field and we want to find the attracting manifold? We will assume is a smooth vector field, e.g., .
First of all, given a point , will evolve according to the ODE
This uniquely identifies the trajectory .
We now want to find such that can identify the attracting manifold. To do this, we first set to behave like before on the trajectories, i.e., pick and
We would like to incorporate in this (cause it controls how the trajectories move). If we use chain rule on (and since ) and re-arrange:
This is a transport PDE for ! We can solve it with the method of characteristics. The solution is
where identifies the characteristic we are on and is some arbitrary function, e.g., .
At this point, I asked ChatGPT to write the TeX for the previous example, see below:
Example from before
For our vector field (from before), the characteristics satisfy
Since , we can use as the time variable. Then
Define the residual along the characteristic,
Then
So
Equivalently,
This quantity labels the characteristic. Therefore the general solution of the transport PDE is
where is arbitrary.
Choosing gives
and therefore the attracting manifold is