Finite difference derivatives for angle variables with jumps

157 Views Asked by At

I am looking to numerically approximate derivatives using finite differences, for instance

$$ \frac{d\phi}{dx} \approx \frac{\phi(x_i+h) - \phi(x_i)}{h} = (D \vec{\phi})_i, $$

where $D$ is the finite difference operator and $\vec\phi$ is a vector of samples. In my particular case, $\vec\phi$ will contain angles which may have jumps of $2\pi$ in them.

I am wondering what the preferred/most efficient way of dealing with this is. Specifically, if two consecutive samples differ by $2\pi$, the derivative should be $0$ and not $2\pi/h$.

Two ways that I could come up with to deal with this are

  • Take the result of the differentiation mod $2\pi/h$
  • Use the fact that $d\phi/dx = \operatorname{Im}(e^{-i\phi} \frac{de^{i\phi}}{dx} )$.
1

There are 1 best solutions below

1
On

Maybe you got the language wrong, but the correct way for the first case is $$\frac {d\phi}{dx}\approx\frac{\phi(x_{i+1})-\phi(x_i)}{(x_{i+1}-x_i) \rm{mod}\ (2\pi) }$$ The second approach is also valid, but if you use it in computations is much more expensive. And you still have the same problem: can $dx$ be greater than $2\pi$?