How do I find the code for the $c$ values where $x^2 + x + c + 1$ has a double root?

77 Views Asked by At

Sage question: Define the polynomial ring $\Bbb Q[c][x]$.Find the $c$ values where $x^2 + x + c + 1$ has a double root.

Sage code I have used to answer the first part "Define the polynomial ring $\Bbb Q[c][x]$".

K.<c>=QQ['c']    
R.<x>=K[]

f=x^2+x+c+1    
f

How do I find the code for the $c$ values where $x^2 + x + c + 1$ has a double root? Also, can you give some examples so that I can construct some programming code in sage?

P.S: This is a sage question. I know that for $c=-\frac 34$ this will be a square but I want the command that I can run in Sage to get this result in Sage. I asked it here but got the downvotes and I don't know why! If someone will downvote me here then please explain to me what do I have to include. I have given a code that I used to answer the first part "Define the polynomial ring $\Bbb Q[c][x]$", so this is my try.

1

There are 1 best solutions below

4
On BEST ANSWER

The question regarding the values of $c$ that make $f$ have double roots is solved for my taste via:

sage: R.<x,c> = PolynomialRing(QQ)
sage: f = x^2 + x + c + 1
sage: f.discriminant(x)
-4*c - 3

There is no need to have explicitly an equation now, solve it, get the one value. Well, if this not needed complication step is needed, then note that solve is not the method to be used now. We are inside a polynomial ring, the last line, the result -4*c - 3 has parent

sage: f.discriminant(x).parent()
Multivariate Polynomial Ring in x, c over Rational Field

and solve is properly used in the world of expressions. To see the difference, one would have now to introduce

sage: var('X,C');
sage: f(X,C)
X^2 + C + X + 1
sage: f.discriminant(x)(X,C)
-4*C - 3
sage: solve( f.discriminant(x)(X,C) == 0, C )
[C == (-3/4)]

to see the last line explicitly.

The second question, "Can you give..." has the answer "Yes, i can". Take a look at the introductions in sage, for instance:

http://sagebook.gforge.inria.fr/ :: Sagebook, Calcul mathématique avec sage

or the many books / publications on

http://www.sagemath.org/library-publications.html, there is also a Books session.


Later EDIT, an lternative solution, as suggested by LutzL, and discussion.

We use the nested structure as in the post.

sage: R.<c> = QQ[]
sage: S.<x> = R[]
sage: ( x^2 + x + c + 1 ).discriminant().roots(multiplicities=0)
[-3/4]

The result gives us the impression that everything went fine. To see what may have wrong, consider the code in a slightly different situation:

sage: ( x^2 + x + c^3 + 2 ).discriminant().roots(multiplicities=0)
[]

Here we have an empty result, have still to look at the intermediate point,

sage: ( x^2 + x + c^3 + 2 ).discriminant()
-4*c^3 - 7

and realize that the discriminant (built w.r.t. $x$, because of the correct order of nesting, a thing that we always have to think twice when things "go wrong") is a polynomial in $c$ without roots in $\Bbb Q$. So i am more or less determined to consider the "intermediate result" of the polynomial in $c$ as the object to be studied further. Or just use an expression in a variable C, and solve for C explicitly,

sage: var('C');
sage: for sol in solve( ( x^2 + x + c^3 + 2 ).discriminant()(C) == 0, C ):
....:     print sol
....:     
C == 1/8*4^(2/3)*(I*7^(1/3)*sqrt(3)*(-1)^(1/3) - 7^(1/3)*(-1)^(1/3))
C == 1/8*4^(2/3)*(-I*7^(1/3)*sqrt(3)*(-1)^(1/3) - 7^(1/3)*(-1)^(1/3))
C == 1/4*7^(1/3)*4^(2/3)*(-1)^(1/3)
sage: 

Many times i got problems when using nested structures in sage. (Here it works, and it has the didactical advantage of fixing $\Bbb Q[c][x]=\Bbb Q[c,x]$.) And in fact, i am expecting in the computation of the discriminant w.r.t. $x$ in the other solution that the result is in $\Bbb Q[c]$, by structure. The sage implementation uses still the big ring.