JuliaHomotopyContinuation / HomotopyContinuation.jl

A Julia package for solving systems of polynomials via homotopy continuation.
https://www.JuliaHomotopyContinuation.org
MIT License
175 stars 30 forks source link

What is the best way to approximate trigonometric functions in HC #568

Closed 00krishna closed 2 months ago

00krishna commented 3 months ago

Hello. I was wondering if it is possible to approximate trigonometric functions in HC? I was experimenting with a simple mechanical system, just to learn the package. So I started with looking for the fixed points of a simple pendulum.

The system is:

$$ \begin{align} x_1 &= x_2\ x_2 &= -\frac{g}{L}\sin{x_1} \end{align} $$

I set $g = 9.8, L = 1$.

So this system does not work natively in HC because of the trig function.

I tried using the Taylor series approximation for the $sin$ function instead. This returns the root at $[0, 0]$, but not the root at $[\pi, 0]$. Here is the code.

    @var x[1:2]; # declare the variables x and y

    f1 = x[2]
    f2 = -9.8*(x[1] - x[1]^3/factorial(3) + x[1]^5/factorial(5))
    H = System([f1, f2])
    result3 = HomotopyContinuation.solve(H)
    real_solutions(result3)

Hence I was wondering if there is a better way to approximate trig functions in the HC system? Like should I use a complex function, or something else. Or is there a way to set the domain for the search of the roots so that I can capture the second root at $[\pi, 0]$.

PBrdng commented 3 months ago

Hi,

unfortunately, there is no support for trigonometric functions. While in principle, it is possible to do homotopies for any analytic functions, our software only supports polynomial functions. The reason is that for polynomial systems there is a theory for start systems, so that the software can find all zeros of a given system. Such a theory does not exist for analytic functions, simply because there can be infinitely many roots (for instance, $\cos(x) = 0$).

In your example, the software correctly computes the 5 complex roots of f2. One of them is real. The Taylor approximation is only good locally around 0, that is why you will not find $\pi$.

PBrdng commented 2 months ago

Closed