Help with Finding the Number of Roots with an Interval using Complex Contour Integration

247 Views Asked by At

I need help finding the existence of roots within an interval $[a,b]$ of a difficult "ill-behaved" function $f(x)$ that is non-negative ($f(x) \ge 0$). So, one person suggested complex contour integration. However, I don't know what that means, nor where to start. Any help will be appreciated. Simply put, I want a way to find a way to tell if there are roots in between $[a,b]$, where $a$ and $b$ are real, positive numbers and both are greater than $1$. Any code should be written for Python 3.x (though JavaScript will also be accepted). A running-time analysis of the algorithm would be nice too. For example purposes, use: $$f(x)=10^3(\sin^2\left(\frac{15\pi}{x}\right)+\sin^2(\pi x)).$$

3

There are 3 best solutions below

8
On

The estimation of the number of roots is trivial: check "many" points. Trying to approximate the possible roots (and checking that are roots) is the problem. Quotes form Newton Raphson Method for double roots (Henning Makholm an Ian):

The usual fast convergence of Newton-Raphson depends on the function having a nonzero derivative at the root.

The solution:

There is a modified Newton method which can detect proximity to a non-simple root and modify $f$ in such a way that quadratic convergence is recovered. If you know the order of the root is $n$, then you can use $$x_{k+1} = x_k - n \frac{f(x_k)}{f'(x_k)}.$$

10
On

For your particular function, there's only one way you can get a root: for \begin{align*} \frac{15\pi}{x}&=k\pi\\ \pi x&=\ell\pi, \end{align*} for integers $k,\ell.$ We can rewrite as \begin{align*} \frac{15}{x}&=k\\ x&=\ell, \end{align*} so that we are looking for integers that divide evenly into $15.$ You will have zeros, therefore, precisely at $\pm 1, \pm 3, \pm 5,$ and $\pm 15.$

8
On

The person who suggested complex analysis was likely thinking of the argument principle. Before using this method, please note that the factor of $10^3$ out front is irrelevant for finding zero. I will leave it off, therefore. The first thing to do is to find the derivative: \begin{align*} f(x)&=\sin^2\left(\frac{15\pi}{x}\right)+\sin^2(\pi x)\\ f'(x)&=-2\left(\frac{15\pi}{x^2}\right)\sin\left(\frac{15\pi}{x}\right)\cos\left(\frac{15\pi}{x}\right)+2\pi\sin(\pi x)\cos(\pi x). \end{align*} The trickest part of using contour integration for anything is choosing the contour. In this case, let us suppose we want to find the roots of $f$ in the interval $(a,b).$ An open interval works better for our purposes, because it would be difficult to find an enclosing contour that would not pick up more roots. We need a simple, closed contour such that this interval on the real line is entirely enclosed in it. So, let $\varepsilon>0.$ Then I choose the contour $\gamma$ given by the circle centered at $c=(b+a)/2$ of radius $r=(b-a)/2.$ We can parametrize this as: $$z=c+r\cos(\theta)+ir\sin(\theta)=c+re^{i\theta},\;\text{for}\;0\le\theta\le 2\pi. $$ This would yield $$dz=ire^{i\theta}\,d\theta. $$ Then the argument principle says that $$\int_\gamma\frac{f'(z)}{f(z)}\,dz=2\pi i(Z-P), $$ where $Z$ is the number of zeros inside $\gamma,$ and $P$ is the number of poles inside $\gamma.$ If $0\not\in(a,b),$ then we can confidently say $P=0,$ so that \begin{align*} Z&=\frac{1}{2\pi i}\int_\gamma\frac{f'(z)}{f(z)}\,dz \\ &=\frac{1}{2\pi i}\int_\gamma\frac{-2\left(\frac{15\pi}{z^2}\right)\sin\left(\frac{15\pi}{z}\right)\cos\left(\frac{15\pi}{z}\right)+2\pi\sin(\pi z)\cos(\pi z)}{\sin^2\left(\frac{15\pi}{z}\right)+\sin^2(\pi z)}\,dz. \end{align*} Then you would plug in the parametrization for $z$ and turn the crank - I'd recommend Mathematica, and you might need to do it numerically anyway.