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.Sat, 08 May 2021 21:44:28 +0200How to use faces of a polytope as variables?https://ask.sagemath.org/question/57027/how-to-use-faces-of-a-polytope-as-variables/ Hello, I am very new to using computer algebras system, and I can't figure out the following: I need to create a 3D polytope (in fact, an associahedron) and then do some computations in the algebra of rational functions in variables that correspond to faces of associahedron. How do I do that? I know writing something like Frac(ZZ['x,y,z']) creates the algebra that I need, but how do I make formal symbols x,y,z remember that they once were faces of a polytope (so that I could check if one was a subface of another, or something like that...)?PolydaryaSat, 08 May 2021 21:44:28 +0200https://ask.sagemath.org/question/57027/Call polynomial ring variables by indexhttps://ask.sagemath.org/question/56797/call-polynomial-ring-variables-by-index/In my study I have to work with something like `BooleanPolynomialRing(... 'x', 10)`.
After that I can create function in the form `x1 + x1*x3 + ...`.
However I would like to create functions in more generic form like
`x[1] + x[2]*x[3]` where `x[1]` is equivalent for `x1`, etc.
The final goal is to be able to construct functions programmatically
combining indexed expressions like `x[i] + x[j]` etc.vet99Sat, 24 Apr 2021 20:11:27 +0200https://ask.sagemath.org/question/56797/Maps of monomials to monomialshttps://ask.sagemath.org/question/50703/maps-of-monomials-to-monomials/ Let us assume I have a function F that takes say degree 1 monomials to degree 2 monomials and degree 3 monomials in variable x,y (example: multiplication by $x+y^{2}$). I have a basis for degree 1 monomials given by x,y; a basis for degree 2 given by $x^{2},xy,y^{2}$, and a basis for degree 3 monomials given by $x^{3},x^{2}y,xy^{2},y^{3}$. So if I want to express F as a matrix, I can say
g1= F(x), g2=F(y).
Then the first row of my matrix will be coefficient of $x^{2}$ in g1, coefficient of $xy$ in g1, coefficient of $y^{2}$ in g1, coefficient of $x^{3}$ in g1, ...., coefficient of $y^{3}$ in g1. The second row will just be the same with g1 replaced with g2.
The issue is if I want degree 10 monomials, the writing out each basis element is too much, especially if there were more variables. I was wondering if there was a simpler way in Sage to write this in coding language without writing out each basis element. Suppose I want degree k monomials to degree m and n monomials. Basically, I feel I need some command like the following. I feel there should be a package for this maybe?
1. Define F. Let B be a k x (m+n) matrix. Take the space of all degree k monomials (maybe ordered lexigraphically?). Apply F to that space. For each element F is applied to, in the image, extract degree m part. Write it out as a vector in the space of degree m monomials. Same for degree n part. Put vector into part of matrix B.
whatupmattSun, 12 Apr 2020 16:55:35 +0200https://ask.sagemath.org/question/50703/Checking whether a real polynomial of 21 variables is non-negativehttps://ask.sagemath.org/question/47771/checking-whether-a-real-polynomial-of-21-variables-is-non-negative/Let $P$ be a real polynomial with $n$ variables.
*Question 1*: Is there a SageMath function deciding whether $P$ is non-negative?
By non-negative I mean that for all $v \in \mathbb{R}^n$ we have $P(v) \ge 0$.
*Question 2*: Is it workable for $n = 21$?
_____________________
Here is the poIynomial I am interested in (where the variables are $x_{s,i}$, with $s = 1,2,3$ and $i = 1,2,\dots, \ell$):
$$P=\sum_{k=1}^{\ell} \frac{1}{n_k} \prod_{s=1}^3 (\sum_{i,j} n_{i,j}^k x_{s,i} x_{s,j})$$
where $n_i$ and $n_{i,j}^k$ are non-negative integers given by the following lists (here $\ell = 7$):
[for those interested it corresponds to a fusion ring, see [here](https://mathoverflow.net/q/132866/34538)]
dim=[1,5,5,5,6,7,7]
M=[
[[1,0,0,0,0,0,0],[0,1,0,0,0,0,0],[0,0,1,0,0,0,0],[0,0,0,1,0,0,0],[0,0,0,0,1,0,0],[0,0,0,0,0,1,0],[0,0,0,0,0,0,1]],[[0,1,0,0,0,0,0],[1,1,0,1,0,1,1],[0,0,1,0,1,1,1],[0,1,0,0,1,1,1],[0,0,1,1,1,1,1],[0,1,1,1,1,1,1],[0,1,1,1,1,1,1]],[[0,0,1,0,0,0,0],[0,0,1,0,1,1,1],[1,1,1,0,0,1,1],[0,0,0,1,1,1,1],[0,1,0,1,1,1,1],[0,1,1,1,1,1,1],[0,1,1,1,1,1,1]],[[0,0,0,1,0,0,0],[0,1,0,0,1,1,1],[0,0,0,1,1,1,1],[1,0,1,1,0,1,1],[0,1,1,0,1,1,1],[0,1,1,1,1,1,1],[0,1,1,1,1,1,1]],[[0,0,0,0,1,0,0],[0,0,1,1,1,1,1],[0,1,0,1,1,1,1],[0,1,1,0,1,1,1],[1,1,1,1,1,1,1],[0,1,1,1,1,2,1],[0,1,1,1,1,1,2]],[[0,0,0,0,0,1,0],[0,1,1,1,1,1,1],[0,1,1,1,1,1,1],[0,1,1,1,1,1,1],[0,1,1,1,1,2,1],[1,1,1,1,2,1,2],[0,1,1,1,1,2,2]],[[0,0,0,0,0,0,1],[0,1,1,1,1,1,1],[0,1,1,1,1,1,1],[0,1,1,1,1,1,1],[0,1,1,1,1,1,2],[0,1,1,1,1,2,2],[1,1,1,1,2,2,1]]
]
Here is the code generating the polynomial:
cpdef ExplicitPolynomial(list dim,list M):
cdef int l,i,j,k,s
l=len(dim)
return sum([prod([sum([sum([M[i][j][k]*var('x_%d' % int(l*s+i))*var('x_%d' % int(l*s+j)) for i in range(l)]) for j in range(l)]) for s in range(3)])/dim[k] for k in range(l)])
Here is the polynomial explicitly:
sage: ExplicitPolynomial(dim,M)
(x_0^2 + x_1^2 + x_2^2 + x_3^2 + x_4^2 + x_5^2 + x_6^2)*(x_10^2 + x_11^2 + x_12^2 + x_13^2 + x_7^2 + x_8^2 + x_9^2)*(x_14^2 + x_15^2 + x_16^2 + x_17^2 + x_18^2 + x_19^2 + x_20^2) + 1/5*(2*x_0*x_1 + x_1^2 + x_2^2 + 2*x_1*x_3 + 2*x_2*x_4 + 2*x_3*x_4 + x_4^2 + 2*x_1*x_5 + 2*x_2*x_5 + 2*x_3*x_5 + 2*x_4*x_5 + x_5^2 + 2*x_1*x_6 + 2*x_2*x_6 + 2*x_3*x_6 + 2*x_4*x_6 + 2*x_5*x_6 + x_6^2)*(2*x_10*x_11 + x_11^2 + 2*x_10*x_12 + 2*x_11*x_12 + x_12^2 + 2*x_10*x_13 + 2*x_11*x_13 + 2*x_12*x_13 + x_13^2 + 2*x_10*x_8 + 2*x_12*x_8 + 2*x_13*x_8 + 2*x_7*x_8 + x_8^2 + 2*x_11*x_9 + 2*x_12*x_9 + 2*x_13*x_9 + x_9^2)*(2*x_14*x_15 + x_15^2 + x_16^2 + 2*x_15*x_17 + 2*x_16*x_18 + 2*x_17*x_18 + x_18^2 + 2*x_15*x_19 + 2*x_16*x_19 + 2*x_17*x_19 + 2*x_18*x_19 + x_19^2 + 2*x_15*x_20 + 2*x_16*x_20 + 2*x_17*x_20 + 2*x_18*x_20 + 2*x_19*x_20 + x_20^2) + 1/7*(x_1^2 + 2*x_1*x_2 + x_2^2 + 2*x_1*x_3 + 2*x_2*x_3 + x_3^2 + 2*x_1*x_4 + 2*x_2*x_4 + 2*x_3*x_4 + x_4^2 + 2*x_0*x_5 + 2*x_1*x_5 + 2*x_2*x_5 + 2*x_3*x_5 + 4*x_4*x_5 + x_5^2 + 2*x_1*x_6 + 2*x_2*x_6 + 2*x_3*x_6 + 2*x_4*x_6 + 4*x_5*x_6 + 2*x_6^2)*(x_10^2 + 2*x_10*x_11 + x_11^2 + 2*x_10*x_12 + 4*x_11*x_12 + x_12^2 + 2*x_10*x_13 + 2*x_11*x_13 + 4*x_12*x_13 + 2*x_13^2 + 2*x_12*x_7 + 2*x_10*x_8 + 2*x_11*x_8 + 2*x_12*x_8 + 2*x_13*x_8 + x_8^2 + 2*x_10*x_9 + 2*x_11*x_9 + 2*x_12*x_9 + 2*x_13*x_9 + 2*x_8*x_9 + x_9^2)*(x_15^2 + 2*x_15*x_16 + x_16^2 + 2*x_15*x_17 + 2*x_16*x_17 + x_17^2 + 2*x_15*x_18 + 2*x_16*x_18 + 2*x_17*x_18 + x_18^2 + 2*x_14*x_19 + 2*x_15*x_19 + 2*x_16*x_19 + 2*x_17*x_19 + 4*x_18*x_19 + x_19^2 + 2*x_15*x_20 + 2*x_16*x_20 + 2*x_17*x_20 + 2*x_18*x_20 + 4*x_19*x_20 + 2*x_20^2) + 1/7*(x_1^2 + 2*x_1*x_2 + x_2^2 + 2*x_1*x_3 + 2*x_2*x_3 + x_3^2 + 2*x_1*x_4 + 2*x_2*x_4 + 2*x_3*x_4 + x_4^2 + 2*x_1*x_5 + 2*x_2*x_5 + 2*x_3*x_5 + 2*x_4*x_5 + 2*x_5^2 + 2*x_0*x_6 + 2*x_1*x_6 + 2*x_2*x_6 + 2*x_3*x_6 + 4*x_4*x_6 + 4*x_5*x_6 + x_6^2)*(x_10^2 + 2*x_10*x_11 + x_11^2 + 2*x_10*x_12 + 2*x_11*x_12 + 2*x_12^2 + 2*x_10*x_13 + 4*x_11*x_13 + 4*x_12*x_13 + x_13^2 + 2*x_13*x_7 + 2*x_10*x_8 + 2*x_11*x_8 + 2*x_12*x_8 + 2*x_13*x_8 + x_8^2 + 2*x_10*x_9 + 2*x_11*x_9 + 2*x_12*x_9 + 2*x_13*x_9 + 2*x_8*x_9 + x_9^2)*(x_15^2 + 2*x_15*x_16 + x_16^2 + 2*x_15*x_17 + 2*x_16*x_17 + x_17^2 + 2*x_15*x_18 + 2*x_16*x_18 + 2*x_17*x_18 + x_18^2 + 2*x_15*x_19 + 2*x_16*x_19 + 2*x_17*x_19 + 2*x_18*x_19 + 2*x_19^2 + 2*x_14*x_20 + 2*x_15*x_20 + 2*x_16*x_20 + 2*x_17*x_20 + 4*x_18*x_20 + 4*x_19*x_20 + x_20^2) + 1/5*(x_1^2 + 2*x_0*x_3 + 2*x_2*x_3 + x_3^2 + 2*x_1*x_4 + 2*x_2*x_4 + x_4^2 + 2*x_1*x_5 + 2*x_2*x_5 + 2*x_3*x_5 + 2*x_4*x_5 + x_5^2 + 2*x_1*x_6 + 2*x_2*x_6 + 2*x_3*x_6 + 2*x_4*x_6 + 2*x_5*x_6 + x_6^2)*(x_10^2 + x_11^2 + 2*x_10*x_12 + 2*x_11*x_12 + x_12^2 + 2*x_10*x_13 + 2*x_11*x_13 + 2*x_12*x_13 + x_13^2 + 2*x_10*x_7 + 2*x_11*x_8 + 2*x_12*x_8 + 2*x_13*x_8 + x_8^2 + 2*x_10*x_9 + 2*x_11*x_9 + 2*x_12*x_9 + 2*x_13*x_9)*(x_15^2 + 2*x_14*x_17 + 2*x_16*x_17 + x_17^2 + 2*x_15*x_18 + 2*x_16*x_18 + x_18^2 + 2*x_15*x_19 + 2*x_16*x_19 + 2*x_17*x_19 + 2*x_18*x_19 + x_19^2 + 2*x_15*x_20 + 2*x_16*x_20 + 2*x_17*x_20 + 2*x_18*x_20 + 2*x_19*x_20 + x_20^2) + 1/5*(x_10^2 + 2*x_10*x_11 + x_11^2 + 2*x_10*x_12 + 2*x_11*x_12 + x_12^2 + 2*x_10*x_13 + 2*x_11*x_13 + 2*x_12*x_13 + x_13^2 + 2*x_11*x_8 + 2*x_12*x_8 + 2*x_13*x_8 + 2*x_12*x_9 + 2*x_13*x_9 + 2*x_7*x_9 + 2*x_8*x_9 + x_9^2)*(2*x_14*x_16 + 2*x_15*x_16 + x_16^2 + x_17^2 + 2*x_15*x_18 + 2*x_17*x_18 + x_18^2 + 2*x_15*x_19 + 2*x_16*x_19 + 2*x_17*x_19 + 2*x_18*x_19 + x_19^2 + 2*x_15*x_20 + 2*x_16*x_20 + 2*x_17*x_20 + 2*x_18*x_20 + 2*x_19*x_20 + x_20^2)*(2*x_0*x_2 + 2*x_1*x_2 + x_2^2 + x_3^2 + 2*x_1*x_4 + 2*x_3*x_4 + x_4^2 + 2*x_1*x_5 + 2*x_2*x_5 + 2*x_3*x_5 + 2*x_4*x_5 + x_5^2 + 2*x_1*x_6 + 2*x_2*x_6 + 2*x_3*x_6 + 2*x_4*x_6 + 2*x_5*x_6 + x_6^2) + 1/6*(2*x_10*x_11 + x_11^2 + 2*x_10*x_12 + 2*x_11*x_12 + 2*x_12^2 + 2*x_10*x_13 + 2*x_11*x_13 + 2*x_12*x_13 + 2*x_13^2 + 2*x_11*x_7 + 2*x_10*x_8 + 2*x_11*x_8 + 2*x_12*x_8 + 2*x_13*x_8 + 2*x_10*x_9 + 2*x_11*x_9 + 2*x_12*x_9 + 2*x_13*x_9 + 2*x_8*x_9)*(2*x_15*x_16 + 2*x_15*x_17 + 2*x_16*x_17 + 2*x_14*x_18 + 2*x_15*x_18 + 2*x_16*x_18 + 2*x_17*x_18 + x_18^2 + 2*x_15*x_19 + 2*x_16*x_19 + 2*x_17*x_19 + 2*x_18*x_19 + 2*x_19^2 + 2*x_15*x_20 + 2*x_16*x_20 + 2*x_17*x_20 + 2*x_18*x_20 + 2*x_19*x_20 + 2*x_20^2)*(2*x_1*x_2 + 2*x_1*x_3 + 2*x_2*x_3 + 2*x_0*x_4 + 2*x_1*x_4 + 2*x_2*x_4 + 2*x_3*x_4 + x_4^2 + 2*x_1*x_5 + 2*x_2*x_5 + 2*x_3*x_5 + 2*x_4*x_5 + 2*x_5^2 + 2*x_1*x_6 + 2*x_2*x_6 + 2*x_3*x_6 + 2*x_4*x_6 + 2*x_5*x_6 + 2*x_6^2)Sébastien PalcouxThu, 05 Sep 2019 22:37:42 +0200https://ask.sagemath.org/question/47771/How can I assign different degrees to the variables of a polynomial ring?https://ask.sagemath.org/question/47290/how-can-i-assign-different-degrees-to-the-variables-of-a-polynomial-ring/ In defining a polynomial ring, is there any way to assign varying degrees to the variables?
For example I want to define the polynomial ring Q[x, y, z] but I want x to be of degree 1, y to be degree 2, and z to be degree 3. I am looking for a way to do this in general not just for a small number of variables.
Laughematician760Mon, 29 Jul 2019 07:07:55 +0200https://ask.sagemath.org/question/47290/How to change/set variables?https://ask.sagemath.org/question/46945/how-to-changeset-variables/I created a list of formal variables that I want to work with under addition, multiplication etc. in the following way:
g = list(var('g_%d' % i) for i in rang(4))
Specifically I'm working with differential forms
M = Manifold(4, 'M', field='complex')
U = M.open_subset('U')
c_xyXY<x, y, X, Y>=U.chart()
eU = c_xyXY.frame()
d = [[M.diff_form(2, name='d_{}{}'.format(j, i)) for i in range(2)] for j in range(2)]
d[0][0] [eU, 2, 0] = g[0]
d[0][1] [eU, 3, 0] = g[1]
d[1][0] [eU, 2, 1] = g[2]
d[1][1] [eU, 3, 1] = g[3]
I then want to set the variables to something specific like
g[0] = x^2
but when I try to display this I get
d[0][0].display(eU)
d_00 = -g_0dx/\dX
What I want is
d_00 = -x^2dx/\dX
EDIT: The question as originally asked has been sufficiently answered by eric_g below. However I'm still having difficulty with a more complicated version of the same set-up, which I present here:
https://ask.sagemath.org/question/46993/update-how-to-changeset-variables/sum8tionWed, 19 Jun 2019 19:57:49 +0200https://ask.sagemath.org/question/46945/solve equation with two variables over RRhttps://ask.sagemath.org/question/46915/solve-equation-with-two-variables-over-rr/Hi,
I have a problem with the following code (minimal example) in SageMath 8.7 notebook:
x, y = var('x,y', domain=RR)
solve(x == 0, x, y)
when executed, I get the following error:
/opt/sagemath-8.7/local/lib/python2.7/site-packages/sage/symbolic/relation.pyc in _solve_expression(f, x, explicit_solutions, multiplicities, to_poly_solve, solution_dict, algorithm, domain)
1357 if to_check:
1358 for ix, soln in reversed(list(enumerate(X))):
-> 1359 if soln.lhs().is_symbol():
1360 if any(a.contradicts(soln) for a in to_check):
1361 del X[ix]
AttributeError: 'list' object has no attribute 'lhs'
both
x, y = var('x,y')
solve(x == 0, x, y)
and
x, y = var('x,y', domain=RR)
solve(x == 0, x)
work as expected.
I am sorry if that question a already been posted, I don't know which keyword to use.
Pierre MacherlFri, 14 Jun 2019 16:48:56 +0200https://ask.sagemath.org/question/46915/Creating a symbolic matrix in a loop and then substituting values in for the variables?https://ask.sagemath.org/question/41655/creating-a-symbolic-matrix-in-a-loop-and-then-substituting-values-in-for-the-variables/I need to create a symbolic matrix in terms of the variables xi with one row of n elements for a given integer n, so for example if n=5 i would need to compute the matrix `[x0, x1, x2, x3, x4]`
As a follow on from this i then need to substitute in random values from a finite field say `GF(q)` for the first `v` number of variables in the matrix for a given integer `v < n` . So for example if `v = 3` then i would need to substitute in random values from `GF(q)` for the first `x0, x1, x2 ` variables of the matrix to get something like `[GF(q).random_element(), GF(q).random_element(), GF(q).random_element(), x3, x4 ]` of course i need to be able to do this for any integers n and v i choose. Any help about how to do this in sage would be great, thanks.
EDIT: I need to substitute in random values from a finite field say `GF(q)` for the first `v` number of variables for a given integer `v < n` into each of the multivariate equations in a list. So for example, if my list of multivariate equations is given by `eqn` where `eqn` looks like the following: `[[10*x0^2 + 11*x0*x1 - 12*x1^2 - 14*x0*x2 + 8*x1*x2 + 6*x2^2 - 15*x0*x3 - 13*x1*x3 - 7*x2*x3 + 9*x3^2 - 13*x0*x4 + 11*x1*x4 + 6*x2*x4 - 15*x3*x4 + 11*x4^2 - 13*x0*x5 + 12*x1*x5 + 6*x2*x5 - 8*x4*x5 + x5^2], [4*x0^2 + 8*x0*x1 - 3*x1^2 - 8*x0*x2 - 3*x1*x2 - 10*x2^2 + 5*x0*x3 - 14*x1*x3 - 5*x2*x3 - 12*x3^2 - 10*x0*x4 + 8*x1*x4 - 10*x2*x4 - 4*x3*x4 + 6*x4^2 - 11*x0*x5 - 3*x1*x5 - 9*x2*x5 + 9*x3*x5 + 4*x4*x5 - 11*x5^2]]` when `o = 2` then i need to substitute random values from GF(q) into the first v variables, to obtain a list of multivariate equations in only the remaining variables that have not been substituted.DalvirTue, 20 Mar 2018 15:44:10 +0100https://ask.sagemath.org/question/41655/Different syntax to solvehttps://ask.sagemath.org/question/33361/different-syntax-to-solve/ I've below equation( j.mp/sage_emi ) involving 4 variables. I've fixed 3 variables' values, but can't get the 4th variables' value (both, including numerical). Can someone fix the code? Manually, I can get the answer for emi as 1210/21.
P, emi, rate, duration = var("P emi rate duration")
eq1 = P = emi * (( 1 + rate / 100)^ duration - 1) / (rate / 100) / (1 + rate /100)^ duration
solve([eq1, P == 100, duration == 2, rate == 10], emi)
It would be helpful if someone writes 2,3 different sage code to achieve the same above objective.
I'm just curious can we do this:
solve([eq1], rate)
Sukrit-GuptaWed, 11 May 2016 07:32:54 +0200https://ask.sagemath.org/question/33361/Ritt-Wu algorithm?https://ask.sagemath.org/question/27046/ritt-wu-algorithm/Has anybody implemented in Sage the [Ritt-Wu](http://en.wikipedia.org/wiki/Wu%27s_method_of_characteristic_set) algorithm for solving multivariate polynomial equations? Apparently (I've never used it, although I'd certainly like to try it!) it can be used as an alternative to the better known technique of Groebner bases. There is a `wsolve` operation in Maple, but I don't have access to Maple.AlasdairSun, 07 Jun 2015 08:18:20 +0200https://ask.sagemath.org/question/27046/Checking an ideal over $\overline{\mathbb Q}$ for primalityhttps://ask.sagemath.org/question/25104/checking-an-ideal-over-overlinemathbb-q-for-primality/I'm trying to check an ideal in a multivariate polynomial ring over $\overline{\mathbb Q}$ for primality.
Using just a single variable, I can type
R.<x> = PolynomialRing(QQ.algebraic_closure())
print Ideal([x^2+2]).is_prime()
and Sage tells me that $\langle x^2+2\rangle$ is not prime in $\overline{\mathbb Q}[x]$, as expected.
However, as soon as I add another variable, e.g. `R.<x,y> = ...` I get the following output:
<pre>
verbose 0 (3539: multi_polynomial_ideal.py, groebner_basis) Warning: falling back to very slow toy implementation.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-8-c0542a5be0f8> in <module>()
----> 1 print Ideal([x**Integer(2)+Integer(2)]).is_prime()
/opt/sage-6.4.beta4/local/lib/python2.7/site-packages/sage/rings/polynomial/multi_polynomial_ideal.pyc in is_prime(self, **kwds)
1265 if not self.ring().base_ring().is_field():
1266 raise NotImplementedError
-> 1267 CPD = self.complete_primary_decomposition(**kwds)
1268 if len(CPD) != 1:
1269 return False
/opt/sage-6.4.beta4/local/lib/python2.7/site-packages/sage/rings/polynomial/multi_polynomial_ideal.pyc in __call__(self, *args, **kwds)
602 if not R.base_ring().is_field():
603 raise ValueError("Coefficient ring must be a field for function '%s'."%(self.f.__name__))
--> 604 return self.f(self._instance, *args, **kwds)
605
606 require_field = RequireField
/opt/sage-6.4.beta4/local/lib/python2.7/site-packages/sage/rings/polynomial/multi_polynomial_ideal.pyc in wrapper(*args, **kwds)
503 """
504 with LibSingularDefaultContext():
--> 505 return func(*args, **kwds)
506 return wrapper
507
/opt/sage-6.4.beta4/local/lib/python2.7/site-packages/sage/rings/polynomial/multi_polynomial_ideal.pyc in complete_primary_decomposition(self, algorithm)
1079 if algorithm == 'sy':
1080 primdecSY = sage.libs.singular.ff.primdec__lib.primdecSY
-> 1081 P = primdecSY(self)
1082 elif algorithm == 'gtz':
1083 primdecGTZ = sage.libs.singular.ff.primdec__lib.primdecGTZ
/opt/sage-6.4.beta4/local/lib/python2.7/site-packages/sage/libs/singular/function.so in sage.libs.singular.function.SingularFunction.__call__ (build/cythonized/sage/libs/singular/function.cpp:13788)()
TypeError: Cannot call Singular function 'primdecSY' with ring parameter of type '<class 'sage.rings.polynomial.multi_polynomial_ring.MPolynomialRing_polydict_domain_with_category'>'
</pre>
Is there a way to work around this or is there really no implementation for primality checks in $\overline{\mathbb Q}[x_1,\dots,x_n]$?pegelWed, 03 Dec 2014 23:28:13 +0100https://ask.sagemath.org/question/25104/Define vector valued function of a vector of symbolic variables?https://ask.sagemath.org/question/24943/define-vector-valued-function-of-a-vector-of-symbolic-variables/ I have a gradient where each component may have a different number of symbolic arguments and get the following error when I run:
gradL<br>
(gradL[0]).arguments()<br>
(gradL[1]).arguments()<br>
(gradL[2]).arguments()<br>
s=[3,.5,.3]<br>
(gradL[0])(*s)<br>
(gradL[1])(*s)<br>
(gradL[2])(*s)<br>
(lam0*(x1 - 1.00000000000000) - log(x0) + log(-x0 + 1), lam0*x0 - log(x1) + log(-x1 + 1), x0*x1 - x0 + 0.500000000000000)<br>
(lam0, x0, x1)<br>
(lam0, x0, x1)<br>
(x0, x1)<br>
-2.10000000000000<br>
2.34729786038720<br>
Error in lines 8-8<br>
Traceback (most recent call last):
File "/projects/5511fe15-8085-4d1d-bdc7-c6bf6c99e693/.sagemathcloud/sage_server.py", line 865, in execute
exec compile(block+'\n', '', 'single') in namespace, locals
File "", line 1, in <module>
File "sage/symbolic/expression.pyx", line 4382, in sage.symbolic.expression.Expression.__call__ (build/cythonized/sage/symbolic/expression.cpp:24669)
File "sage/symbolic/ring.pyx", line 760, in sage.symbolic.ring.SymbolicRing._call_element_ (build/cythonized/sage/symbolic/ring.cpp:8970)
ValueError: the number of arguments must be less than or equal to 2
I need to be able to to be able to define this as a vector valued function of a vector so that I can evaluate it using the entire argument set (lam0, x0, x1) where the missing arguments are ignored for the corresponding component. This is so I can def a function for scipy.optimize like:
def F(s):<br>
tmp=[]<br>
for ii in range(len(gradL)):<br>
tmp.append((gradL[ii])(*s))<br>
return tmp<br>
ssoln = scipy.optimize.broyden1(F, [.5,.5,.5], f_tol=1e-14)
I can't figure out how to accomplish this. Thanks for any help in advance.
-Steve
strangerlandSat, 22 Nov 2014 18:24:55 +0100https://ask.sagemath.org/question/24943/Multivariate polynomials again: specifying variableshttps://ask.sagemath.org/question/10936/multivariate-polynomials-again-specifying-variables/I'm back looking at multivariate polynomials, with which I was last experimenting about six months ago. Suppose I have a polynomial in four variables x,y,z,w. What I need to do is:
1. Rewrite the polynomial in terms of two of the variables (say x, y), to obtain something like Ax^2y+Bxy+Cxy^3+Dx^2y^3, where each of the coefficients A, B, C and D is a polynomial in z and w.
2. Obtain those polynomials in z and w as a list.
I don't know in advance what powers of x and y will be in the expression, nor do I know how many terms there will be.
I would have thought this would be fairly straightforward, but I can't find an easy way to do it. In Maxima number one can be done with "collectterms", but the Sage method "collect" seems only to work on one variable at a time.AlasdairThu, 16 Jan 2014 18:13:53 +0100https://ask.sagemath.org/question/10936/