# Finding all the roots at once numerically

I want to calculate the roots of equations like

tanh(ax) = x

numerically. But the problem is sage gives option of finding just one root provided I give it the interval where the root may be found.

(tanh(1.5*x)==x).find_root(0.5,2)


But sometimes the interval is not so obvious and I need to know all the numerical roots at once (If the number of roots are finite that is). Is There a way to do that?

edit retag close merge delete

Sort by » oldest newest most voted

Returning only one root in a given interval is not a limitation of Sage, per se. Without any sort of "insight" into the given function, the number of roots, whether there are an infinite number of roots, or the approximate locations of the roots are all impossible to determine.

In practice, one must have some understanding the behavior of the function in order to use numerical methods to find all roots.

In the given case $f(x) = \tanh(a \cdot x) - x$:

• If $a \leq 1$, then the only root of $f(x)$ is $x = 0$.

• If $a > 1$, then there are three distinct roots: $0$, $r$, and $-r$. It can be shown that $0 < r < 1$.

more

but wolfram alpha does give all the numerical solutions in most of the cases. If roots are not finite, wolfram alpha returns some of the roots. So, can this functionality be implemented in sage also? You are right. it is necessary to understand the behavior of the function.

( 2011-05-05 11:27:46 -0600 )edit

I doubt that wolfram alpha does anything much more sophisticated than using a sort of process of elimination, where each failure to find a root over a given interval eliminates the possibility of a root existing in that interval. In that sense, yes, this heuristic can be implemented in Sage. However, this probably is not very useful for most applications, where at least some information can be obtained about the system.

( 2011-05-05 14:44:11 -0600 )edit

Thank you!

( 2011-06-26 20:53:49 -0600 )edit

## Stats

Seen: 1,880 times

Last updated: May 05 '11