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.Tue, 29 Jun 2021 22:48:32 +0200Index problemhttps://ask.sagemath.org/question/57817/index-problem/I am absolutely confused to ask a question that I think to have asked a lot of time but each time I am confused.
I have this simple code
x = list(var('x_%i' % i) for i in (0..1))
show(x)
Ineq = [x[1] + x[0] <= -2, x[1] >=0,x[0] >=0]
show(Ineq)
type(Ineq[0])
sol0=solve_ineq([x[0] + x[1] <= -2, x[1] >=0,x[0] >=0],[x[0],x[1]])
sol0
If I replace `(0..1)` by `(1..2)` whith the correction for the x[i], I have an error of the type `list index out of range`. Why ?CyrilleTue, 29 Jun 2021 22:48:32 +0200https://ask.sagemath.org/question/57817/I am trying to change the ring in sage.https://ask.sagemath.org/question/57808/i-am-trying-to-change-the-ring-in-sage/ I have been able to use .change_ring(FiniteField()) for finite fields. I was instructed to try .change_ring(IntergerModRing()) for other non finite fields but it is not working. What other commands could I try?JSCHWINGTue, 29 Jun 2021 17:15:25 +0200https://ask.sagemath.org/question/57808/Doubt about solve_ineqhttps://ask.sagemath.org/question/57791/doubt-about-solve_ineq/ This question is about the solution of `solve_ineq()`. Here is a simple system of 3 equations :
$x+y >= 3$, $2x-y <=6$ and $3 x-y <= 3$. The graphical representation is given by
f0(x)=3-x
f1(x)=2*x-6
f2(x)=1+(1/3)*x
p=plot(f0(x),x,1.48,3,thickness=3,ticks=None)
p+=plot(f1(x),x,3,4.2,thickness=3,ticks=None)
p+=plot(f2(x),x,1.48,4.2,thickness=3,ticks=None)
sol0=solve(f0==f1,x)
sol1=solve(f0==f2,x)
sol2=solve(f1==f2,x)
p+=point((sol0[0].rhs(),f1(sol0[0].rhs())), rgbcolor=(0.26, 0.80, 0.50),size=60, zorder=10,axes_labels=['$x_1$','$x_2$'])
p+=point((sol1[0].rhs(),f2(sol1[0].rhs())), rgbcolor=(0.26, 0.80, 0.50),size=60, zorder=10)
p+=point((sol2[0].rhs(),f1(sol2[0].rhs())), rgbcolor=(0.26, 0.80, 0.50),size=60, zorder=10)
p+=point((0,f2(sol2[0].rhs())), rgbcolor=(0.99, 0.86, 0.23),size=60, zorder=10)
p+=point((0,0), rgbcolor=(0.99, 0.86, 0.23),size=60, zorder=10)
p+=line([(0,0),(0,f2(sol2[0].rhs()))],rgbcolor=(.5, 0.5, 0.69),thickness=3, zorder=8)
p+=point((sol1[0].rhs(),0), rgbcolor=(1, 0.1, 0.5),size=60, zorder=10)
p+=point((sol2[0].rhs(),0), rgbcolor=(1, 0.1, 0.5),size=60, zorder=10)
p+=line([(sol1[0].rhs(),0),(sol2[0].rhs(),0)],rgbcolor=(1, 0.5, 0.69),thickness=3, zorder=8)
p+=polygon([(sol0[0].rhs(),f1(sol0[0].rhs())),(sol1[0].rhs(),f2(sol1[0].rhs())),(sol2[0].rhs(),f1(sol2[0].rhs()))], rgbcolor=(0.9098, 0.3804, 0))
p+=text("$\\mathrm{Points }\\,\\, \\mathrm{intérieurs}$",(2.8,1.2),color='white')
p+=text("$x_2=3-x_1$",(1.9,.6),rotation=-44.0, horizontal_alignment='left',color='white',fontsize=12)
p+=text("$x_2=2x_1-6$",(3.5,1.2),rotation=62.0, horizontal_alignment='left',color='white',fontsize=12)
p+=text("$0$",(-.15,0.1), horizontal_alignment='center',color='black',fontsize=12)
p+=text("$x_2=1+(1/3)x_1$",(2.4,2.),rotation=18.0, horizontal_alignment='center',color='white',fontsize=12)
p+=text(r"$\mathrm{Elimination}\,\, \mathrm{de}\,\, x_1$",(0.2,1.2),rotation=90.0, horizontal_alignment='center',color='white',fontsize=12)
p+=text(r"$\mathrm{Elimination}\,\, \mathrm{de}\,\, x_2$",(3,-0.4),rotation=0.0, horizontal_alignment='center',color='white',fontsize=12)
p+=line([(sol1[0].rhs(),0),(sol1[0].rhs(),f2(sol1[0].rhs()))],linestyle="--",color='white')
p+=line([(sol1[0].rhs(),0),(sol1[0].rhs(),f2(sol1[0].rhs()))],linestyle="--",color='white')
p+=line([(sol2[0].rhs(),0),(sol2[0].rhs(),f2(sol2[0].rhs())), (0,f2(sol2[0].rhs()))],linestyle="--",color='white')
p+=line([(0,0), (sol1[0].rhs(),0)],linestyle="--",color='black', zorder=8)
p.axes_color('white')
p.axes_label_color('white')
p.tick_label_color('white')
show(p,aspect_ratio=1,transparent=True,ticks=None)
![image description](/upfiles/16248254087668092.png)
The graphic shows clearly the interval of validity when $x$ is eliminated or when it's $y$. Now I use `solve_ineq()` which, if I understand use Maxima Fourier_Motzkin implementation on the same sytem :
var('x y') #déclarer x est facultatif
sol0=solve_ineq([x + y >= 3, 2*x - y <=6, 3*y-x <=3],[x,y])
show(sol0)
sol0[2]
As you can see the solution display the 3 points which are the vertices of the polygon. But if you look at `sol0[2]`, if I am not wrong there is a big mistake because the interval conditions are on $y$ when obviously, according the the graphics and my hand written calculations it should be on $x$
![image description](/upfiles/1624826282905778.png)
His this an error of mine or a bugg ?
CyrilleSun, 27 Jun 2021 22:40:04 +0200https://ask.sagemath.org/question/57791/Is it possible to compute a Gröbner basis of an ideal of a graded commutative algebra in SageMathhttps://ask.sagemath.org/question/57617/is-it-possible-to-compute-a-grobner-basis-of-an-ideal-of-a-graded-commutative-algebra-in-sagemath/Let me start by saying that I am a newbie to Sage.
Let us say I have a graded commutative algebra `A` using the command
`GradedCommutativeAlgebra`, and an ideal `I` of `A`.
For instance, something like the following (but this is just a toy example!):
sage: A.<x,y,z> = GradedCommutativeAlgebra(QQ, degrees=((1,1), (2,1), (3,2))
sage: I = A.ideal([z*y - x*y*y])
I would like to get a Gröbner basis of `I` from SageMath
(not for the previous example, which is immediate).
I know how to do this for polynomial algebras, but for graded
commutative algebras constructed using `GradedCommutativeAlgebra`
this does not seem to work. Is it possible?
Thanks in advance!
EDIT: I slightly changed the previous example to avoid any misunderstanding. I remark that, if one forgets the multidegree of the algebras, the algebras I am interested in (and produced by the command `GradedCommutativeAlgebra`) are super commutative for the underlying Z/2Z grading. In particular, in the previous example, we have `z*z = 0` in `A`, because `z` has total odd degree, and `z*y = - y * z` in `A`, since `y` also has odd degree.EstanislaoFri, 18 Jun 2021 10:54:18 +0200https://ask.sagemath.org/question/57617/Building a homomorphism from group algebra to matrix spacehttps://ask.sagemath.org/question/57568/building-a-homomorphism-from-group-algebra-to-matrix-space/
I would like to define an algebra homomorphism between a group algebra over the integers and a complex matrix space.
More precisely I have a free group F on 4 generators and the associated group algebra G and I would like to construct a homomorphism which sends each of the generators to a certain complex matrix. Inspired by a similar question, I have tried multiple things, but nothing seems to work
I have
F.<A,B,C,D>=FreeGroup(4)
F.inject_variables()
R=MatrixSpace(CC,2)
A1 = matrix(CC,[[0,I],[I,0]])
B1 = matrix(CC,[[I,0],[0,-I]])
C1 = matrix(CC,[[0,1],[-1,0]])
G=GroupAlgebra(F, ZZ)
I would like to define the homomorphism G->R which sends A to A1, B to B1 and both C and D to C1.
cate15Tue, 15 Jun 2021 19:02:04 +0200https://ask.sagemath.org/question/57568/How to interpret Solve_ineq() result ?https://ask.sagemath.org/question/57512/how-to-interpret-solve_ineq-result/For this code
R = PolynomialRing(QQ, 'x', 2)
X = vector(R.gens())
show(X)
A=matrix(QQ,[[1, 2], [-3, 4]])
b=vector(QQ,[[2], [-4]])
show(A,"....", b)
Z=A*X+b
ZZ=[SR(y) for y in Z]
ZZZ=[eq<=0 for eq in ZZ]
Y=[SR(X[i]).variables()[0] for i in range(len(X))]
show(Y)
show(ZZZ)
sol=solve_ineq(ZZZ,[x[0]])
sol
`sol[0]` gives `[x0 == -2*x1 - 2, 5*x1 + 1]`. And here is the question what means `5*x1 + 1` (no equality, inequality ...)
CyrilleWed, 09 Jun 2021 19:56:13 +0200https://ask.sagemath.org/question/57512/multiplication of a polytopehttps://ask.sagemath.org/question/57455/multiplication-of-a-polytope/ I answering to my question `https://ask.sagemath.org/question/57371/how-to-transform-a-derived-set-of-inequation-in-the-good-polyhedron-format/` tmonteil gives me the very nice code
D = polytopes.dodecahedron()
M = matrix([[0,1,0],[0,0,1]])
(M * D).plot()
which do so simply what I was expecting. But as I am curious, I would like to know what is the internal representation of the polyhedra wich permit such product. Hope this is not a too stupid question with a self evident answer.
A second question is : how to translate D in the 3D space ?CyrilleFri, 04 Jun 2021 19:04:27 +0200https://ask.sagemath.org/question/57455/How to transform a derived set of inequation in the good polyhedron formathttps://ask.sagemath.org/question/57371/how-to-transform-a-derived-set-of-inequation-in-the-good-polyhedron-format/This is a follow-up to:
- [Ask Sage question 57318: Use solve with inequality extracted from polytope](https://ask.sagemath.org/question/57318)
- [Ask Sage question 57359: Symbolic expression not scriptable in Solve](https://ask.sagemath.org/question/57359)
- [Ask Sage question 57364: Inequation solution doesn't isolate the operational variable](https://ask.sagemath.org/question/57364)
Applying this code
def one_dimension_less(representationH):
x = list(var('x_%i' % i) for i in (0..2))
sol = [solve_ineq(ieq, [x[0]]) for ieq in Ineq]
sol_r = flatten([x[1] for x in sol])
ineq_ge = [z for z in sol_r if z.rhs() == x[0]]
ineq_le = [z for z in sol_r if z.lhs() == x[0]]
ineq_a = [z for z in sol_r if z.lhs() != x[0] and z.rhs() != x[0]]
ineq_aa = [(z.lhs()).full_simplify() >= 0 for z in ineq_a]
result = flatten(ineq_aa + [
[(ineq_le[j].rhs()-ineq_ge[i].lhs()).full_simplify() >= 0
for i in range(len(ineq_ge))]
for j in range(len(ineq_le))])
# result1 = [result[i].factor() for i in range(len(result))]
return result
to
D = polytopes.dodecahedron()
DH = D.Hrepresentation()
with
PD1 = one_dimension_less(DH)
show(PD1)
I can eliminate one variable and obtain a set of inequalities
defining a polyhedron in a lower dimension
(here I go from 3 to 2 but it can be higher.
For each `x in PD1`, I can isolate its right hand side but I don't
know how to isolate the parameters in such a way to write it as
sage: Polyhedron(ieqs=[(0, 1, 0), (0, 0, 1), (1, -1, -1)]).Hrepresentation()
(An inequality (-1, -1) x + 1 >= 0,
An inequality (1, 0) x + 0 >= 0,
An inequality (0, 1) x + 0 >= 0)`
the lists needed to feed `ieqs` in `Polyhedron`. How to do that?CyrilleMon, 31 May 2021 11:41:12 +0200https://ask.sagemath.org/question/57371/how to calcualte the basis of quotient module over the steenrod algebra in Sagehttps://ask.sagemath.org/question/56943/how-to-calcualte-the-basis-of-quotient-module-over-the-steenrod-algebra-in-sage/ A(2) is steenrod algebra generated by sq1, sq2,sq4 with Adem relations, we knew A(2) has dimension 64, how to calculate the basis like quotient algebra A(2)/A(2){sq1} and A(2)/A(2){sq1,sq2sq3} and A(2)/A(2){sq1, sq7,sq3sq7+sq4sq6} in Sage? Thanks !wittenheTue, 04 May 2021 14:28:08 +0200https://ask.sagemath.org/question/56943/Substitution of an indexed variable in an expressionhttps://ask.sagemath.org/question/56830/substitution-of-an-indexed-variable-in-an-expression/ Until a certain stage of my computation, I do not need indices in my work. Then I want to substitute indexed variables
x,y,p,q=SR.var('x, y, p, q')
A=matrix(SR,2,2,[x,-y,-x,0])
B=matrix(SR,2,2,[-x,y,x,0])
pp = vector(SR,[p, 1-p])
qq = vector(SR,[q, 1-q])
EGe0 = (pp*A*qq).collect(p)
EGp0 = (pp*B*qq).collect(q)
p = var("p", n=10, latex_name='\\overline{p}')
EGe0 = (pp*A*qq).collect(p).substitute_expression(p==p[0])
show(EGe0)
But I certainly have made an error. (I also tried `.subs()`)CyrilleTue, 27 Apr 2021 16:17:43 +0200https://ask.sagemath.org/question/56830/factor symbolic expressionhttps://ask.sagemath.org/question/56805/factor-symbolic-expression/ In the following code, if I add `.collect(p)` to the `pp*A*qq` in the before last expression, I have an error. Why ?
LE=LatexExpr
x,y,p,q=SR.var('x, y, p, q')
A=matrix(SR,2,2,[x,-x,-x,0])
B=matrix(SR,2,2,[-x,y,x,0])
show(LE(r"\boldsymbol{A} = "),A, LE(r"\,\,\,\,\,\text{et}\,\,\,\,\,"),LE(r"\boldsymbol{B} = "),B)
pp = vector(SR,[p, 1-p])
qq = vector(SR,[q, 1-q])
show(LE(r"\boldsymbol{p} = "),pp, LE(r"\,\,\,\,\,\text{et}\,\,\,\,\,"),LE(r"\boldsymbol{q} = "),qq)
EGe0 = pp*A*qq.collect(p)
show(LE(r"\mathbb{E}G_e^0 = "),EGe0)
CyrilleSun, 25 Apr 2021 16:47:57 +0200https://ask.sagemath.org/question/56805/"Ratio" of two elements in a ringhttps://ask.sagemath.org/question/56538/ratio-of-two-elements-in-a-ring/Suppose I have a $\mathbb{Q}$-algebra R, and I have two elements x and y in R. I happen to know that x is a scalar multiple of y. Is there a way to figure out what the scalar is?
In other words, I want to identify the $\mathbb{Q}$-span of y with 1-dimensional vector space, choose an isomorphism of this vector space with $\mathbb{Q}$ (sending y to 1), and see where x goes.
The general context is that R is a finite-dimensional graded $\mathbb{Q}$-algebra (given as a quotient of a polynomial ring), and the top degree piece has dimension 1. I have an isomorphism of this top degree piece with $\mathbb{Q}$ (defined by sending a certain element to 1), and I want to be able to compute what it does to other elements.
An example of such a ring: let $A = \mathbb{Q}[x_1, x_2, x_3, x_4]$. Let $I_1 = (x_1x_3, x_2x_4)$. Let $I_2 = (x_1 + x_3, x_2 + x_4)$. Let $R = A/(I_1 + I_2)$.
(Note that $R$ is the Stanley-Reisner ring of simplicial complex (a triangulation of the circle) modulo a linear system of parameters. So it is graded by degree, and as the simplicial complex is a circle, the degree 2 is a 1-dimensional vector space.)
Let $y = x_1 x_2$, and let $x = (x_1 + x_4)(x_2 + x_3)$. Then x is a scalar multiple of y (as they are both in degree 2), and I would like to know what the scalar is.
(In this case, x = 2y.)
Later edit: fixed typovukovThu, 08 Apr 2021 04:40:24 +0200https://ask.sagemath.org/question/56538/Splitting a matrixhttps://ask.sagemath.org/question/56377/splitting-a-matrix/Dear SAGE community,
I am looking for a way that can help me split this matrix, A
A = matrix([[x], [x - 2*y]]), which is a linear combination of variables x, and y
into a Coefficient matrix, C = matrix([[1, 0], [1, -2]]) times the vector containing independent variables b = matrix([[x], [y]]).
Basically, A = C*b.
If there's a way to obtain the matrix C, would be really helpful.
-TIAApoorvThu, 25 Mar 2021 20:18:08 +0100https://ask.sagemath.org/question/56377/Solve for coefficients of polynomialshttps://ask.sagemath.org/question/55474/solve-for-coefficients-of-polynomials/I want to solve for the coefficients $\alpha(n, m, k)$ an equation that looks like this:
$$
0 = (1 + x + y + z) \\sum_{n, m, k \\in \\{0, 1, \dots, N\\}} \\alpha(n, m, k) x^n y^m z^k
$$
where $\\alpha(n, m, k) \\in \\{0, 1\\}$ and $x^n y^m z^k$
are polynomials over $\mathbb{F}_2$ that satisfy
$x^L = y^L = z^L = 1$ for some integer $L$.
Is there a way to do this in Sage? Notice there are three generators $x,y,$ but the number of coefficents $\alpha$ is $2^{3L}$.
I tried to follow [this](https://ask.sagemath.org/question/51639/equating-coefficients-of-multivariate-polynomials/) answer and wrote this code that failed-
R = PolynomialRing(GF(2),3,"xyz")
x,y,z = R.gens()
S.<a,b,c> = R.quotient((x^2 + 1,y^2+1,z^2+1))
K = PolynomialRing(GF(2),2,'q') # Coefficients
q = K.gens()
Pol = (q[1]*a+q[0])*(a*b)-5*b*a # Equation to solve
I = K.ideal(Pol.coefficients())
I.variety()
And I get the following error:
TypeError Traceback (most recent call last)
<ipython-input-90-e45cccb450b5> in <module>
5 q = K.gens()
6
----> 7 Pol = (q[Integer(1)]*a+q[Integer(0)])*(a*b)-Integer(5)*b*a # Equation to solve
8
9 K.ideal(Pol.coefficients())
/opt/sagemath-9.2/local/lib/python3.7/site-packages/sage/structure/element.pyx in sage.structure.element.Element.__mul__ (build/cythonized/sage/structure/element.c:12199)()
1513 return (<Element>left)._mul_(right)
1514 if BOTH_ARE_ELEMENT(cl):
-> 1515 return coercion_model.bin_op(left, right, mul)
1516
1517 cdef long value
/opt/sagemath-9.2/local/lib/python3.7/site-packages/sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel.bin_op (build/cythonized/sage/structure/coerce.c:11304)()
1246 # We should really include the underlying error.
1247 # This causes so much headache.
-> 1248 raise bin_op_exception(op, x, y)
1249
1250 cpdef canonical_coercion(self, x, y):
TypeError: unsupported operand parent(s) for *: 'Multivariate Polynomial Ring in q0, q1 over Finite Field of size 2' and 'Quotient of Multivariate Polynomial Ring in x, y, z over Finite Field of size 2 by the ideal (x^2 + 1, y^2 + 1, z^2 + 1)'ofir_arWed, 27 Jan 2021 17:33:29 +0100https://ask.sagemath.org/question/55474/How can I compute a fixed field over the p-adicshttps://ask.sagemath.org/question/55336/how-can-i-compute-a-fixed-field-over-the-p-adics/I have problems to implement the following set up:
I want to have a field $K = \mathbb{Q}_3$ and an extension $L = \mathbb{Q}_3(\alpha)$ over $K$ where $f:=\min_K(\alpha) = x^4 - 3x^2 + 18$. This extension has degree $4$ and ramification index $2$. Furthermore, let $F/K$ be the unique unramified extension of $K$ of degree $4$ which is generated by a primitive $5$-th root of unity $\zeta_5$.
Then one can show that $\varphi: \alpha \mapsto \frac{(2 \alpha^2 - 3)\sqrt{-\frac{2}{7}}}{\alpha},$ $\zeta_5 \mapsto \zeta_5^3$ is an element of the Galois group of $LF/K$. Now let $L' = (LF)^{\langle \varphi \rangle}$. This must be a quadratic and totally ramified extension of $K$. There are only two possibilities for that: $K(\sqrt{3})$ or $K(\sqrt{-3})$.
**Question**: How to determine whether $L' = K(\sqrt{3})$ or $L' = K(\sqrt{-3})$ (or equivalently, $\varphi(\sqrt{3}) = \sqrt{3}$ or $\varphi(\sqrt{-3}) = \sqrt{-3}$)?
Since I only have only superficial knowledge about Sage, I was not even able to set up the easy things like the field $L$ properly. When I use
K = Qp(3)
R.<x> = ZZ[]
f = x^4 - 3*x^2 + 18
L.<alpha> = K.extension(f)
I get an error that my polynomial $f$ must be either unramified or Eisenstein (which of course does not exist since $L/K$ is neither unramified nor totally ramified). Furthermore, I have no idea how to approach with my problem with Sage otherwise. And since computation by hand is pretty hard in this case (I already tried!), it would be nice to solve with problem here, so I can use it for similar computations in the future.
Could you please help me with this problem?RotdatMon, 18 Jan 2021 16:41:46 +0100https://ask.sagemath.org/question/55336/How to do low degree computation in a Free Algebra ?https://ask.sagemath.org/question/55269/how-to-do-low-degree-computation-in-a-free-algebra/Say $F$ is a free algebra over $n$ generators of degree $1$, and i want to compute in this algebra but i only need to get my expressions up to degree $k$. For example, if $k=2$, $(ab +a)*b$ should be $ab$.
For now, i have been doing the computation and truncating everything above degree $k$, but the time complexity is too high when i launch a big computation.
I am actually asking how to compute in the tensor Algebra $T(V)$ modulo $T_{\geq k}(V)$. For free Lie algebras, this can be done using nilpotent Lie algebras, (for example `L = LieAlgebra(QQ, 3, step=3)` implements a 3-nilpotent free Lie algebra). How to do this with free algebras ?qfaesThu, 14 Jan 2021 16:03:58 +0100https://ask.sagemath.org/question/55269/Determine Two quadratic form is integer congruence (rational equivalent)?https://ask.sagemath.org/question/55294/determine-two-quadratic-form-is-integer-congruence-rational-equivalent/Fix $n \\geq 2$ and consider $A,B \\in \\operatorname{GL}(n,\\mathbb{Z}).$
We know that we have the Smith normal form.
One can find $U, V \\in \\operatorname{SL}(n,\\mathbb{Z})$ such that $A=UDV.$
Likewise for $B$. The Smith normal form is easy to compute using Mathematica.
We also call two matrices $A,B$ congruent if there exists
$X \\in \\operatorname{PSL}(n,\\mathbb{Z})$ such that $X^TAX=B$.
Now we have the following: if two matrices are congruent, then they have the same $D$.
But now, given two 4 by 4 matrices with same Smith normal form $D$,
how to verify they are congruent?
An if they are, how to find a matrix $X$ such that $X^T A X = B$.
To be more specific, suppose
$A = \\begin{bmatrix}
2 & -1 & -1 & -1 \\\\
-1 & 2 & 0 & 0 \\\\
-1 & 0 & 2 & 0 \\\\
-1 & 0 & 0 & 2 \\\\
\\end{bmatrix}$
and
$B = \\begin{bmatrix}
4 & -6 & 4 & -2 \\\\
-6 & 12 & -8 & 4 \\\\
4 & -8 & 6 & -3 \\\\
-2 & 4 & -3 & 2 \\\\
\\end{bmatrix}.$
I want to ask whether $A,B$ are congruent. Here is how far I got.
$A$, $B$ both have the same Smith normal form
$D = \\begin{bmatrix}
1 & 0 & 0 & 0 \\\\
0 & 1 & 0 & 0 \\\\
0 & 0 & 2 & 0 \\\\
0 & 0 & 0 & 2 \\\\
\\end{bmatrix}.$
So they define the same integer lattices.
But I do not know whether they are congruent.
I suspect they are congruent but I have no idea how to prove it.
Any ideas or comments are really appreciated.
By the way, $A$ is the Cartan matrix of $SO(8).$
I think it will not help.
I used Sage and typed them in as quadratic forms.
But I found that the `is_rationally_isometric` function only works
for number field but not integers ring (if I use integers,
there will be an error like no real_embedding).
The `is_rationally_isometric` is True.
But I do not know whether they are isometric over the integers.
If the answer is true, can I find such X?
sage: A = QuadraticForm(QQ, 4, [4, -12, 8, -4, 12, -16, 8, 6, -6, 2])
sage: print(A)
sage: A1 = QuadraticForm(QQ, 4, [2, -2, -2, -2, 2, 0, 0, 2, 0, 2])
sage: print(A1)
sage: A1.is_rationally_isometric(A)
TrueGracecatSat, 16 Jan 2021 03:33:07 +0100https://ask.sagemath.org/question/55294/How to compute in the Tensor Algebra $T(V)$ ?https://ask.sagemath.org/question/55256/how-to-compute-in-the-tensor-algebra-tv/I need to make some computations in low degree in the Tensor algebra $T(V)$ of a rational vector space $V$, but i cannot find a good way of doing this. I could use FreeAlgebras, but then i cannot get access to the summands in my element : for example i want to be able to retrieve $a$ $b$ and $c$ from the element $a*b*c $ (whenever the element is homogeneous).
The reason for this is I need to define a 'cycle' function that associates $Wa$ to a tensor $aW$ when $W$ is a tensor and $a \in V$.qfaesWed, 13 Jan 2021 16:21:54 +0100https://ask.sagemath.org/question/55256/Matrix-scalar and vector-scalar operationshttps://ask.sagemath.org/question/54844/matrix-scalar-and-vector-scalar-operations/ Consider :
sage: b=vector([var("b_{}".format(u)) for u in (1..3)])
sage: B=matrix(b).transpose()*matrix(b)
Unsurprisingly :
sage: B*x
[ b_1^2*x b_1*b_2*x b_1*b_3*x]
[b_1*b_2*x b_2^2*x b_2*b_3*x]
[b_1*b_3*x b_2*b_3*x b_3^2*x]
This is less obvious (but intuitively compatible with associativity) :
sage: B+x
[b_1^2 + x b_1*b_2 b_1*b_3]
[ b_1*b_2 b_2^2 + x b_2*b_3]
[ b_1*b_3 b_2*b_3 b_3^2 + x]
This also is unsurprising :
sage: b*x
(b_1*x, b_2*x, b_3*x)
But there is nothing "obviously expectable" from this :
sage: b+x
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-29-58bd66da7aa5> in <module>
----> 1 b+x
/usr/local/sage-9/local/lib/python3.9/site-packages/sage/structure/element.pyx in sage.structure.element.Element.__add__ (build/cythonized/sage/structure/element.c:10988)()
1230 # Left and right are Sage elements => use coercion model
1231 if BOTH_ARE_ELEMENT(cl):
-> 1232 return coercion_model.bin_op(left, right, add)
1233
1234 cdef long value
/usr/local/sage-9/local/lib/python3.9/site-packages/sage/structure/coerce.pyx in sage.structure.coerce.CoercionModel.bin_op (build/cythonized/sage/structure/coerce.c:11708)()
1248 # We should really include the underlying error.
1249 # This causes so much headache.
-> 1250 raise bin_op_exception(op, x, y)
1251
1252 cpdef canonical_coercion(self, x, y):
TypeError: unsupported operand parent(s) for +: 'Vector space of dimension 3 over Symbolic Ring' and 'Symbolic Ring'
However,
sage: vector([u+x for u in b])
(b_1 + x, b_2 + x, b_3 + x)
would be a possible candidate, but I have trouble visualizing the consequences in the rest of algebraic computation rules in Sage. Is this documented ?Emmanuel CharpentierTue, 22 Dec 2020 21:02:35 +0100https://ask.sagemath.org/question/54844/Erasing some of the decimals in a listhttps://ask.sagemath.org/question/54401/erasing-some-of-the-decimals-in-a-list/ This is a nice table to the reserve of the to long decimals
A=[[10,10,10,10,10,10,10,10,10,10],[100,0,0,0,0,0,0,0,0,0],[11.1,11.1,11.1,11.1,11.1,11.1,11.1,11.1,11.1,0]
,[20,20,20,20,20,0,0,0,0,0],[50,25,12.5,6.25,3.125,1.56,0.78,0.39,0.19,0.09]]
t=table(A,header_row=["$1$","$2$","$3$","$4$","$5$","$6$","$7$","$8$","$9$","$10$"],header_column=["","Équi-Rep","Tout pour un","Un déshérité","Injuste pour 1/2","$5$","Injuste croissante"])
show(t)
I have tried to construct a function `f(x)=round(x,2)` and then to use `A.map_apply(f)` but this doesnot works since
`f(x)=round(x,2)` generates an error. How shouild I do ?CyrilleThu, 26 Nov 2020 19:11:43 +0100https://ask.sagemath.org/question/54401/Klee-Minty cube vertices for D=5https://ask.sagemath.org/question/54366/klee-minty-cube-vertices-for-d5/According to [Wikipedia](https://en.wikipedia.org/wiki/Klee–Minty_cube)
(but this is well known), A Klee-Minty cube in $D$ dimensions is defined by
$x_1\leq 5$
$4 x_1 + x_2 \leq 25$
$8 x_1 + 4 x_2 + x_3 \leq 125$
$16 x_1 + 8 x_2 + 4 x_3 + x_4 \leq 625$
$32 x_1+ 16 x_2 + 8 x_3 + 4 x_4 + x_5 \leq 3125$
$\vdots \vdots$
$2^D x_1 + 2^{D-1} x_2 + 2^{D-2} x_3 + \ldots + 4 x_{D-1} + x_D \leq 5^D$
$x_1 \geq 0$
$x_2 \geq 0$
$x_3 \geq 0$
$x_4 \geq 0$
$x_5 \geq 0$
This polyhedron has $2^D$ vertices. How can I find them?
I have tried the following code for $D = 5$ --- that is 32 vertices.
A = matrix(QQ, 10, 5,
[0, 0, 0, 0, -1,
0, 0, 0, -1, -4,
0, 0, -1, -4, -8,
0, -1, -4, -8, -16,
-1, -4, -8, -16, -32,
1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 1, 0,
0, 0, 0, 0, 1])
show(LatexExpr(r"\text{A = }"), A)
b = vector(QQ, [5, 254, 125, 625, 3125, 0, 0, 0, 0, 0])
show(LatexExpr(r"\text{b = }"), b)
c = vector(QQ, [2^4, 2^3, 2^2, 2^1, 2^0])
show(LatexExpr(r"\text{c = }"), c)
AA = matrix(list(list([b]) + list(transpose(A))))
show(transpose(AA))
pol = Polyhedron(ieqs=AA)
pol.Hrepresentation()
But I am far away from the account and some of the vertices
are in the negative part of the hyperplane (which is impossible).
Need some help to decipher my mistake(s). Thanks.CyrilleMon, 23 Nov 2020 17:04:16 +0100https://ask.sagemath.org/question/54366/All rational periodic pointshttps://ask.sagemath.org/question/54066/all-rational-periodic-points/Hello, I am trying to find all rational periodic points of a polynomial. To specify: a periodic point is the point that satisfy $f^n(x)=x$. It is related to dynamical systems in fact. So the current codes that I used are following:
A.<z> = AffineSpace(QQ, 1)
f = DynamicalSystem_affine([2*z^3-3*z^2+1/2])
x=f.dynatomic_polynomial(2)
x.factor()
With this I can find its dynatomic polynomial and factorize it and find rational roots of this polynomial. So this roots corresponds to periodic point of the polynomial of given period. In particular dynatomic polynomial is the polynomial of the form $$\phi_{n,f}(x)=\prod_{d|n}(f^d(x)-x)^{\mu(n/d)}$$ n is period, f is your polynomial and $\mu$ is the mobius function.
But with this code I can find periods up to 8 because of memory limit. The other code that I used is
R.<x> = QQ[]
K.<i> = NumberField(xˆ2+1)
A.<z> = AffineSpace(K,1)
f = DynamicalSystem([zˆ2+i], domain=A)
f.orbit(A(0),4)
But in fact it doesn't fit my purposes.
I have codes that I can get limited information. For example checking up to a period is not advisable. If you know a little bit arithmetic dynamics, you can see what I mean. Silverman-Morton conjecture plays an important role here.
I am waiting for your answers. Thank you so much.nomaddWed, 28 Oct 2020 20:12:20 +0100https://ask.sagemath.org/question/54066/Reuse of already entered parametershttps://ask.sagemath.org/question/48206/reuse-of-already-entered-parameters/ I would like to know if there is a general procedure to reuse some already enter parameters. For instance In
> MixedIntegerLinearProgram
one can enter an inequation as
> p.add_constraint( a[1,1]*x[0] + a[1,2]*x[1] + c[1,3]*x[2] >= b [1])
and now I need a[1, 1] ..., a[1, 3] and b[1]
to write
>pol = Polyhedron(ieqs = [[-b [1], a[1, 1], a[1, 2]],...].
And when the result of a calculaton is verbose --- composed of strings and numbers ---, how to keep only the interesting part ?
CyrilleSun, 06 Oct 2019 19:03:35 +0200https://ask.sagemath.org/question/48206/apply map in multiple dimensionhttps://ask.sagemath.org/question/53817/apply-map-in-multiple-dimension/ I have a this list
ver1=[(0.00,0.50,0.75),(0.00,−0.50,0.75),(0.50,0.75,0.00),(0.50,−0.75,0.00)]
I want apply the function `f(x,y, z)` say `0.3*ver[0][0]+ 0.7*ver[1][0]+ 0.2*ver[2][0]` to each 3-tuple of this function. I know that map do it but the exemples are for for only one variable not for 3.
I have tried to transform ver1 in matrix but after I do not know how to proceed. Perhaps it is not possible ?CyrilleSat, 10 Oct 2020 16:42:30 +0200https://ask.sagemath.org/question/53817/Seemingly false answer by bool()https://ask.sagemath.org/question/53775/seemingly-false-answer-by-bool/I plot the inequalities
var("x_1","x_2")
eq1=solve(3*x_1+4*x_2==14,x_2)
eq2=solve(5*x_1+6*x_2==-8,x_2)
eq3=solve(4*x_1-7*x_2==18,x_2)
eq4=solve(2*x_1-3*x_2==-8,x_2)
b=10
p=plot([eq1[0].rhs(),eq2[0].rhs(),eq3[0].rhs(),eq4[0].rhs()], (x_1, 0,b),color=["#c72b91","#2b37c7", "#cb7b2b","#2bcb4b"],axes_labels=["$x_1$","$x_2$"],legend_label=[r"$%s$"%latex(eq1[0].rhs()),r"$%s$"%latex(eq2[0].rhs()),r"$%s$"%latex(eq3[0].rhs()),r"$%s$"%latex(eq4[0].rhs())])
show(p)
which shows that the `eq1` is always above for any $x\geq 0$ to `eq2`. The same for `eq4`. But there is an intersection with `eq3`. So the following code shoud return true for both `bool`. And this is not the case.
assume(x_1 >0)
show(bool(eq1[0][0].rhs()>eq2[0][0].rhs()))
show(bool(eq3[0][0].rhs()>eq2[0][0].rhs()))
and this is confirmed by the fact that
solve(eq3[0][0].rhs()>eq3[0][0].rhs()
return for solution `eq2[0][0]`, which is a way to answer to the same question that the one ask with `bool`. Is it my error ?CyrilleThu, 08 Oct 2020 06:41:28 +0200https://ask.sagemath.org/question/53775/Solve in inequalities return two separate solutions. Could they be gathered ?https://ask.sagemath.org/question/53776/solve-in-inequalities-return-two-separate-solutions-could-they-be-gathered/In the following code, I wonder if there is a way to ask `solve()` to return only one solution with $\leq$ and not one for $<$ and one for $=$.
var('x_1','x_2')
eq2=solve(5*x_1+6*x_2<-8,x_1)
eq4=solve(2*x_1-3*x_2<-8,x_1)
l1=solve(eq4[0][0].rhs()>eq2[0][0].rhs(),x_1)
l2=solve(eq4[0][0].rhs()>=eq2[0][0].rhs(),x_2)
show(l1)
show(l2)CyrilleThu, 08 Oct 2020 06:49:01 +0200https://ask.sagemath.org/question/53776/To give a name to an append listhttps://ask.sagemath.org/question/53725/to-give-a-name-to-an-append-list/If I code this
A = matrix([[1/2, 1/4, 0], [1, 3, -1], [1, 1, 0]])
b = vector([5, 18,10])
c = vector([102, 303, -100])
t = matrix(A.augment(b))
c = c.list()
c.append(0)
show(t, c)
SageMath returns what is expected.
But if I want to change the name of `c.append(0)`?
It returns `None`, so I cannot reuse the augmented vector.CyrilleMon, 05 Oct 2020 09:48:16 +0200https://ask.sagemath.org/question/53725/Compute radical and idempotents of a quotient algebrahttps://ask.sagemath.org/question/10350/compute-radical-and-idempotents-of-a-quotient-algebra/I tried the following:
R.<x, y> = PolynomialRing(QQ, 2)
I = Ideal(x^2, y^2)
S = R.quotient(I)
I have the following question:
**I would like to compute with Sage the Jacobson radical of the algebra S,
all primitive orthogonal idempotents and the central idempotents.**
Of course, you can compute this by hand, but I am interested in more
complicated examples, too (also in matrix algebras), but wanted to
start with this simple example.
Since I am relatively new to Sage, I unfortunately do not know how to compute this.
I would be grateful for any help.BernFri, 12 Jul 2013 10:50:17 +0200https://ask.sagemath.org/question/10350/Splitting a list into sub-listhttps://ask.sagemath.org/question/53605/splitting-a-list-into-sub-list/I have not find the way do do this split `A=[1, 2, 3, 4, 6, 8, 2, 7, 9]` in such a way to obtain `A=[[1, 2, 3], [4, 6, 8], [2, 7, 9]]` --- simply for the cazse where `len(A)= k len(sublist)`.CyrilleSat, 26 Sep 2020 10:55:46 +0200https://ask.sagemath.org/question/53605/Concatenation of listshttps://ask.sagemath.org/question/53643/concatenation-of-lists/Starting from a list of lists and some extra lists,
I want to combine them in various ways.
Suppose I have the following lists:
- a list of lists
A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
- two extra lists
U = [100, 200, 300]
V = [40, 50, 60]
How to extend `A` using `U` and `V` to obtain
B = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [100, 200, 300]]
C = [[1, 2, 3, 100], [4, 5, 6, 200], [7, 8, 9, 300]]
D = [[1, 2, 3, 100], [4, 5, 6, 200], [7, 8, 9, 300], [40, 50, 60, a]]
for a given `a`.
I have the same question with matrices and vectors.
And is there a mechanism to go back to lists from matrices and vectors?CyrilleMon, 28 Sep 2020 18:22:41 +0200https://ask.sagemath.org/question/53643/