ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 13 Jun 2015 17:48:40 -0500About finding roots of polynomials in specific domainshttp://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/ I have two polynomials $p(x)$ and $q(x)$ and I want to know if there are roots of the equation $\frac{p'}{p} = \frac{q'}{q}$ in the domain $(a,\infty)$ , where $a = max \{ roots(p), roots(q) \} $
This is the same as asking for the roots of the polynomial, $p'q - pq' = 0$ in the same domain.
- Can something in Sage help?Thu, 11 Jun 2015 16:31:40 -0500http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/Answer by B r u n o for <p>I have two polynomials $p(x)$ and $q(x)$ and I want to know if there are roots of the equation $\frac{p'}{p} = \frac{q'}{q}$ in the domain $(a,\infty)$ , where $a = max { roots(p), roots(q) } $</p>
<p>This is the same as asking for the roots of the polynomial, $p'q - pq' = 0$ in the same domain.</p>
<ul>
<li>Can something in Sage help?</li>
</ul>
http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?answer=27089#post-id-27089I would do as follows:
sage: r = p.derivative()*q - q*p.derivative()
sage: R_r = r.roots(RR)
This gives you the real roots of `r` in the variable `R_r`. Now to filter the roots that make sense to you, you need to compute the roots of `p` and `q`:
sage: R_p = p.roots(RR)
sage: R_q = q.roots(RR)
In `R_p` and `R_q`, you have the real roots of `p` and `q`, given as pairs with the root and the multiplicity. To find `a`:
sage: a = max([x[0] for x in R_p] + [x[0] for x in R_q])
And finally, the roots you want:
sage: R = [x in R_r if x[0] > a]
Fri, 12 Jun 2015 04:28:20 -0500http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?answer=27089#post-id-27089Comment by Wizq for <p>I would do as follows:</p>
<pre><code>sage: r = p.derivative()*q - q*p.derivative()
sage: R_r = r.roots(RR)
</code></pre>
<p>This gives you the real roots of <code>r</code> in the variable <code>R_r</code>. Now to filter the roots that make sense to you, you need to compute the roots of <code>p</code> and <code>q</code>:</p>
<pre><code>sage: R_p = p.roots(RR)
sage: R_q = q.roots(RR)
</code></pre>
<p>In <code>R_p</code> and <code>R_q</code>, you have the real roots of <code>p</code> and <code>q</code>, given as pairs with the root and the multiplicity. To find <code>a</code>:</p>
<pre><code>sage: a = max([x[0] for x in R_p] + [x[0] for x in R_q])
</code></pre>
<p>And finally, the roots you want:</p>
<pre><code>sage: R = [x in R_r if x[0] > a]
</code></pre>
http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?comment=27105#post-id-27105If I am reading the code correctly and R is a list, then you could try <code>len(R) == 0 </code>. If I misunderstood, then nevermind.Sat, 13 Jun 2015 17:48:40 -0500http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?comment=27105#post-id-27105Comment by Phoenix for <p>I would do as follows:</p>
<pre><code>sage: r = p.derivative()*q - q*p.derivative()
sage: R_r = r.roots(RR)
</code></pre>
<p>This gives you the real roots of <code>r</code> in the variable <code>R_r</code>. Now to filter the roots that make sense to you, you need to compute the roots of <code>p</code> and <code>q</code>:</p>
<pre><code>sage: R_p = p.roots(RR)
sage: R_q = q.roots(RR)
</code></pre>
<p>In <code>R_p</code> and <code>R_q</code>, you have the real roots of <code>p</code> and <code>q</code>, given as pairs with the root and the multiplicity. To find <code>a</code>:</p>
<pre><code>sage: a = max([x[0] for x in R_p] + [x[0] for x in R_q])
</code></pre>
<p>And finally, the roots you want:</p>
<pre><code>sage: R = [x in R_r if x[0] > a]
</code></pre>
http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?comment=27099#post-id-27099And what would be a command to check if R turned out to be empty? I need some kind of an error catching for that.Fri, 12 Jun 2015 12:58:16 -0500http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?comment=27099#post-id-27099Comment by Phoenix for <p>I would do as follows:</p>
<pre><code>sage: r = p.derivative()*q - q*p.derivative()
sage: R_r = r.roots(RR)
</code></pre>
<p>This gives you the real roots of <code>r</code> in the variable <code>R_r</code>. Now to filter the roots that make sense to you, you need to compute the roots of <code>p</code> and <code>q</code>:</p>
<pre><code>sage: R_p = p.roots(RR)
sage: R_q = q.roots(RR)
</code></pre>
<p>In <code>R_p</code> and <code>R_q</code>, you have the real roots of <code>p</code> and <code>q</code>, given as pairs with the root and the multiplicity. To find <code>a</code>:</p>
<pre><code>sage: a = max([x[0] for x in R_p] + [x[0] for x in R_q])
</code></pre>
<p>And finally, the roots you want:</p>
<pre><code>sage: R = [x in R_r if x[0] > a]
</code></pre>
http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?comment=27098#post-id-27098If you just wrote "p.roots()" would it give all the roots? (and not just the reals)Fri, 12 Jun 2015 12:57:23 -0500http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?comment=27098#post-id-27098Comment by Phoenix for <p>I would do as follows:</p>
<pre><code>sage: r = p.derivative()*q - q*p.derivative()
sage: R_r = r.roots(RR)
</code></pre>
<p>This gives you the real roots of <code>r</code> in the variable <code>R_r</code>. Now to filter the roots that make sense to you, you need to compute the roots of <code>p</code> and <code>q</code>:</p>
<pre><code>sage: R_p = p.roots(RR)
sage: R_q = q.roots(RR)
</code></pre>
<p>In <code>R_p</code> and <code>R_q</code>, you have the real roots of <code>p</code> and <code>q</code>, given as pairs with the root and the multiplicity. To find <code>a</code>:</p>
<pre><code>sage: a = max([x[0] for x in R_p] + [x[0] for x in R_q])
</code></pre>
<p>And finally, the roots you want:</p>
<pre><code>sage: R = [x in R_r if x[0] > a]
</code></pre>
http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?comment=27097#post-id-27097Thanks! Let me try this.Fri, 12 Jun 2015 12:56:35 -0500http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?comment=27097#post-id-27097Answer by vdelecroix for <p>I have two polynomials $p(x)$ and $q(x)$ and I want to know if there are roots of the equation $\frac{p'}{p} = \frac{q'}{q}$ in the domain $(a,\infty)$ , where $a = max { roots(p), roots(q) } $</p>
<p>This is the same as asking for the roots of the polynomial, $p'q - pq' = 0$ in the same domain.</p>
<ul>
<li>Can something in Sage help?</li>
</ul>
http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?answer=27090#post-id-27090Alternatively
def are_there_roots(p, q):
return FalseFri, 12 Jun 2015 06:48:19 -0500http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?answer=27090#post-id-27090Comment by vdelecroix for <p>Alternatively</p>
<pre><code>def are_there_roots(p, q):
return False
</code></pre>
http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?comment=27101#post-id-27101**max(roots(p), roots(q))** is ambiguous.Fri, 12 Jun 2015 15:55:34 -0500http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?comment=27101#post-id-27101Comment by tmonteil for <p>Alternatively</p>
<pre><code>def are_there_roots(p, q):
return False
</code></pre>
http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?comment=27094#post-id-27094@b-r-u-n-o wrote:
> I think it's hard f=or p′ and q′ to have a common root larger that the largest root of p and q...
What about, say, $p=q=x^3+8$ whose single real root is -2, but whose derivative have root 0 ?Fri, 12 Jun 2015 10:41:18 -0500http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?comment=27094#post-id-27094Comment by B r u n o for <p>Alternatively</p>
<pre><code>def are_there_roots(p, q):
return False
</code></pre>
http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?comment=27092#post-id-27092I think it's hard for $p'$ and $q'$ to have a common root larger that the largest root of $p$ and $q$... I am impressed by how exact yet uninformative this answer is!Fri, 12 Jun 2015 09:15:03 -0500http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?comment=27092#post-id-27092Comment by tmonteil for <p>Alternatively</p>
<pre><code>def are_there_roots(p, q):
return False
</code></pre>
http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?comment=27091#post-id-27091What if, for example, $p=q\neq 0$ or if $p'$ and $q'$ have a common root that is larger than $a$ ?Fri, 12 Jun 2015 07:56:14 -0500http://ask.sagemath.org/question/27086/about-finding-roots-of-polynomials-in-specific-domains/?comment=27091#post-id-27091