Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
00krishna opened this issue Mar 21, 2024 · 2 comments
Closed

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

00krishna opened this issue Mar 21, 2024 · 2 comments

Comments

@00krishna
Copy link

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
Copy link
Collaborator

PBrdng commented Mar 25, 2024

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
Copy link
Collaborator

PBrdng commented May 3, 2024

Closed

@PBrdng PBrdng closed this as completed May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants