Find a specific intersection point of line and Fourier series using Newton–Raphson method when graphs have more then one intersection points

220 Views Asked by At

I need to find an intersection point of two graphs in polar coordinates. First is defined by a simple line $y=kx+b$. Second — by Fourier series $$ r=r_{0} + \sum [a_{i}\cos(i\phi) + b_{i}\sin(i\phi)] $$

I transformed the line equation into polar coordinates: $$ r = \frac{b}{\sin\phi-k\cos\phi} $$

I know there is no hope for an analytic solution and I need to use a numerical method to find an intersection point.

This amounts to finding a root of $$ \left(r_{0} + \sum [a_{i}\cos(i\phi) + b_{i}\sin(i\phi)] \right)({\sin\phi-k\cos\phi}) - b = 0 $$

So I use the Newton–Raphson method to find it. Ok. It's working. But I have a problem, when these graphs have more then one root. I need to find root between two points, but Newton–Raphson method find first root and stops. It's better to understand in follow picture.enter image description here

I need to find root between A and B points (it's $(r_{1}; \phi_{1})$).

Here is code of Newton–Raphson method:

public static double NewtonRaphsonMethod(
    double x0,
    Func<double, double> f,
    Func<double, double> fd
)
{
    double eps = 0.0001;
    double xc = x0;
    double xn = xc;

    do
    {
        xc = xn;
        xn = xc - f(xc) / fd(xc);
    }
    while (Math.Abs(xn - xc) >= eps && Math.Abs(f(xn)) >= eps);

    return xn;
}
1

There are 1 best solutions below

0
On BEST ANSWER

I would say that this is a typical problem. But I could also ask : how did you guess the first root ?

Considering $$F(\phi)=\left(r_{0} + \sum [a_{i}\cos(i\phi) + b_{i}\sin(i\phi)] \right)({\sin\phi-k\cos\phi}) - b $$ and looking for the zero's of it, I see two methods (I use them) :

  • First method : use global minization of $F^2(\phi)$ and keep the points corresponding to values close to $0$ (this is not simple).
  • Second method : set $\phi_k=\phi_0+(k-1)\Delta\phi$ and search for $k$ such that $$F(\phi_k)\times F(\phi_{k-1})<0$$ It is not very elegant (just brute force) but it works. Start now Newton method at $\phi=\frac{\phi_k+\phi_{k-1}} 2$. If you already have a root $\phi^*$, start the search with $\phi_0=\phi^*$.