Suppose I have a function $f(x)$ (for drawing purposes, I will image it to be $2D$). Is there some sort of dynamics/set of differential equations etc that allows me to move around the orbit defined by the level set $$ f^{-1}(c) = \{x\,:\, f(x) = c\} $$ It would look something like this.
- 5,153
-
@hardmath I think the gradient should be perpendicular to the level set. Mmm I'd rather not use a parametrization, as I don't know the shape of the orbit. But, say, given I can evaluate the function $f()$ at any point and compute related quantities (e.g. $f'(x)$) I would like to find a way to move around it – Euler_Salter May 19 '21 at 16:50
-
2Adding some motivation (why is this problem important?) would improve your Question, and possibly lead to more useful responses. In general one would not know that the orbit (level set) through a point is a bounded curve, but your intended application might yield such information. – hardmath May 19 '21 at 18:14
2 Answers
If $P(t)$ is your moving point, what you want is that the velocity vector $\dot{P}(t)$ is orthogonal to the gradient $\nabla f$. So if $\nabla f = [a(x,y), b(x,y)]$ you might try $$\eqalign{\dot{x} &= b(x,y)\cr \dot{y} &= -a(x,y)\cr} $$ where $x$ and $y$ are the cartesian coordinates of $P(t)$.
- 448,999
Just to clarify, the function is $f:\mathbb{R^2}\to\mathbb{R}$. right? Suppose you already found a single point $x$ with $f(x)=c$. You now want to find a tangent to the level-set at $x$.
Such a tangent vector $t$ is orthogonal to the vector of derivatives $\begin{pmatrix} \partial_{x_1} f(x) \\ \partial_{x_2}f(x)\end{pmatrix}$. In $2D$ there is always a unique (up to scaling) orthogonal vector, for example $\begin{pmatrix} -\partial_{x_2} f(x) \\ \partial_{x_1}f(x)\end{pmatrix}$.
Now for a numerical algorithm, you should do this:
- find a first value of $x$ with $f(x)=c$ (possibly using newton method or something similar)
- find a tangent $t$ as explained before.
- go a little bit in that direction, i.e. set $x'=x+\epsilon t$ (for some small number $\epsilon$). This $x'$ will of course not exactly be in the level-set (but it should be very close)
- find a new value for $x$ in the level set, close to $x'$ (probably one or two iterations of newton method starting at $x'$ is enough)
- go back to step 2 and repeat as long as you want
Edit: as a differential equation, this essentially is: $$x'(t) = \begin{pmatrix} -\partial_{x_2} f(x) \\ \partial_{x_1}f(x)\end{pmatrix}$$ which you can solve with any numerical method you like (Runge-Kutta...). Though to improve accuracy, you should occasionaly do a newton-step to get exactly into the level-set again. The differential equation alone will drift away over time (though very slowly if the numerical integration scheme is good and $\epsilon$ is small enough)
- 5,061
-
Thank you! Do you know of any theory on similar problems and can you point me to some terminology/books? – Euler_Salter May 19 '21 at 16:54
-
1No idea what this method would be called, sorry. It should be noted that it only works if the level-set is connected , and also it gets quite complicated in higher dimension than 2D. The most important algorithm for drawing level-sets in 3D (which are 2D surfaces of course), that also works for disconnected shapes is the "marching cubes algorithm" (google it, there are plenty of resources. It is comonly used in computer graphics) – Simon May 19 '21 at 16:59
-
There is also a way to make this level set attracting if you are interested in having a closed trajectory only for this value of constant. – Evgeny May 20 '21 at 08:08
