ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 18 Jul 2020 14:22:37 -0500How to calculate discriminant using symmetric polynomials?https://ask.sagemath.org/question/52558/how-to-calculate-discriminant-using-symmetric-polynomials/I want to calculate discriminants using symmetric polynomials. I am working on the quadratic discriminant first. Here is my attempt:
P.<x1,x2>=PolynomialRing(QQ)
S=SymmetricFunctions(P.base_ring())
e = S.elementary()
e(S.from_polynomial((x1-x2)^2))
this produces
e[1, 1] - 4*e[2]
How can I convert this output to b^2 - 4 * a * c?
Thank yourain1Sat, 18 Jul 2020 14:22:37 -0500https://ask.sagemath.org/question/52558/discriminant of multivariate polynomialhttps://ask.sagemath.org/question/50317/discriminant-of-multivariate-polynomial/If I do
R.<x,z,I>=QQ[]
f_str = 'x**3 + x*z +1'
f = eval(f_str)
f.discriminant(x)
this works out correctly, giving
-4*z^3 - 27
But if I instead replace the coefficient of any monomial with a rational, such as
R.<x,z,I>=QQ[]
f_str = '1.0*x**3 + x*z +1'
f = eval(f_str)
f.discriminant(x)
I get the following error:
AttributeError: 'MPolynomial_polydict' object has no attribute 'discriminant'
Can someone explain how to make it work?physicistSat, 21 Mar 2020 03:50:29 -0500https://ask.sagemath.org/question/50317/Action of lattice automorphism group on discriminant grouphttps://ask.sagemath.org/question/40645/action-of-lattice-automorphism-group-on-discriminant-group/I have a lattice $L$ with automorphism group $G=Aut(L)$. The action of $G$ on $L$ should induce an action on the discriminant group $D={\tilde L}/L$ such that we have a group homomorphism $\phi: Aut(L) \rightarrow Aut(D)$. The kernel of this map will be a normal subgroup $N$ of $G$. I need to be able to compute the action of the quotient $G/N$ on $D$. In the actual example I am interested in $L$ has rank $20$ and is defined through its Gram Matrix. $L$ is an even lattice. A simpler model of this situation would be to take $L$ to be a root lattice, say the $A_2$ root lattice to be concrete, $Aut(L)$ is the dihedral group $D_6$ arising as the product of the $Z_2$ outer automorphism and the $S_3$ Weyl group of $A_2$. The dual lattice $\tilde L$ is the weight lattice of $A_2$ and the discriminant group ${\tilde L}/L$ is $Z_3$ with one non-trivial automorphism, taking $g \rightarrow g^{-1}$. In this simple case everything is computable by hand, but for the case I am interested in I only have $Aut(L)$ presented in terms of $20 \times 20$ matrix generators and computing by hand seems too difficult. Can anyone provide any hints on how to get sage to do this? I can compute $Aut(L)$ and $Aut(D)$ using sage, my problem is in figuring out how to determine $N$ and the action of the quotient $G/N$ on $D$.jahTue, 16 Jan 2018 14:37:35 -0600https://ask.sagemath.org/question/40645/Evaluating discriminant of a polynomial in Z_n[x]/<x^r-1>https://ask.sagemath.org/question/33879/evaluating-discriminant-of-a-polynomial-in-z_nxxr-1/Consider the following code
Zn=Zmod(n)
R = PolynomialRing(Zn,'x')
F = R.quotient((x**r)-1)
y=F((x+1))
f=F(y**n)
Clearly **f** will be a polynomial in xbar , I want to consider this polynomial as a polynomial in $ \mathbb{Z}[x] $ and evaluate its discriminant.
I tried **"f.polynomial()"** but it is not working. Any suggestions ? vishbWed, 22 Jun 2016 01:10:18 -0500https://ask.sagemath.org/question/33879/Discriminant of multivariate polynomials with complex coefficientshttps://ask.sagemath.org/question/31761/discriminant-of-multivariate-polynomials-with-complex-coefficients/I would like to compute the discriminant of some polynomial in two variables, x and z, the discriminant should be computed with respect to x.
I am able to do so in certain cases, but not when the coefficients are complex numbers written in a certain way.
For example, this works:
R.<z> = QQ[]
S.<x> = R[]
p = x**2 - z**2
p.discriminant()
gives:
4*z^2
But when I try to use a complex coefficient, discriminant fails because the expression is regarded as a symbolic expression, instead of a polynomial
q = x**2 - z**2 * I
q.discriminant()
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'discriminant'
Curiously, if I use instead
q = x**2 - z**2 * 1j
q.discriminant()
this gives the correct answer.
Now for particular reasons I really need to deal with 'I' as the complex unit, and cannot use 'j'. What's wrong with 'I'?
physicistTue, 22 Dec 2015 13:31:47 -0600https://ask.sagemath.org/question/31761/Plotting parametric matrix discriminantshttps://ask.sagemath.org/question/24881/plotting-parametric-matrix-discriminants/Greetings, I am struggling with the problem concerting characteristic polynomial determinants. I'm intending to plot curves in the (a,b)-plane of parametric matrices, which signal the points of some eigenvalues being zero. To this end, I use the following code
var('a b')
A = matrix([[a+sqrt(-1)b,-1,0],[-1,0,-1],[0,-1,a-sqrt(-1)b]])
p=A.charpoly('t')
d=p.discriminant()
region_plot(d>=0, (a,-4,1), (b,-4,1),incol='gray',figsize=5,axes=true)
which however produces the error
File "handle_error.pyx", line 90, in sage.libs.pari.handle_error._pari_handle_exception (build/cythonized/sage/libs/pari/handle_error.c:1178) sage.libs.pari.gen.PariError: incorrect type in gtofp
Printing the discriminant explicitly and then plotting it works fine
var('a b')
A = matrix([[a+sqrt(-1)*b,-1,0],[-1,0,-1],[0,-1,a-sqrt(-1)*b]])
p=A.charpoly('t')
d=p.discriminant()
d2=-4*b^2*a^4 + (-8*b^4 - 40*b^2 + 4)*a^2 + (-4*b^6 + 24*b^4 - 48*b^2 + 32)
region_plot(d2>=0, (a,-2,2), (b,-2,2),incol='gray',figsize=5,axes=true)
although both quantities seem to be of the same type
<type 'sage.symbolic.expression.Expression'>
any ideas about what am I missing?mamuteekSun, 16 Nov 2014 05:35:12 -0600https://ask.sagemath.org/question/24881/pariError when computing discriminanthttps://ask.sagemath.org/question/9233/parierror-when-computing-discriminant/Consider the following piece of code:
Qx.<x> = PolynomialRing(Rationals())
K = NumberField(x^2+1, 'a')
OOK = K.ring_of_integers() #K.maximal_order() has same effect
OOa = OOK.extension(x^3+2, 'alpha'); OOa
This returns "`Univariate Quotient Polynomial Ring in alpha over Maximal Order in Number Field in a with defining polynomial x^2 + 1 with modulus alpha^3 + 2`". Why is this the case? I would have expected it to have the same effect as
Qx.<x> = PolynomialRing(Rationals())
00b = ZZ.extension([x^3+2,x^2+1], 'beta,b'); OOb
Namely, that it returns `"Relative Order in Number Field in beta with defining polynomial x^3 + 2 over its base field`".
Moreover, and perhaps more interestingly, when one tries to run the command `OOa.discriminant()` after the first piece of code, "`PariError: (5)`" is returned. Running the analogous command, `OOb.absolute_discriminant()` after the second piece of code, one gets -746496. I presume the fact that these two commands return different results is explained in [Quotients of Univariate Polynomial Rings](http://www.sagemath.org/doc/reference/sage/rings/polynomial/polynomial_quotient_ring.html "Quotients of Univariate Polynomial Rings") when it says
> The discriminant of the quotient polynomial ring need not equal the discriminant of the corresponding number field, since the discriminant of a number field is by definition the discriminant of the ring of integers of the number field.
even though we are not computing the discriminant of a number field in the second piece of code. However, why is a pariError returned when trying to compute the discriminant of `OOa`? Surely this must be somehow linked to the fact that the two blocks of code return completely different things. Is this indeed the case? Any help would be appreciated.
Leonhard MoosbruggerTue, 14 Aug 2012 02:58:15 -0500https://ask.sagemath.org/question/9233/is there a formula about the same absolute_discriminant but different absolute_polynomial?https://ask.sagemath.org/question/10857/is-there-a-formula-about-the-same-absolute_discriminant-but-different-absolute_polynomial/some same degree polynomial,different terms,but absolute_discriminant is same
foe example:Q[zeta3,2^1/3],absolute_polynomial=x^6 - 3*x^5 + 6*x^4 - 11*x^3 + 12*x^2 + 3*x + 1
absolute_discriminant=-1 * 2^4 * 3^7,but when I find from LMFDB.org by absolute_discriminant or absolute_polynomial, polynomial given =x^6 - 3*x^5 + 5*x^3 - 3*x + 1
two polynomial has same discriminant,is there more this kands of polynomials?
http://www.lmfdb.org/NumberField/?natural=x%5E6+-+3*x%5E5+%2B+6*x%5E4+-+11*x%5E3+%2B+12*x%5E2+%2B+3*x+%2B+1&search=Go
http://cjsh716.blog.163.com/blog/static/213847199201311245475450/
cjshMon, 23 Dec 2013 22:48:55 -0600https://ask.sagemath.org/question/10857/Problems with computing discriminants and resultants.https://ask.sagemath.org/question/7944/problems-with-computing-discriminants-and-resultants/I have been trying to prepare a class on algebraic geometry, and make some exercises (involving resultants and discriminants of polynomials) in sage.
I have noticed the following:
1) Discriminant is not defined for multivariate polynomial rings (handled by libsingular), they could be easily implemented by something like
f.resultant(f.derivative(y),y)
Other option would be to convert our polynomials to a univariate polynomial ring (over a ring with the other variables), and then use the function defined in univariate rings. But this has the following problem:
2) Both discriminant and resultants are defined for univariate polynomial rings, but they raise an error when the variable is not 'x', and there are more variables in the base ring. I think it can be solved in three possible ways:
- Go back to the multivariate case and use the approach above.
- Change the name of the variables, in such a way that the variable of the univariate polynomial ring is called 'x', compute the resultant/discriminant and then change the names back.
- Make pari forget about the other variables involved, making them live not in a polynomial ring, but in its base field. The computation works fine there, and then we can convert the result (who lives in the fraction field, back to the original ring.
See an example:
R.<x,y>=QQ[]
f=R(x^2+y^3-1)
gf=f.polynomial(R(y))
gf.base_ring()(gf.change_ring(gf.base_ring().fraction_field()).discriminant())
I plan to submit a patch with some of this solutions, but i would like to know what do you think would be the best approach.mmarcoTue, 15 Feb 2011 01:17:34 -0600https://ask.sagemath.org/question/7944/