ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 27 Jun 2011 03:53:49 +0200Finding all the roots at once numericallyhttps://ask.sagemath.org/question/8105/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?
Thu, 05 May 2011 07:17:27 +0200https://ask.sagemath.org/question/8105/finding-all-the-roots-at-once-numerically/Answer by Kelvin Li for <p>I want to calculate the roots of equations like </p>
<p>tanh(ax) = x </p>
<p>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. </p>
<pre><code>(tanh(1.5*x)==x).find_root(0.5,2)
</code></pre>
<p>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?</p>
https://ask.sagemath.org/question/8105/finding-all-the-roots-at-once-numerically/?answer=12335#post-id-12335Returning 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$.Thu, 05 May 2011 15:25:53 +0200https://ask.sagemath.org/question/8105/finding-all-the-roots-at-once-numerically/?answer=12335#post-id-12335Comment by ebs for <p>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.</p>
<p>In practice, one must have some understanding the behavior of the function in order to use numerical methods to find all roots.</p>
<p>In the given case $f(x) = \tanh(a \cdot x) - x$:</p>
<ul>
<li><p>If $a \leq 1$, then the only root of $f(x)$ is $x = 0$.</p></li>
<li><p>If $a > 1$, then there are three distinct roots: $0$, $r$, and $-r$. It can be shown that $0 < r < 1$.</p></li>
</ul>
https://ask.sagemath.org/question/8105/finding-all-the-roots-at-once-numerically/?comment=21761#post-id-21761but 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.Thu, 05 May 2011 18:27:46 +0200https://ask.sagemath.org/question/8105/finding-all-the-roots-at-once-numerically/?comment=21761#post-id-21761Comment by ebs for <p>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.</p>
<p>In practice, one must have some understanding the behavior of the function in order to use numerical methods to find all roots.</p>
<p>In the given case $f(x) = \tanh(a \cdot x) - x$:</p>
<ul>
<li><p>If $a \leq 1$, then the only root of $f(x)$ is $x = 0$.</p></li>
<li><p>If $a > 1$, then there are three distinct roots: $0$, $r$, and $-r$. It can be shown that $0 < r < 1$.</p></li>
</ul>
https://ask.sagemath.org/question/8105/finding-all-the-roots-at-once-numerically/?comment=21545#post-id-21545Thank you! Mon, 27 Jun 2011 03:53:49 +0200https://ask.sagemath.org/question/8105/finding-all-the-roots-at-once-numerically/?comment=21545#post-id-21545Comment by Kelvin Li for <p>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.</p>
<p>In practice, one must have some understanding the behavior of the function in order to use numerical methods to find all roots.</p>
<p>In the given case $f(x) = \tanh(a \cdot x) - x$:</p>
<ul>
<li><p>If $a \leq 1$, then the only root of $f(x)$ is $x = 0$.</p></li>
<li><p>If $a > 1$, then there are three distinct roots: $0$, $r$, and $-r$. It can be shown that $0 < r < 1$.</p></li>
</ul>
https://ask.sagemath.org/question/8105/finding-all-the-roots-at-once-numerically/?comment=21760#post-id-21760I 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.Thu, 05 May 2011 21:44:11 +0200https://ask.sagemath.org/question/8105/finding-all-the-roots-at-once-numerically/?comment=21760#post-id-21760