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.Sun, 11 Mar 2018 18:49:25 +0100missing solutions in solvehttps://ask.sagemath.org/question/41475/missing-solutions-in-solve/Hi
SageMath 8.1, Windows 10, Jupyter Notebook.
why there are 3 missing solutions in S4 ?
forget()
t = var('t')
f_x = function('f_x')(t)
f_y = function('f_y')(t)
assume(t, 'real')
assume(t > 0)
assume(t < 2*pi)
f_x=cos(t)
f_y=1/2 *sin(2*t)
S4=solve(derivative(f_y,t)/derivative(f_x,t)==0,t)
show(S4)
fP=parametric_plot( (f_x, f_y), (t,0,2*pi))
for s in S4 :
p=point2d((f_x(t=s.rhs()),f_y(t=s.rhs())),size=30, rgbcolor=hue(0.75), marker='d', markeredgecolor='red')
#p2=point2d((f_x(t=s.rhs()+pi/2),f_y(t=s.rhs()+pi/2)),size=30, rgbcolor=hue(0.75), marker='d', markeredgecolor='red')
#p3=point2d((f_x(t=s.rhs()+pi),f_y(t=s.rhs()+pi)),size=30, rgbcolor=hue(0.75), marker='d', markeredgecolor='red')
#p4=point2d((f_x(t=s.rhs()+3*pi/2),f_y(t=s.rhs()+3*pi/2)),size=30, rgbcolor=hue(0.75), marker='d', markeredgecolor='red')
#show(fP+p+p2+p3+p4)
show(fP+p)Sat, 10 Mar 2018 19:35:19 +0100https://ask.sagemath.org/question/41475/missing-solutions-in-solve/Answer by Emmanuel Charpentier for <p>Hi</p>
<p>SageMath 8.1, Windows 10, Jupyter Notebook.</p>
<p>why there are 3 missing solutions in S4 ?</p>
<pre><code>forget()
t = var('t')
f_x = function('f_x')(t)
f_y = function('f_y')(t)
assume(t, 'real')
assume(t > 0)
assume(t < 2*pi)
f_x=cos(t)
f_y=1/2 *sin(2*t)
S4=solve(derivative(f_y,t)/derivative(f_x,t)==0,t)
show(S4)
fP=parametric_plot( (f_x, f_y), (t,0,2*pi))
for s in S4 :
p=point2d((f_x(t=s.rhs()),f_y(t=s.rhs())),size=30, rgbcolor=hue(0.75), marker='d', markeredgecolor='red')
#p2=point2d((f_x(t=s.rhs()+pi/2),f_y(t=s.rhs()+pi/2)),size=30, rgbcolor=hue(0.75), marker='d', markeredgecolor='red')
#p3=point2d((f_x(t=s.rhs()+pi),f_y(t=s.rhs()+pi)),size=30, rgbcolor=hue(0.75), marker='d', markeredgecolor='red')
#p4=point2d((f_x(t=s.rhs()+3*pi/2),f_y(t=s.rhs()+3*pi/2)),size=30, rgbcolor=hue(0.75), marker='d', markeredgecolor='red')
#show(fP+p+p2+p3+p4)
show(fP+p)
</code></pre>
https://ask.sagemath.org/question/41475/missing-solutions-in-solve/?answer=41492#post-id-41492**Note :** This was a good answer to the bad question. See below...
This smells of homework. Therefore, some hints .
You're trying to find the zeroes of $\displaystyle-\frac{\sin\left(t\right)}{\cos\left(2 \, t\right)}$ (expression quite easily obtained with Sage). A plot of this function (as easily obtained...) should help to convince you that this function has exactly one zero in the open interval $(0~2\pi)$ of $\mathbb{R}$. Proving it formally is also a good exercice.
However, this plot might also attract your attention to this function's *poles*, which aren't quite the same thing...
**Now for the _right_ question :**
Indeed, the default solver (Maxima's) gives only a partial solution to the *real* equation (i. e. $\displaystyle\frac{\cos(2t)}{sin(t)}=0$).
One can obtain a better set of solution with:
solve(cos(2*t),t,to_poly_solve="force")
[t == 1/4*pi + 1/2*pi*z40]
(see `solve`'s doc). But this doesn't fulfills the constraint $0\lt t\lt2\pi $.
Note that `sympy`'s solver is not really better :
sage: [s._sage_() for s in sympy.solve(cos(2*t),t)]
[1/4*pi, 3/4*pi]
`Mathematica` seems to be able to solve the system, but its answer can't currently be parsed back in Sage :
sage: S=[t>0,t<2*pi,cos(2*t)==0]
sage: mathematica.Solve(S,t)
{{t -> Pi/4}, {t -> (3*Pi)/4}, {t -> (5*Pi)/4}, {t -> (7*Pi)/4}}
Sun, 11 Mar 2018 08:58:10 +0100https://ask.sagemath.org/question/41475/missing-solutions-in-solve/?answer=41492#post-id-41492Comment by ortollj for <p><strong>Note :</strong> This was a good answer to the bad question. See below...</p>
<p>This smells of homework. Therefore, some hints .</p>
<p>You're trying to find the zeroes of $\displaystyle-\frac{\sin\left(t\right)}{\cos\left(2 \, t\right)}$ (expression quite easily obtained with Sage). A plot of this function (as easily obtained...) should help to convince you that this function has exactly one zero in the open interval $(0~2\pi)$ of $\mathbb{R}$. Proving it formally is also a good exercice.</p>
<p>However, this plot might also attract your attention to this function's <em>poles</em>, which aren't quite the same thing...</p>
<p><strong>Now for the _right_ question :</strong></p>
<p>Indeed, the default solver (Maxima's) gives only a partial solution to the <em>real</em> equation (i. e. $\displaystyle\frac{\cos(2t)}{sin(t)}=0$).</p>
<p>One can obtain a better set of solution with:</p>
<pre><code>solve(cos(2*t),t,to_poly_solve="force")
[t == 1/4*pi + 1/2*pi*z40]
</code></pre>
<p>(see <code>solve</code>'s doc). But this doesn't fulfills the constraint $0\lt t\lt2\pi $.</p>
<p>Note that <code>sympy</code>'s solver is not really better :</p>
<pre><code>sage: [s._sage_() for s in sympy.solve(cos(2*t),t)]
[1/4*pi, 3/4*pi]
</code></pre>
<p><code>Mathematica</code> seems to be able to solve the system, but its answer can't currently be parsed back in Sage :</p>
<pre><code>sage: S=[t>0,t<2*pi,cos(2*t)==0]
sage: mathematica.Solve(S,t)
{{t -> Pi/4}, {t -> (3*Pi)/4}, {t -> (5*Pi)/4}, {t -> (7*Pi)/4}}
</code></pre>
https://ask.sagemath.org/question/41475/missing-solutions-in-solve/?comment=41501#post-id-41501Hi Emmanuel
it is not the problem, I know the four points t=pi/4,pi/4 +pi/2,pi/4 +2*pi/2,pi/4+3*pi/2
the problem is why the command solve does not get the four solutions.(you put the expression upside down in your post above)
the question is why in this code below, S4 get only One of the fourth solution because I have precised :
assume(t < 2*pi)
forget()
t = var('t')
f = function('f')(t)
assume(t, 'real')
assume(t > 0)
assume(t < 2*pi)
f=cos(2*t)
S4=solve(f==0,t)
show(S4)
I think that if we did not specify the domain, as there is an infinity of solutions, the command Solve should provide a single solution, but when we specified the domain, the command solve should give all the solutions belonging to this domain.Sun, 11 Mar 2018 11:17:19 +0100https://ask.sagemath.org/question/41475/missing-solutions-in-solve/?comment=41501#post-id-41501Comment by Emmanuel Charpentier for <p><strong>Note :</strong> This was a good answer to the bad question. See below...</p>
<p>This smells of homework. Therefore, some hints .</p>
<p>You're trying to find the zeroes of $\displaystyle-\frac{\sin\left(t\right)}{\cos\left(2 \, t\right)}$ (expression quite easily obtained with Sage). A plot of this function (as easily obtained...) should help to convince you that this function has exactly one zero in the open interval $(0~2\pi)$ of $\mathbb{R}$. Proving it formally is also a good exercice.</p>
<p>However, this plot might also attract your attention to this function's <em>poles</em>, which aren't quite the same thing...</p>
<p><strong>Now for the _right_ question :</strong></p>
<p>Indeed, the default solver (Maxima's) gives only a partial solution to the <em>real</em> equation (i. e. $\displaystyle\frac{\cos(2t)}{sin(t)}=0$).</p>
<p>One can obtain a better set of solution with:</p>
<pre><code>solve(cos(2*t),t,to_poly_solve="force")
[t == 1/4*pi + 1/2*pi*z40]
</code></pre>
<p>(see <code>solve</code>'s doc). But this doesn't fulfills the constraint $0\lt t\lt2\pi $.</p>
<p>Note that <code>sympy</code>'s solver is not really better :</p>
<pre><code>sage: [s._sage_() for s in sympy.solve(cos(2*t),t)]
[1/4*pi, 3/4*pi]
</code></pre>
<p><code>Mathematica</code> seems to be able to solve the system, but its answer can't currently be parsed back in Sage :</p>
<pre><code>sage: S=[t>0,t<2*pi,cos(2*t)==0]
sage: mathematica.Solve(S,t)
{{t -> Pi/4}, {t -> (3*Pi)/4}, {t -> (5*Pi)/4}, {t -> (7*Pi)/4}}
</code></pre>
https://ask.sagemath.org/question/41475/missing-solutions-in-solve/?comment=41506#post-id-41506You are right. I should *never, ever* attempt to answer an ask.sage... question before the morning's tea has kicked up....Sun, 11 Mar 2018 18:49:25 +0100https://ask.sagemath.org/question/41475/missing-solutions-in-solve/?comment=41506#post-id-41506