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.Fri, 23 Jul 2021 20:08:14 +0200Coefficient of a single variable polynomial over a modular ringhttps://ask.sagemath.org/question/58104/coefficient-of-a-single-variable-polynomial-over-a-modular-ring/ I want to find coefficent of a polynomial ring. How to do this?
R.<x>=IntegerModRing(15)[]
f=1+x^2+4*x^6
So coefficient of x is 0, x^2 is 1, x^6 is 4 etc.
How to get these?
SanuFri, 23 Jul 2021 20:08:14 +0200https://ask.sagemath.org/question/58104/Defining vector partition functions in sagehttps://ask.sagemath.org/question/58072/defining-vector-partition-functions-in-sage/I want to define a vector partition function starting from a given list of vectors. For example, let's say I have vectors $v_1,v_2,v_1+v_2$ where $v_1,v_2$ are linearly independent and I want to list all the partitions using these three vectors. For convenience I can define the set of positive vectors to be the set $\{kv_1+lv_2:k,l \in \mathbb{Z}_{\geq 0} \} $, and for the program to be finite I am okay with taking $k,l$ only up to some fixed number, for example I have taken 2 below. I am trying as follows:
sage: v1,v2 = var('v1','v2')
sage: S = [v1,v2,v1+v2]
sage: Pos = [k*v1+l*v2 for k in [0,1,2] for l in [0,1,2]]
sage: def par(x):
sage: p(x) = []
sage: for y in S :
sage: if x-y in Pos:
sage: for z in p(x-y):
sage: n = z + y
sage: if n not in p(x):
sage: p(x)=p(x)+n
sage: return p(x)
This does not work. I don't understand why. Somehow `sage: par(v1)` gives () as answer and `sage: par(v1+v2)` gives TypeError: Must construct a function with a tuple (or list) of variables.
Please help me out.
Edit:
Vector partition function: I have a fixed set $S=\{ v_1,...,v_n\} $ of vectors, let $v$ be a vector. An expression of the form $v=c_1v_1+...+c_nv_n$ with $c_i\in \mathbb{Z}_{\geq 0}$ is called a partition of $v$. $Par(v)$ be the set of partitions of $v$. I want to find out this set at the end of the program.
Roughly, what I wanted was: Start with L an empty list/set. Find $P(v-v_i)$ for each $i$. For each partition of $v-v_i$ attach $v_i$ to make it a partition of $v$. Now check whether the new partition thus formed is already counted before or not, if not then enter it in L.mathstudentWed, 21 Jul 2021 15:16:53 +0200https://ask.sagemath.org/question/58072/TypeError: dist must be a Distribution instancehttps://ask.sagemath.org/question/58081/typeerror-dist-must-be-a-distribution-instance/Hi,
Suddenly, using Cython magic, I got the message **"TypeError: dist must be a Distribution instance"**.
I use Sage 9.3 Ubuntu with Jupyter and compile via %%cython -a.
I tried an other *ipynb* file, and there was no problem using Cython...<br>
Only one *ipynb* file seems to have this problem.
Further research shows that the probable cause is the use of **cython_lambda**.
Any solution is very appreciated.
RolandrolandThu, 22 Jul 2021 10:33:18 +0200https://ask.sagemath.org/question/58081/Express a vector field in terms of a framehttps://ask.sagemath.org/question/58073/express-a-vector-field-in-terms-of-a-frame/I have a set of 4 vector fields that form a frame, I have defined them as
N = Manifold(4, 'N')
Y.<x,y,k,t> = N.chart()
F = Y.frame()
X_1 = cos(k)*F[0] + sin(k)*F[1] + (-y/2*cos(k) + x/2*sin(k))*F[3]
X_2 = -sin(k)*F[0] + cos(k)*F[1] + (x/2*cos(k) + y/2*sin(k))*F[3]
X_3 = F[3]
b = var('b', domain='real')
assume(2 > b, b >= 0)
X_4 = F[2] - b*F[3]
Now I want to calculate their Lie bracket and express it in terms
of these vectors fields, for example the following gives `[X_2, X_4]`,
and I would like that written in terms of the `{X_1, X_2, X_3, X_4}`,
in this case the output should be `X_1`.
vw = X_2.bracket(X_4)
vw
vw.display()
In general, I would like to know, given a vector field `V`
in the original frame, how it can be expressed
in terms of `{X_1, X_2, X_3, X_4}`. Many thanks.raulWed, 21 Jul 2021 16:08:38 +0200https://ask.sagemath.org/question/58073/Elliptic curves over function fieldshttps://ask.sagemath.org/question/58049/elliptic-curves-over-function-fields/I was wondering if SageMath can compute the local data at each place for elliptic curves over function fields. It seems that Magma can do so. Thanks.John WoodMon, 19 Jul 2021 03:26:13 +0200https://ask.sagemath.org/question/58049/Only the most basic stuff neededhttps://ask.sagemath.org/question/58075/only-the-most-basic-stuff-needed/I installed sage years ago, and it worked with simple computations like sum from to .. combinations of well known functions.
Now I seem to have forgotten totally how to use it.
As I remember I only used comand line, not sure if inside sage, or the usual terminal of this linux system.
So I need to get the most basic info.
1. How to Sage install on linux (maybe not needed, because it was installed)
2. How to run it.
3. How to type a command to make a basic computation.
I can't see anything anywhere which resembles math.
I only see computer instructions which seem to be written for CS experts.
basicWed, 21 Jul 2021 21:56:59 +0200https://ask.sagemath.org/question/58075/Assuming matrix is positive semi-definitehttps://ask.sagemath.org/question/58070/assuming-matrix-is-positive-semi-definite/ I'm trying to find moments of of transformations of the multivariate normal distribution.
Let $x,y,z\sim N(\mu, \Sigma)$, I want to find out (for example) $E[e^x], E[e^{2x}], E[e^xy]$.
I have defined the following:
x, y, z = var('x y z')
X = vector([x,y,z])
mx, my, mz = var('mx my mz')
mu = vector([mx, my, mz])
sx, sy, sz = var('sx sy sz')
sxy, sxz, syz = var('sxy sxz syz')
assume(sx > 0)
assume(sy > 0)
assume(sz > 0)
S = matrix(SR, [[sx^2, sxy, sxz], [sxy, sy^2, syz], [sxz, syz, sz^2]])
f = (1 / sqrt(S.det() * (2*pi)^3))*exp(-0.5*((X - mu) * S.inverse() * (X - mu)))
And now I'm trying some integration, for example:
(x*f).integrate(z, -Infinity, Infinity).integrate(y, -Infinity, Infinity).integrate(x, -Infinity, Infinity)
I'd expect this to yield `mx` but of course life ain't easy so I get errors related to the covariance matrix:
ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before evaluation *may* help (example of legal syntax is 'assume(sx^2*(sy^2*sz^2-syz^2)
>0)', see `assume?` for more details)
Is sx^2*(sy^2*sz^2-syz^2)
-sxy^2*sz^2
+2*sxy*sxz*syz
-sxz^2*sy^2 positive or negative?
Even for 1D integration (i.e only over $z$, `(x*f).integrate(z, -Infinity, Infinity)`) I get errors:
ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before evaluation *may* help (example of legal syntax is 'assume(sx^2*(sy^2*sz^2-syz^2)
>0)', see `assume?` for more details)
Is sx^2*(sy^2*sz^2-syz^2)
-sxy^2*sz^2
+2*sxy*sxz*syz
-sxz^2*sy^2 positive or negative?
I have tried assuming everything he asks but I still get the same errors. Is there any nice way of telling `SAGE` to assume the matrix `S` is positive-semidefinite?
PS I have managed to work with two 2D case, by using correlation and the "full" version of the formula (rather than the vectorized):
x = var('x')
y = var('y')
mux = var('mux')
muy = var('muy')
sx = var('sx')
sy = var('sy')
r = var('r')
assume(r<=1)
assume(r>=-1)
k = 1/(2*pi*sx*sy*sqrt(1-r^2))
fxy = k*exp(-(1/(2*(1-r^2)))*(((x-mux)/sx)^2 - 2*r*((x-mux)/sx)*((y-muy)/sy) + ((y-muy)/sy)^2))
If I run `integrate(integrate(x*fxy, y, -Infinity, Infinity), x, -Infinity, Infinity).simplify()`, the result is eventually the correct one (`mux`).guyaspWed, 21 Jul 2021 09:58:41 +0200https://ask.sagemath.org/question/58070/Generate dnf and cnf with Sage possible?https://ask.sagemath.org/question/58059/generate-dnf-and-cnf-with-sage-possible/Hello,
I just found out about Sagemath. We previously used sympy to calculate the dnf and cnf of a truthtable, but only one answer is given. Is something similar in Sagemath (logic) possible, but maybe with different solutions?lemircoTue, 20 Jul 2021 15:14:11 +0200https://ask.sagemath.org/question/58059/Solving equations in SageMathhttps://ask.sagemath.org/question/58055/solving-equations-in-sagemath/Hey! I'm new to sage and I'm trying to see how complex are the calculations that I can express in SageMath. So I considered the following example, the comparison between the likelihood of two normals with different means but same variance:
$$ \dfrac{1}{\sigma\sqrt{2\pi} } \exp{\left(-\dfrac{(x-\mu_1)^2}{2\sigma^2}\right)} = \dfrac{1}{\sigma\sqrt{2\pi} } \exp{\left(-\dfrac{(x-\mu_2)^2}{2\sigma^2}\right)} $$
I know that the answer must be $\mu_1 = \mu_2$. Can I solve it with SageMath? I tried:
x, mu1, mu2, sigma = var('x, mu1, mu2, sigma')
exp((0.5/sigma)*(x-mu1)^2)==exp((0.5/sigma)*(x-mu2)^2)
and
solve(exp((0.5/sigma)*(x-mu1)^2)==exp((0.5/sigma)*(x-mu2)^2))
but that doesn't seem to work. Is it possible to do so in sagemath? Thanks!! YetAnotherUsrMon, 19 Jul 2021 21:16:32 +0200https://ask.sagemath.org/question/58055/How to compute an ideal of specific norm?https://ask.sagemath.org/question/58029/how-to-compute-an-ideal-of-specific-norm/So I was wondering if there was a way to compute ideals of a certain norm something like:
sage: K = QuadraticField(2)
sage: K.ideal_of_norm(2)
[Fractional ideal (a)]
something like this.prathamlalwaniFri, 16 Jul 2021 09:01:52 +0200https://ask.sagemath.org/question/58029/Plotting a Cayley graphhttps://ask.sagemath.org/question/58052/plotting-a-cayley-graph/ I want to plot a Cayley graph that its connection set is derangements. I mean
https://doc.sagemath.org/html/en/reference/combinat/sage/combinat/derangements.html
I wrote this code, but it fails to run.
G = SymmetricGroup(3)
CG = G.cayley_graph(generators = Derangements(3))
CGU = CG.to_undirected()
CGU.show()
Could you please give me help?salamMon, 19 Jul 2021 18:21:04 +0200https://ask.sagemath.org/question/58052/I want to display the origin on the graph.https://ask.sagemath.org/question/58027/i-want-to-display-the-origin-on-the-graph/I'm displaying the graph of a function as follows:
d = 2
n = 1
psi(x) = sqrt(2.0/d)*sin(n*pi*x/d)
graph = plot(abs(psi(x))^2, 0, d, figsize=5, axes_labels=['$x$', '$|\psi_{1}(x)|^2$'])
graph.show()
I want to display "o" at the origin. Is there no choice but to display it in text as shown below?
text('o', (-1, -1))
fukuiFri, 16 Jul 2021 04:35:02 +0200https://ask.sagemath.org/question/58027/Sage refuses to evaluate summations...https://ask.sagemath.org/question/58045/sage-refuses-to-evaluate-summations/I'm trying to define a function
g(x) = sum(frac(j*p/q), j, 0, x)
where `p`, `q` are pre-defined constants (say `(p, q)=(33, 21)`).
Sage did not give any errors, but when I type `g(10)`,
I would get output symbolic expression `sum(frac(11/7*j), j, 0, 10)`,
which is different from the expected value `31/7`.
How do I fix this?HyacinthSun, 18 Jul 2021 00:10:31 +0200https://ask.sagemath.org/question/58045/AttributeError when load object (ideal and groebner basis) with numpy.loadhttps://ask.sagemath.org/question/58040/attributeerror-when-load-object-ideal-and-groebner-basis-with-numpyload/I've calculated Groebner Basis with sage and have saved it with
I = Ideal(ideal_generators)
B = I.groebner_basis(algorithm=groebner_alghorithm);
np.save("output/basis_ideal", (B, I))
where `ideal_generators` is some equations in PolynomialRing of several variables. It was in 2019.
After two years (and several updates of SageMath) I try to load that saved object and get an error: `AttributeError: 'TermOrder' object has no attribute '_singular_ringorder_column'`.
I've saved several baseis and some of them are loaded fine and some with such error.
How to load that "broken" files?
P.S. Full traceback:
Traceback (most recent call last):
File "/home/user/algebra/groebner.sage.py", line 55, in <module>
B, I = np.load(filename, allow_pickle=True)
File "/usr/lib/python3.9/site-packages/numpy/lib/npyio.py", line 440, in load
return format.read_array(fid, allow_pickle=allow_pickle,
File "/usr/lib/python3.9/site-packages/numpy/lib/format.py", line 744, in read_array
array = pickle.load(fp, **pickle_kwargs)
File "sage/rings/polynomial/multi_polynomial_libsingular.pyx", line 1925, in sage.rings.polynomial.multi_polynomial_libsingular.unpickle_MPolynomialRing_libsingular (build/cythonized/sage/rings/polynomial/multi_polynomial_libsingular.cpp:19177)
File "/usr/lib/python3.9/site-packages/sage/rings/polynomial/polynomial_ring_constructor.py", line 777, in _multi_variate
R = MPolynomialRing_libsingular(base_ring, n, names, order)
File "sage/rings/polynomial/multi_polynomial_libsingular.pyx", line 384, in sage.rings.polynomial.multi_polynomial_libsingular.MPolynomialRing_libsingular.__init__ (build/cythonized/sage/rings/polynomial/multi_polynomial_libsingular.cpp:5668)
File "sage/libs/singular/ring.pyx", line 167, in sage.libs.singular.ring.singular_ring_new (build/cythonized/sage/libs/singular/ring.cpp:3856)
AttributeError: 'TermOrder' object has no attribute '_singular_ringorder_column'petRUShkaSat, 17 Jul 2021 20:44:42 +0200https://ask.sagemath.org/question/58040/set_trace() analog for Sagehttps://ask.sagemath.org/question/58014/set_trace-analog-for-sage/ In sage one can use `import pdb;pdb.set_trace()` or in case of tests: `import pytest; pytest.set_trace()`. But these commands invoke pure python console without Sage improvements.
Are there something like `sage.set_trace()` command which opens Sage REPL instead if Python REPL?petRUShkaWed, 14 Jul 2021 15:24:39 +0200https://ask.sagemath.org/question/58014/polynomial multiplication is unexpectedly slowhttps://ask.sagemath.org/question/58035/polynomial-multiplication-is-unexpectedly-slow/Hello!
I'm writing some code to solve by radicals a polynomial with solvable galois group, and an important part of doing this is the special case of a cyclic field extension.
I've implemented the algorithm (probably naively) and while it _works_, it's extremely slow to do a polynomial multiplication in the middle part of the algorithm. Granted, we end up with a polynomial of degree $n!$, but for $n=5$ I feel like it shouldn't be quite as slow as it is (though maybe I'm wrong). As an aside, if anybody knows of a more efficient algorithm, I would love to hear about it. I'm thinking of looking through the references of [this paper](https://www.ams.org/journals/mcom/1999-68-226/S0025-5718-99-01060-1/S0025-5718-99-01060-1.pdf), but I haven't had time yet.
Here's a minimal excerpt from the code which shows the part that runs slowly:
f = x^3 + x^2 - 2*x - 1
n = f.degree(x)
# make a number field where w is a nth root of 1
K.<w> = CyclotomicField(n)
# make vars for the roots.
# a[i] = alpha_i
R = PolynomialRing(K, n, 'a')
a = R.gens()
v = sum([w^k * a[k] for k in range(n)])^3
# build the conjugates of v.
# it turns out we only need one from each conjugacy class,
# which keeps the degree down.
Sn = SymmetricGroup(n)
conjugates = []
for tau in Sn:
if v * tau not in conjugates:
conjugates += [v * tau]
S.<Y> = PolynomialRing(R)
psi = 1
for c in conjugates:
psi *= (Y - c)
It took my desktop (Ryzen 5 3600) running overnight to fully compute this polynomial. I've tried using `prod(Y-c for c in conjugates)` as well as `product`, rather than the explicit loop I have here. I've also tried making `Y` a symbolic variable rather than an element of a polynomial ring, but nothing has appreciably decreased the runtime.
The first 10 multiplications or so happen without much hassle, but very quickly things start going very slowly. If anyone has any ideas, I would love to hear them!
Thanks in advance ^_^dispoSat, 17 Jul 2021 09:29:29 +0200https://ask.sagemath.org/question/58035/Finite categories?https://ask.sagemath.org/question/58033/finite-categories/Hi,
As part of a project on geometry of moduli of curves ('stacky fans') I'm trying to implement `categories with finitely many objects and finitely many morphisms'. I've started creating a class FiniteCat, but I can't decide whether it should be a child of DiGraph (where I add extra data of composition) , or of Category, using the existing machinery around that.
For context, I'm going to start with creating a FiniteCat from a lattice/poset (with maybe a couple of hundred vertices), then adding in a few more interesting (auto)morphisms). The main purpose is that I want to look at (pre)sheaves on these categories, check whether certain collections of data define sections of these presheaves, and perform basic operations on them.
Any suggestions would be very welcome .
Thanks,
David HolmesDavid HolmesFri, 16 Jul 2021 13:07:46 +0200https://ask.sagemath.org/question/58033/_invert_ for ring which is not integralhttps://ask.sagemath.org/question/58031/_invert_-for-ring-which-is-not-integral/ Suppose I have implemented my own ring `MyRing` which derives (among others) from `CommutativeRing`. `MyRing` is not an integral domain, so `MyRing.is_integral_domain()` will return `False`. The element class is called `MyRingElement` and is derived from `CommutativeRingElement`. All arithmetic operations on `MyRingElement`, like `_add_`, `_mult_`, etc., work well. Some of the elements are invertible and for those, `_invert_` will return the inverse (or raise an error if no inverse exists). What is the Sage-way to call `_invert_`?
R = MyRing()
el = R.an_element()
~el # or 1/el or el.inverse_of_unit()
yields an error as `MyRing` is not an integral domain:
> ~/sage-9.2/local/lib/python3.8/site-packages/sage/structure/element.pyx
> in
> sage.structure.element.RingElement.__invert__
> (build/cythonized/sage/structure/element.c:19405)()
> 2738 2739 def
> __invert__(self):
> -> 2740 return self._parent.one() / self 2741
> 2742 def additive_order(self):
>
> ~/sage-9.2/local/lib/python3.8/site-packages/sage/structure/element.pyx
> in
> sage.structure.element.Element.__truediv__
> (build/cythonized/sage/structure/element.c:13147)()
> 1733 cdef int cl =
> classify_elements(left, right) 1734
> if HAVE_SAME_PARENT(cl):
> -> 1735 return (<Element>left)._div_(right) 1736
> if BOTH_ARE_ELEMENT(cl): 1737
> return coercion_model.bin_op(left,
> right, truediv)
>
> ~/sage-9.2/local/lib/python3.8/site-packages/sage/structure/element.pyx
> in
> sage.structure.element.RingElement._div_
> (build/cythonized/sage/structure/element.c:19149)()
> 2732 """ 2733 try:
> -> 2734 frac = self._parent.fraction_field() 2735
> except AttributeError: 2736
> raise bin_op_exception('/', self,
> other)
>
> ~/sage-9.2/local/lib/python3.8/site-packages/sage/rings/ring.pyx
> in
> sage.rings.ring.CommutativeRing.fraction_field
> (build/cythonized/sage/rings/ring.c:12126)()
> 1328 1329 if not
> self.is_integral_domain():
> -> 1330 raise TypeError("self must be an integral
> domain.") 1331 1332 if
> self.__fraction_field is not None:
>
> TypeError: self must be an integral
> domain.philipp7Fri, 16 Jul 2021 09:52:41 +0200https://ask.sagemath.org/question/58031/linear distancehttps://ask.sagemath.org/question/58025/linear-distance/ Hello
I want to take linear distance beetween two points on Eliptic curve:
curve : y2=x3+7 secp256k1
p_string = 'FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE FFFFFC2F'
p = ZZ( '0x' + p_string.replace(' ', ''))
p
E = EllipticCurve( GF(p), [0, 7] )
E
n_string = 'FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE BAAEDCE6 AF48A03B BFD25E8C D0364141'
n = ZZ( '0x' + n_string.replace(' ', '') )
xP = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
yP = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
P = E.point( (xP, yP) ) # Generator point
Point no 1:
p_1_x=0x28f3c7982219bf067d9723a54bef8e0ae7d970b4285a148685ce98819bd59c99
p_1_y=0x3da6945a85ba67249e96534f3cb93af144301e3ef03f848ebf17fedd55addd14
P1 = E.point( (p_1_x, p_1_y) )
Point no 2:
p_2_x=0xc69b120facc137ad7ecf7407b97f3e1bcecec27ed6617ad1e3bb4f5a265c2230
p_2_y=0xdab461d8de9d194b9aae05cf3fc361e31b0cd172985720a9963a1fd9cb4dab13
P2 = E.point( (p_2_x, p_2_y) )
#calculation : perform add or mult for equal :
P1_mult = P1 * 82096204097375626523300693245739453783745399685178560726932375997561515334942 =
P1_mult result=
(46471116781602954419346378639681376672332207911597631846166461640126253045935 : 115074167981782238568697336312618123980176908468606887399010690362202000326798 : 1)
P2_add = P2 + 29894233847412895230616850443375888414306408440111129860511310128693381347651 * P
P2_add result:
(46471116781602954419346378639681376672332207911597631846166461640126253045935 : 115074167981782238568697336312618123980176908468606887399010690362202000326798 : 1)
so P1_mult = P2_add
so what is linear distance in integer beetween P1 and P2 if we know above information?
at the moment no idea, any tips, solution, How to do?
MiroslawThu, 15 Jul 2021 23:14:35 +0200https://ask.sagemath.org/question/58025/I want to find a generator set of the $l$-torsion points of an elliptic curve defined over a finite field $F_q$https://ask.sagemath.org/question/57994/i-want-to-find-a-generator-set-of-the-l-torsion-points-of-an-elliptic-curve-defined-over-a-finite-field-f_q/I have the elliptic curve $E: y^2=x^3+x$ defined over a field $F_q$ with $q=p^2$ for a certain prime $p$, and want to calculate the $l$-torsion points, or in other words $E[l]$, for an integer $l$ (probably a prime different from $p$.)M.TawfikTue, 13 Jul 2021 21:38:36 +0200https://ask.sagemath.org/question/57994/Dedekind Zeta function of cyclotomic field wrongly evaluating to zero on -1?https://ask.sagemath.org/question/55607/dedekind-zeta-function-of-cyclotomic-field-wrongly-evaluating-to-zero-on-1/Let $K := \mathbb{Q}(\zeta)$ be the pth cyclotomic extension of $\mathbb{Q}$. I would like to verify the results of a paper which states the quotient of their Dedekind zeta functions have particular values. Below Z is the Riemann zeta function (Dedekind zeta function of $\mathbb{Q}$).
x = var('x')
K = NumberField(x**2 + x + 1,'a')
L = K.zeta_function(algorithm='gp')
Z = Dokchitser(conductor=1, gammaV=[0], weight=1, eps=1, poles=[1], residues=[-1], init='1')
The expected values are nonzero! For example. `(L/Z)(-1)` is expected to be `1.333333333` (i.e. 4/3).
`L(-1)` returns `0.000000000000000`, as does `L(-1)/Z(-1)`.
`Z(-1)` returns `-0.0833333333333333`. `L/Z` returns a type error, as does `L(x)/Z(x)`.
Here is my first question: Have I incorrectly implemented the Dedekind Zeta function of a cyclotomic number field? Why is `L(-1) = 0`?
Here is my second question: How do I implement the evaluation of the L-series after I've taken their quotient? That is, `A = L/Z, A(-1);` instead of `L(-1)/Z(-1)`. masseygirlSat, 06 Feb 2021 23:44:49 +0100https://ask.sagemath.org/question/55607/find the first power of $t$ with a non-positive coefficienthttps://ask.sagemath.org/question/58003/find-the-first-power-of-t-with-a-non-positive-coefficient/
Consider the following rational expression in $t$,
$$f(t)=\frac{(1-t^q)^{m-k}((1-t^2)^m}{(1-t)^{m-k+1}((1-t^{2q})^m}$$
where $q=4,m=33, k=31$.
I want to find the first power of $t$ with a non-positive coefficient. How can I proceed?
The hint given in the book is that
$$f(t)=1 + 26t + 295t^2 + 1820t^3 + 5610t^4 − 1560t^5+\dots$$
How did the author of the book arrived at this approximation? Kindly give some hints. Is it possible to do it in SageMath.
Thanks for readingSri1729Wed, 14 Jul 2021 07:43:44 +0200https://ask.sagemath.org/question/58003/numeric precision unexpectedly lowhttps://ask.sagemath.org/question/58012/numeric-precision-unexpectedly-low/I try to integrate a probability density function over an fixed interval.
Can't give the like but it is a "relativistic Breit-Wigner Distribution" as in the English Wikipedia.
Gamma = 294000
m = 3686100
gamma = sqrt(m^2*(m^2+Gamma^2))
k = (2*sqrt(2)*m*Gamma*gamma)/(pi*sqrt(m^2+gamma))
BW = k/((x^2-m^2)^2+m^2*Gamma^2)
test = integrate(BW(x),x,m-20*Gamma,m+20*Gamma)
Till here I shouldn't have lost any precision. but when I convert it numerically with
n(test,2000)
I get:
1.003568780514681625312584816997550190541415598167450102773034501594600296432162707154049825083671452461581265874619355037287669117698123644188958803147725041330150928274806048238042399517154207573726037521427349383968841867335044816048064092169439887022730672979989338003256477687641391106254297483937686718675512005461848316884186358220468903611061147782405268579702217582451508116179810896698136112722502668649975423152214020083815884479176920571802765348290248949692543327981513253681778869531348343181499633971108206392658073359294594919457298263920263466439149236869382936665388139526661407807092
Since this is an integral over a probability density it must be less or equal to unity. To make things worse the test I used to catch this failed. When I print n(test,2000)-n(test,5000) I get:
1.548076368777034133563243683402305144019545879147318729129474813190957966982407215191933066512274489911906109674015771900520547143254593904332062734353178144359258512027924010153347526193868596270002650844292344493806124142870891743921764286481744814534440665865632030746674736110661609478466022255757297949839318763567151082721152805813677624313092475594710476219357188434129215184208643483256856632402761545583382935944646898012751255575740279260126952010697251536670906745564901191471261083975404910237568882848368855134234892724370503380053787304268124196831149676013601785994763640281219314046884e-517
So it seems as if 500 digits are correct. Is this a bug or am I not using this correctly? I'm using sage 9.0 as packaged in Ubuntu.just_tryin_to_use_thisWed, 14 Jul 2021 12:35:41 +0200https://ask.sagemath.org/question/58012/Problem with precompute and append in parallel computinghttps://ask.sagemath.org/question/58009/problem-with-precompute-and-append-in-parallel-computing/Here is a parallel computation involving precompute and append:
sage: L=[]
sage: @cached_function
....: def function(i):
....: L.append(i)
....: print(L)
....:
sage: function.precompute(range(5),num_processes=2)
[0]
[1]
[2]
[3]
[4]
The problem is that the list L is still empty at the end, the action `L.append(i)` was not done globally, whereas the list `L` is global.
sage: L
[]
How to solve this problem?Sébastien PalcouxWed, 14 Jul 2021 10:13:53 +0200https://ask.sagemath.org/question/58009/Boolean Polynomial Ringhttps://ask.sagemath.org/question/58007/boolean-polynomial-ring/ Dear all,
I am working polynomial ring of 100 binary variables. Sometime I get polynomial with only 4 variables.
I want to study these polynomials. My following code is giving error:
from sage.crypto.boolean_function import BooleanFunction
V = BooleanPolynomialRing(100,['x%d'%(i) for i in range(100)])
V.inject_variables()
f=x1*x2+x3*x4
xx=f.variables()
l=len(xx)
P=BooleanPolynomialRing(l,map(str,xx))
f=P(f)SanuWed, 14 Jul 2021 09:47:05 +0200https://ask.sagemath.org/question/58007/How do I install Jupyterlab ?https://ask.sagemath.org/question/57998/how-do-i-install-jupyterlab/I am on Windows 10, My understanding is that, to install jupyterlab I have to run:
(1) sage -pip install jupyterlab
(2) sage -i jupyterlab_widgets
is this right ?
but I get the following error when I execute them:
> 'sage' is not recognized as an internal or external command, operable program or batch file.
.....
Is there an alternative way to install jupyterlab without messing around with environment variables ?l3gi0nTue, 13 Jul 2021 23:37:01 +0200https://ask.sagemath.org/question/57998/How to multiply a list by an integer?https://ask.sagemath.org/question/57992/how-to-multiply-a-list-by-an-integer/This is so basic I'm embarrassed to even ask the question, but I've tried all the possibilities I can think of, and searched two SM guides (SM Tutorial and SM for Undergrads), and I can't find out how to do this. I want to multiply a list of rational numbers (fractions) by an integer. I've tried with lists and sets (although sets wouldn't really work, because the list of fractions contains repetitions), and I've tried with the single integer as simply a number and as a list. But I always get an error message, saying "unsupported operand type(s)" or something similar. Here is an example of what I'm trying to do:
a = [1, 1/2, 1/3, 3/8, 1/5, 1/3, 3/14, 1/4, 1/6, 1/4,]
b = 840
print (a ^ b)
Help for a clueless newbie would be greatly appreciated. (Also, if anyone can recommend a tutorial or guide that will explain how to do these sorts of things in SM, that would be even better!)Jerry CaveneyTue, 13 Jul 2021 18:14:40 +0200https://ask.sagemath.org/question/57992/Polynomial system without solution in char. 0: classification of char. p with solutionhttps://ask.sagemath.org/question/57934/polynomial-system-without-solution-in-char-0-classification-of-char-p-with-solution/Let $r$ be an integer and let $S$ be a finite set of polynomials $f \in \mathbb{Q}[x_1,\dots, x_r]$. Assume that the ideal $I(S)$ generated by $S$ is $\mathbb{Q}[x_1,\dots, x_r]$ itself, i.e. the Groebner basis is trivial (no solution in char. 0). Then we can lift $1$, i.e. for all $f \in S$ there is $k_f \in \mathbb{Q}[x_1,\dots, x_r]$ such that $\sum_{f \in S}k_ff = 1$.
For simplicity, assume that $S \subset \mathbb{Z}[x_1,\dots, x_r]$. Let $S_p \subset GF(p)[x_1,\dots, x_r]$ be the set of polynomials in $S$ modulo $p$. The problem here is how to classify all the prime numbers $p$ for which the ideal $I(S_p)$ is not $GF(p)[x_1,\dots, x_r]$, i.e. the Groebner basis is not trivial (solution in char. $p$). Let $P_S$ be the set of all such primes.
More precisely, the problem is how to get $P_S$ *in practice*, because in theory, we just need to check every element of the finite set of prime divisors of the denominators of the (simplified) rational coefficients of $k_f$, for all $f$ in $S$.
I am interested in the system in the function TwoParallel in Appendix (slightly different from the one in [this post](https://ask.sagemath.org/question/57180/quick-trivial-groebner-basis-but-too-long-lift-of-one/)).
sage: %time TwoParallel(0)
CPU times: user 48.5 s, sys: 0 ns, total: 48.5 s
Wall time: 48.5 s
[1]
Here is the expected classification for $p<10^7$:
sage: P=Primes()
sage: L=[]
....: for p in range(10000000): # about 1 day of computation
....: if p in P and p!=5:
....: G=TwoParallel(p)
....: if G!=[1]:
....: L.append(p)
sage: L
[11, 17, 29, 41, 1979, 2767, 5791, 13469, 20681]
As $20681 \ll 10^7$, we could naively guess that there is no other such prime $p$, but it is not true...
The following strategy due to Ricardo Buring (see [this answer](https://ask.sagemath.org/question/57180/quick-trivial-groebner-basis-but-too-long-lift-of-one/?answer=57244#post-id-57244), where the system is slightly different) provides other such $p>10^7$: let $M$ be the multiplication matrix on the normal basis associated to C1+C2, of the extra polynomial. The numerator of $\det(M)$ is equal to $n^2$, with the following prime factorization for $n$:
n = 11^4 * 17^2 * 1979 * 2767 * 5791 * 13469 * 20681 *
4151025112783 * 15929905087813 * 2628354959317319 *
21815977082618267790114673 * 253027658769045762395418314237453 *
7255303910453681802448954810627649 * 3770507507964245954661482843443342675673959607
TwoParallel does not map to trivial from $p$ dividing $n$, but **the converse is not true** (see $p = 29, 41$).
The problem is that we cannot *in practice* lift $1$ from A1+A2+extra, but only from C1+C2+extra (see how in the answers of the post mentioned above). It seems hard to lift C1 from A1, the coefficients may be colossal.
_____
**Appendix**
def TwoParallel(p):
if p==0:
F=QQ
else:
F=GF(p)
R1.<u0,u1,u2,v0,v1,v2,v3,v4,v5,v6>=PolynomialRing(F,10)
A1=[u0+7/F(5)*u1+7/F(5)*u2-4/F(125),
5*v0+5*v1+7*v3+7*v5+1/F(5),
25*v0^2+25*v1^2+35*v3^2+35*v5^2-4/F(5),
5*v0^3+5*v1^3+7*v3^3+7*v5^3-v0^2+1/F(125),
5*v0*v1^2+5*v1*v2^2+7*v3*v4^2+7*v5*v6^2+1/F(125),
5*u0*v1-v1^2+7*u1*v3+7*u2*v5+1/F(125),
5*v1+5*v2+7*v4+7*v6+1/F(5),
25*v0*v1+25*v1*v2+35*v3*v4+35*v5*v6+1/F(5),
5*v0^2*v1+5*v1^2*v2+7*v3^2*v4+7*v5^2*v6-v1^2+1/F(125),
25*v1^2+25*v2^2+35*v4^2+35*v6^2-4/F(5),
5*v1^3+5*v2^3+7*v4^3+7*v6^3-u0+1/F(125),
5*u0*v2-v2^2+7*u1*v4+7*u2*v6+1/F(125)]
Id1=R1.ideal(A1)
G1=Id1.groebner_basis()
C1=[g for g in G1]
R2.<y0,y1,y2,z0,z1,z2,z3,z4,z5,z6>=PolynomialRing(F,10)
A2=[y0+7/F(5)*y1+7/F(5)*y2-4/F(125),
5*z0+5*z1+7*z3+7*z5+1/F(5),
25*z0^2+25*z1^2+35*z3^2+35*z5^2-4/F(5),
5*z0^3+5*z1^3+7*z3^3+7*z5^3-y0+1/F(125),
5*y0*z0-z0^2+7*y1*z3+7*y2*z5+1/F(125),
5*z0*z1^2+5*z1*z2^2+7*z3*z4^2+7*z5*z6^2-z1^2+1/F(125),
5*z1+5*z2+7*z4+7*z6+1/F(5),
25*z0*z1+25*z1*z2+35*z3*z4+35*z5*z6+1/F(5),
5*z0^2*z1+5*z1^2*z2+7*z3^2*z4+7*z5^2*z6+1/F(125),
5*y0*z1-z1^2+7*y1*z4+7*y2*z6+1/F(125),
25*z1^2+25*z2^2+35*z4^2+35*z6^2-4/F(5),
5*z1^3+5*z2^3+7*z4^3+7*z6^3-z2^2+1/F(125)]
Id2=R2.ideal(A2)
G2=Id2.groebner_basis()
C2=[g for g in G2]
R.<u0,u1,u2,v0,v1,v2,v3,v4,v5,v6,y0,y1,y2,z0,z1,z2,z3,z4,z5,z6>=PolynomialRing(F,20)
C=C1+C2+[5*u0*z2 + 7*u1*z4 + 7*u2*z6 - u0 + 1/F(125)] # extra polynomial
Id=R.ideal(C)
G=Id.groebner_basis()
return GSébastien PalcouxFri, 09 Jul 2021 11:26:49 +0200https://ask.sagemath.org/question/57934/Implicit derivative at a particular pointhttps://ask.sagemath.org/question/57986/implicit-derivative-at-a-particular-point/ For the function f(x,y) = x^3 + y^3 - 6*x*y, what will be input command in sage math for calculation of dy/dx at (1,2).RGGTue, 13 Jul 2021 07:34:53 +0200https://ask.sagemath.org/question/57986/I've got a big expression I need to dissect a certain wayhttps://ask.sagemath.org/question/57982/ive-got-a-big-expression-i-need-to-dissect-a-certain-way/ I've got a BIG polynomial (7 indeterminates, total degree 12), and I want to collect all the terms therein that contain only EVEN powers of all the indeterminates. Is there any reasonably simple way to do this? By "simple," I mean short of traversing the whole expression tree, testing each term to see if it contains only even powers, and collecting them one-by-one in a list (which, BTW, I also don't really know how to do)! If it makes any difference, I haven't been using the sage.rings.polynomial module, just generic Sage expressions.Tim02130Mon, 12 Jul 2021 22:11:18 +0200https://ask.sagemath.org/question/57982/