ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 27 Jul 2017 17:37:44 -0500how accelerate this simple programhttp://ask.sagemath.org/question/38420/how-accelerate-this-simple-program/Hello everybody. Here is my question
We seek integers of which the decimal part of their square root begin by 2017.
Sample: sqrt(10858) = 104.**2017**27....
Here is my program:
for n in range (1, 10^5):
if int( N(sqrt(n)).frac() * 10000 ) == 2017:
cpt += 1
the problem is it takes too much time.
For the bound 10^5 it takes about 55 sec on my iMac, for 10^6 it takes 620 sec, for 10^7 it takes almost 6000 sec ...
The question is to obtain the result for the bound 10^10 !wisherThu, 27 Jul 2017 17:37:44 -0500http://ask.sagemath.org/question/38420/collect variables buried in an expressionhttp://ask.sagemath.org/question/38417/collect-variables-buried-in-an-expression/Suppose we have
var('Pmean,alpha,M,Nb,D,H,c');
sol3= [M == 1/4*(2*D*Nb*Pmean - (D*H*alpha + D*H)*c)/((alpha + 1)*c)]
How would you collect the coefficients of D*H in the second term?
Specifically, once the collection is done, how could the factored version of the expression be returned?
I know from using other computer algebra systems that it can be taken all the way to this:
M==1/4*D*(-H+(2*Nb*Pmean)/((1+alpha)*c))Chris ChiassonThu, 27 Jul 2017 11:18:33 -0500http://ask.sagemath.org/question/38417/Check if a finitely generated matrix group is finite (works with QQ and not with CC)http://ask.sagemath.org/question/38403/check-if-a-finitely-generated-matrix-group-is-finite-works-with-qq-and-not-with-cc/Dear all, I am a newbie in sage. I would like to check if a finitely generated matrix group is finite. Before to proceed with the calculation on my actual problem (where matrices have complex entries), I have tried a very simple example. Consider the group generated by the matrices [1,0,0,1] and [0,1,1,0], this group is clearly finite. Can somebody explain me why the following code works:
sage: MS = MatrixSpace(QQ, 2, 2)
sage: G = MatrixGroup([MS([1,0,0,1]),MS([0,1,1,0])])
sage: G.is_finite()
True
but if I change the field QQ -> RR (or CC), an error is generated:
sage: MS = MatrixSpace(RR, 2, 2)
sage: G = MatrixGroup([MS([1,0,0,1]),MS([0,1,1,0])])
sage: G.is_finite()
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
<ipython-input-215-0022a668c150> in <module>()
----> 1 G.is_finite()
/Applications/SageMath-7.6.app/Contents/Resources/sage/src/sage/groups/group.pyx in sage.groups.group.Group.is_finite (/Applications/SageMath-7.6.app/Contents/Resources/sage/src/build/cythonized/sage/groups/group.c:2696)()
179 NotImplementedError
180 """
--> 181 return self.order() != infinity
182
183 def is_multiplicative(self):
/Applications/SageMath-7.6.app/Contents/Resources/sage/src/sage/groups/group.pyx in sage.groups.group.Group.order (/Applications/SageMath-7.6.app/Contents/Resources/sage/src/build/cythonized/sage/groups/group.c:2623)()
164 NotImplementedError
165 """
--> 166 raise NotImplementedError
167
168 def is_finite(self):
NotImplementedError:
Is there any way to force the second piece of code to work with matrices with entries in CC?
Thank you in advance.frenkyoTue, 25 Jul 2017 10:22:22 -0500http://ask.sagemath.org/question/38403/How can I list all the elements of the affine Coxeter group of type A having a specific lengthhttp://ask.sagemath.org/question/38409/how-can-i-list-all-the-elements-of-the-affine-coxeter-group-of-type-a-having-a-specific-length/If I try to list the whole group \tilde{A} I get a list but since the group is infinite, the program doesn't stop. What if I want to get a list of all elements of a prescribed order?
EliWed, 26 Jul 2017 03:26:30 -0500http://ask.sagemath.org/question/38409/how find quickly the order of a long prime ?http://ask.sagemath.org/question/38376/how-find-quickly-the-order-of-a-long-prime/Is it a quicker way for finding the order of a long prime without the inner loop for?
I know that a prime number p is long iif is order is order is p-1
for n in range(6, 50):
if is_prime(n):
for i in range(1, n):
m = 10^i % n
if m==1:
print n, "ordre=", i
#if i == n-1: print "-> premier long",
#print
breakwisherMon, 24 Jul 2017 08:58:19 -0500http://ask.sagemath.org/question/38376/Polynomials over number fieldshttp://ask.sagemath.org/question/38381/polynomials-over-number-fields/Below I define a polynomial ring K[s,t]. My goal is to compute the minors of a large matrix with entries in this ring.
var('x')
# K.<t> = NumberField(x^2-2)
K.<s,t> = NumberField([x^2-2,x^2-5])
R.<p0,p1,p2,p3,p4,p5> = K[]
M = Mat(R,10,10).random_element()
mins = M.minors(2)
This code works fine, but if I replace the last line with
mins = M.minors(7)
it fails with the error message
TypeError: no conversion to a Singular ring defined
Is it possible to avoid this error?coreyharrisMon, 24 Jul 2017 11:09:25 -0500http://ask.sagemath.org/question/38381/Suppress automatically generated Python files when running Sage scripthttp://ask.sagemath.org/question/38383/suppress-automatically-generated-python-files-when-running-sage-script/ Hello,
I'm curious if it is possible to stop Sage from automatically generating corresponding Python files. For instance, if I run a sage script `test.sage`, then after running `sage test.sage`, I'll get an automatically generated file called `test.sage.py`. Is there any way to suppress the generation of this file? I tried to take a look in the documentation, but I couldn't find anything.
Thanks again! Vincent RussoMon, 24 Jul 2017 13:44:17 -0500http://ask.sagemath.org/question/38383/Why are precompiled versions faster than those built from source code?http://ask.sagemath.org/question/38380/why-are-precompiled-versions-faster-than-those-built-from-source-code/Maybe I am missing an environment variable or make target but my builds
are always slower.
For example
%time _ = bernoulli(3*10^5)
finishes in about 2 min. 30 sec. using a precompiled
version but 31 min. 41 sec. built from source (7.6) and 47 min. from source (8.0) and
time a = N(pi, digits=5000000)
finishes in 13 min. 42 sec. from source (7.6) and 20 min. 21 sec. from source (8.0)
I use SAGE64=yes and SAGE_INSTALL_GCC=no
Is it PARI/GP tuning or MPIR vs. GMP or some other thread related problem?Petra NickasMon, 24 Jul 2017 11:07:48 -0500http://ask.sagemath.org/question/38380/NameError: name 'var' is not definedhttp://ask.sagemath.org/question/38384/nameerror-name-var-is-not-defined/I'm using Jupyter Notebook on CoCalc.
I can't create symbolic variables.
var('a,b,c')
results in NameError: name 'var' is not defined.
I tried
from sage.calculus.var import *
but it still doesn't work and gives the same error.RoadMon, 24 Jul 2017 13:49:10 -0500http://ask.sagemath.org/question/38384/How do I print a graph after I find all_graph_colorings?http://ask.sagemath.org/question/38362/how-do-i-print-a-graph-after-i-find-all_graph_colorings/Code is as follows:
from sage.graphs.graph_coloring import chromatic_number
from sage.graphs.independent_sets import IndependentSets
from sage.graphs.graph_coloring import number_of_n_colorings
from sage.graphs.graph_coloring import first_coloring
from sage.graphs.graph_coloring import all_graph_colorings
g=Graph([[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 13], [1, 14], [1, 22], [1, 23], [1, 25], [1, 27], [1, 30], [1, 32], [2, 3], [2, 4], [2, 5], [2, 6], [2, 17], [2, 18], [2, 21], [2, 24], [2, 26], [2, 28], [2, 29], [2, 31], [3, 4], [3, 9], [3, 10], [3, 17], [3, 18], [3, 22], [3, 23], [3, 25], [3, 27], [3, 30], [3, 32], [4, 9], [4, 10], [4, 13], [4, 14], [4, 21], [4, 24], [4, 26], [4, 28], [4, 29], [4, 31], [5, 9], [5, 14], [5, 17], [5, 21], [5, 23], [6, 10], [6, 13], [6, 18], [6, 22], [6, 24], [9, 13], [9, 18], [9, 21], [9, 23], [10, 14], [10, 17], [10, 22], [10, 24], [13, 17], [13, 21], [13, 22], [14, 18], [14, 23], [14, 24], [17, 21], [17, 22], [18, 23], [18, 24], [25, 28], [25, 29], [26, 27], [26, 30], [27, 31], [28, 32], [29, 32], [30, 31]])
all=all_graph_colorings(g,4)
show(all)
This prints:
<generator object all_graph_colorings at 0x7f1bd8e9c370>chrisalex0207Sat, 22 Jul 2017 12:12:19 -0500http://ask.sagemath.org/question/38362/Group action in sagehttp://ask.sagemath.org/question/38363/group-action-in-sage/I want to define a group action in sage. The group is a direct product of two general linear groups. The set under action is of matrices and the action is $(A,B) (M)=A^{-1}MB$. Assume all matrices have compatible sizes in order for multiplication.
I might need a stabelizer later so I was thinking doing it in GAP but could not figure out how. Any suggestions?upendra.kapshikarSat, 22 Jul 2017 13:33:12 -0500http://ask.sagemath.org/question/38363/Piecewise Symbolic Function with Conditional Statementhttp://ask.sagemath.org/question/38347/piecewise-symbolic-function-with-conditional-statement/I wish to incorporate a conditional Python expression (`if ... else ...`) in a symbolic function.
Suppose I have a piecewise function *k(n)* defined for *n* = 1,2,3... as in the following pseudocode:
k(n) =
2 if n = 1
n otherwise
I compose this with another function *g(x)* and wish to integrate the result. For example,
f(x)=g(x)/k(n)
f(n=...).integrate(x, 0, 1)
How can implement a non-evaluating conditional in a symbolic Sage function?terrygarciaFri, 21 Jul 2017 11:23:17 -0500http://ask.sagemath.org/question/38347/How to trace Maxima failureshttp://ask.sagemath.org/question/38266/how-to-trace-maxima-failures/I often hit the "Detected access to protected memory ..." failure from maxima. In some cases it seems to go into a loop whereupon I receive the same message hundreds of times. I know which sage worksheet cell is failing, but cannot find what it is about that cell which causes the failure, because maxima does not tell me.
Is it possible to set up the worksheet so that this error is trapped and triggers a stack trace in sage/python?
sage: version()
'SageMath version 7.6, Release Date: 2017-03-25'
sage: Parallelism().set(nproc=2)
sage: var('rho12,rho13,rho23', domain='real')
sage: assume(rho12>0, rho13>0, rho23>0)
sage: var('r12,r13,r23', domain='real')
sage: var('m1 m2 m3', domain='real')
sage: var('mu12,mu13,mu23', domain='real')
sage: ####
sage: #assume(m1>0, m2>0, m3>0) # !! This is a Maxima killer (even though physically required)!
sage: m1=1; m2=1; m3=1
sage: # !! With 'assume' above and with ANY m1,m2,m3 in SR, we seg-fault and core-dump when computing the connection.
sage: ####
sage: mu12 = (m1*m2)/(m1+m2); mu23 = (m2*m3)/(m2+m3); mu13 = (m1*m3)/(m1+m3)
sage: # Contravariant metric tensor, per Turbiner et al., arXiv:1611.08157.
sage: Ginv = matrix([[2/mu12*rho12, 1/m1*(rho12+rho13-rho23), 1/m2*(rho12+rho23-rho13)],\
... [1/m1*(rho12+rho13-rho23), 2/mu13*rho13, 1/m3*(rho13+rho23-rho12)],\
... [1/m2*(rho12+rho23-rho13), 1/m3*(rho13+rho23-rho12), 2/mu23*rho23]])
sage: G = Ginv.inverse();
sage: # Begin manifold creation
sage: M = Manifold(1*3,'R^3',field='real',start_index=1)
sage: U = M.open_subset('U')
sage: Rho.<rho12,rho13,rho23> = U.chart();
sage: Rho.add_restrictions([rho12>0, rho13>0, rho23>0])
sage: Rho.add_restrictions([sqrt(rho23)<sqrt(rho12)+sqrt(rho13),\
... sqrt(rho13)<sqrt(rho12)+sqrt(rho23), sqrt(rho12)<sqrt(rho13)+sqrt(rho23)])
...
sage: g = M.riemannian_metric('g');
sage: g[:] = G[:].simplify_full()
sage: ginv = g.inverse()
sage: ### This will seg-fault and core-dump if ANY m1,m2,m3 are in SR, and the 'assume' statement active.
sage: nabla = g.connection()
sage: # Turbiner calculates the Ricci scalar.
sage: ### Attempting to do so here causes seg fault if all m1,m2,m3=1!
sage: # (Is this because of singularities at all boundaries of rho-space?
sage: # (Regardless, code should *never* crash.)
sage: Ric_g = g.ricci_scalar()Richard_LFri, 14 Jul 2017 14:37:51 -0500http://ask.sagemath.org/question/38266/How to specify existing software when building from source?http://ask.sagemath.org/question/38349/how-to-specify-existing-software-when-building-from-source/I'm building sage-7.6 on a CentOS6 machine as per the instructions found on the docs pages, about compiling from source, and it succeeds, but the resulting distribution is 8G in size which is a little unwieldy for deploying to multiple machines.
I notice that it's compiling its own versions of a bunch of things we already have installed, though maybe not at quite exactly the same version number.
Is there a way to use the already installed versions of gcc, python, etc, rather than have sage build its own versions?elbieFri, 21 Jul 2017 14:26:08 -0500http://ask.sagemath.org/question/38349/Sagemath & Cocal what is the actual status?http://ask.sagemath.org/question/38357/sagemath-cocal-what-is-the-actual-status/Is Sagemath beeing developed?thethaSat, 22 Jul 2017 05:47:02 -0500http://ask.sagemath.org/question/38357/3d plot in vector format: still using matplotlib?http://ask.sagemath.org/question/38350/3d-plot-in-vector-format-still-using-matplotlib/In 2012, the best way to create a vector image in Sage from a three-dimensional plot was to call matplotlib, as the [answers to Question 9057 show](https://ask.sagemath.org/question/9057/save-3d-plot-as-vector-format/)
Is this still the case? Or are there other work-arounds now?UrsulaFri, 21 Jul 2017 15:34:13 -0500http://ask.sagemath.org/question/38350/Way to solve max_split enumerationhttp://ask.sagemath.org/question/38283/way-to-solve-max_split-enumeration/Hello everyone,
I try to solve a problem on graphs. The graphs contain two types of nodes, a first type linked together containing max_cliques that I seek to determine. A second one connected only to the first.
For the moment I enumerate the biggest cliques of the first type, then determines for each the number of nodes of the second type related to this one. Finally I list the one with the largest number of nodes of the second type.
So I'm looking to find the biggest split graph.
Do you have an idea to improve my current way?AlexJSun, 16 Jul 2017 05:32:13 -0500http://ask.sagemath.org/question/38283/unable to coerce <type 'sage.rings.real_mpfi.RealIntervalFieldElement'> to an integerhttp://ask.sagemath.org/question/38338/unable-to-coerce-type-sageringsreal_mpfirealintervalfieldelement-to-an-integer/ I am very desperate. I just want to convert a real number to an integer. I have tried int(x), Integer(x), floor(x), ceil(x) but nothing seems to work.davidThu, 20 Jul 2017 16:11:57 -0500http://ask.sagemath.org/question/38338/What is the most efficient way to "look up" a face in the face lattice of a polyhedron?http://ask.sagemath.org/question/34485/what-is-the-most-efficient-way-to-look-up-a-face-in-the-face-lattice-of-a-polyhedron/Say I have a polyhedron `p` with face lattice `L = p.face_lattice()`. I want to define `x` as the element of `L` defined as the convex hull of vertices `<0 1 3>` of `p`. What is the most efficient way to define `x`?
For example, consider
sage: p = polytopes.simplex(3)
sage: for v in p.vertices():
print '\tIndex {}:'.format(v.index()), v
....:
Index 0: A vertex at (0, 0, 0, 1)
Index 1: A vertex at (0, 0, 1, 0)
Index 2: A vertex at (0, 1, 0, 0)
Index 3: A vertex at (1, 0, 0, 0)
We see that `p` has four vertices.
The vertices indexed by `0`, `1`, and `3` are the vertices of a face of `p`. This is confirmed:
sage: L = p.face_lattice()
sage: list(L)
[<>,
<0>,
<1>,
<2>,
<3>,
<0,1>,
<0,2>,
<1,2>,
<0,3>,
<1,3>,
<2,3>,
<0,1,2>,
<0,1,3>,
<0,2,3>,
<1,2,3>,
<0,1,2,3>]
I want to define `x` as the face in `p.face_lattice()` given by these vertices. Of course, I could do this by hand with `x = list(L)[12]`, but I want a way to automate this.done_with_fishTue, 16 Aug 2016 04:06:34 -0500http://ask.sagemath.org/question/34485/Computing the ideal of relationshttp://ask.sagemath.org/question/27263/computing-the-ideal-of-relations/Given two projective spaces $\mathbb P^n$ and $\mathbb P^m$ together with $m+1$ global sections of the invertible sheaf $\mathcal O_{\mathbb P^n}(d)$ (e.g. $m+1$ homogeneous polynomials of degree $d$ in the variables $x_0,\cdots,x_n$, say $f_0,\cdots,f_m$), we know that there exists a unique morphism $[f_0,\cdots,f_m] : \mathbb P^n \to \mathbb P^m$. Assume the projective spaces are considered over a noetherian ring ; the morphisms to the base are both projective, hence proper, which means $[f_0,\cdots,f_m]$ is a proper morphism, hence has closed image.
Question : Does there exist an algorithm already implemented in Sage to find the homogeneous ideal of relations of the image of the map $[f_0,\cdots,f_m]$? I've been messing around for a few days now and it seems to only involve linear algebra, so in the case where the base is the spectrum of a field there should be an algorithm, I just don't know how efficient it is or if it's implemented at all. I would not mind if the algorithm was slow, I just want it to work in small cases (i.e. small degree and small number of polynomials)!Patrick D. SilvaMon, 06 Jul 2015 02:25:49 -0500http://ask.sagemath.org/question/27263/How can I substitute "target" functions inside expressions?http://ask.sagemath.org/question/38326/how-can-i-substitute-target-functions-inside-expressions/Hi all,
I'm a Sage newbie striving to manipulate complex-valued expressions. In particular, I need to convert expressions like abs(x)^2 into x*conj(x) and back, within expressions including multiple instances of these patterns. In other words, x is here just a placeholder for what may be a list of different variables or expressions, but I do not want to substitute each of these separately or manually.
Here is some experimenting that I have been doing on the matter with generic functions, as well as standard functions (sin):
# Some initialization
reset()
forget()
f = function('foo')(x)
g = function('goo')(x)
h = function('hoo')(x)
h(x) = f(x)^2
# Types and basic substitutions
print(type(foo))
print(type(goo))
print(type(hoo))
print(type(f))
print(type(g))
print(type(h))
print(h(x))
print(h.substitute_function(f,g))
print(h.substitute_function(foo,goo))
# Substitution of a function
h(x) = sin(x)^2
print(type(h))
print(type(sin))
print(h.substitute_function(sin,goo))
If I try, however, to substitute abs with some other function, I do not get what I want:
# Substitution of a built-in function (not working)
h(x) = abs(x)^2
print(type(h))
print(type(abs))
print(h.substitute_function(abs,goo))
Here is a workaround that I came up with, but I hope someone can let me know a more elegant/standard technique:
# Substitute abs(x) with sqrt(x*conj(x)): a workaround
moo = sage.functions.other.Function_abs()
m(x) = abs(x)
c(x) = (x*x.conjugate()).sqrt()
print(type(moo))
print(type(m))
print(type(c))
s(x) = h.substitute_function(moo,c)
print(s(x))
Also, I found a lot of headaches with the opposite conversion, and following is my attempt at solving the problem:
# Substitute sqrt(x*conj(x)) with abs(x): a workaround
doo(x) = goo(x)/x
qoo(x) = abs(x)^2
b_temp(x) = s.substitute_function(conjugate,goo)
print(b_temp(x))
b_temp(x) = b_temp.substitute_function(goo,doo)
print(b_temp(x))
b(x) = b_temp.substitute_function(goo,qoo)
print(b(x))
Honestly, it seems strange to me that one cannot easily recast an expression in order to make certain target functions to appear.
Thank you in advance for your support!AskerWed, 19 Jul 2017 09:12:58 -0500http://ask.sagemath.org/question/38326/iterating over quotient ring and polynomial ringhttp://ask.sagemath.org/question/38324/iterating-over-quotient-ring-and-polynomial-ring/Hello
I have been studied some finite algebraic structure as follows:
P.<v> = PolynomialRing(GF(2))
R.<v> = P.quotient((v^2-v))
T.<x> = PolynomialRing(R)
R is a quotient ring with elements : 0,1,v,1+v.
I want to list all of the polynomials with degree 2. So I write:
for r in T.polynomials(of_degree=2): r
but the error is "object does not support iteration".
And also the same problem arises when I want to list the elements of R.
Is there any solution to this problem?
How can I iterate over this structure?
thank youtugbaWed, 19 Jul 2017 06:12:25 -0500http://ask.sagemath.org/question/38324/Submatrix of a given matrix by deleting some rows and columns(For my case 2 rows and columns).http://ask.sagemath.org/question/38292/submatrix-of-a-given-matrix-by-deleting-some-rows-and-columnsfor-my-case-2-rows-and-columns/I have a matrix A of order $n\times n$. Now I need another matrix B whose (i,j)th entry is
$det A(i,j)$, where $det A(i,j)$ denote the determinant of the sub matrix of A formed by deleting $i^{th}$ and $j^{th}$ rows and columns. I'm unable to generate the submatrices $A(i,j)$ for every element at a time.Deepak SarmaMon, 17 Jul 2017 23:58:26 -0500http://ask.sagemath.org/question/38292/Polyhedron.volume() ZeroDivisionErrorhttp://ask.sagemath.org/question/37936/polyhedronvolume-zerodivisionerror/Let us consider the following function
def vol(c):
S = [g * c for g in G]
return Polyhedron(S).volume()
vol(vector([1.1,0.1,1]))
Here, G is the list of rotation matrices in SO(3) corresponding to the octahedral symmetry group. However when I try to run this code it gives a ZeroDivisionError. Can I do anything to fix it? It seems to work for all integer vectors but fails on most random RDF vectors.
Code to generate G:
G = [
matrix( ((0, 0, -1), (-1, 0, 0), (0, 1, 0)) ),
matrix( ((-1, 0, 0), (0, 0, 1), (0, 1, 0)) ),
matrix( ((0, 1, 0), (0, 0, -1), (-1, 0, 0)) ),
matrix( ((-1, 0, 0), (0, 0, -1), (0, -1, 0)) ),
matrix( ((0, 0, 1), (1, 0, 0), (0, 1, 0)) ),
matrix( ((1, 0, 0), (0, -1, 0), (0, 0, -1)) ),
matrix( ((0, 0, 1), (-1, 0, 0), (0, -1, 0)) ),
matrix( ((1, 0, 0), (0, 1, 0), (0, 0, 1)) ),
matrix( ((0, 1, 0), (0, 0, 1), (1, 0, 0)) ),
matrix( ((0, -1, 0), (0, 0, -1), (1, 0, 0)) ),
matrix( ((0, -1, 0), (0, 0, 1), (-1, 0, 0)) ),
matrix( ((0, 0, -1), (0, -1, 0), (-1, 0, 0)) ),
matrix( ((0, 1, 0), (1, 0, 0), (0, 0, -1)) ),
matrix( ((0, -1, 0), (-1, 0, 0), (0, 0, -1)) ),
matrix( ((0, 0, -1), (1, 0, 0), (0, -1, 0)) ),
matrix( ((-1, 0, 0), (0, -1, 0), (0, 0, 1)) ),
matrix( ((1, 0, 0), (0, 0, -1), (0, 1, 0)) ),
matrix( ((0, 0, 1), (0, 1, 0), (-1, 0, 0)) ),
matrix( ((0, 1, 0), (-1, 0, 0), (0, 0, 1)) ),
matrix( ((-1, 0, 0), (0, 1, 0), (0, 0, -1)) ),
matrix( ((0, -1, 0), (1, 0, 0), (0, 0, 1)) ),
matrix( ((1, 0, 0), (0, 0, 1), (0, -1, 0)) ),
matrix( ((0, 0, 1), (0, -1, 0), (1, 0, 0)) ),
matrix( ((0, 0, -1), (0, 1, 0), (1, 0, 0)) )
]AkababaTue, 13 Jun 2017 16:36:38 -0500http://ask.sagemath.org/question/37936/ImportError: No module namedhttp://ask.sagemath.org/question/38318/importerror-no-module-named/I just did a fresh install of fedora 26 (4.11.8-300.fc26.x86_64) and installed a jupyter notebook using pip3 and then installed the sage from the repositories. Upon calling sage I get the following error. Any ideas why this happens and how to resolve this?
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 7.6, Release Date: 2017-03-25 │
│ Type "notebook()" for the browser-based notebook interface. │
│ Type "help()" for help. │
└────────────────────────────────────────────────────────────────────┘
Traceback (most recent call last):
File "/usr/lib64/sagemath/local/bin/sage-ipython", line 7, in <module>
from sage.repl.interpreter import SageTerminalApp
File "/usr/lib64/python2.7/site-packages/sage/repl/interpreter.py", line 108, in <module>
from sage.repl.prompts import SagePrompts, InterfacePrompts
File "/usr/lib64/python2.7/site-packages/sage/repl/prompts.py", line 16, in <module>
from IPython.terminal.prompts import Prompts
File "/usr/lib64/sagemath/site-packages/IPython/__init__.py", line 48, in <module>
from .core.application import Application
File "/usr/lib64/sagemath/site-packages/IPython/core/application.py", line 23, in <module>
from traitlets.config.application import Application, catch_config_error
ImportError: No module named traitlets.config.application
k1monfaredTue, 18 Jul 2017 23:23:56 -0500http://ask.sagemath.org/question/38318/complex normhttp://ask.sagemath.org/question/38289/complex-norm/As a newbie, I must be missing something, but here is the question:
With this setup:
var('a', domain=CC)
a.norm()
a.norm().simplify()
The last line displays as a^2, but should be |a|^2 .
What am I missing?normvcrMon, 17 Jul 2017 15:33:41 -0500http://ask.sagemath.org/question/38289/Upgrade to latest versions of all packageshttp://ask.sagemath.org/question/38290/upgrade-to-latest-versions-of-all-packages/[Version 7.6, installed from source]
Is there a way to verify that all the latest versions of installed packages are the most recent stable versions?
What method is recommended to upgrade all installed packages?
rickhg12hsMon, 17 Jul 2017 17:03:08 -0500http://ask.sagemath.org/question/38290/How to check whether a permutation is linear?http://ask.sagemath.org/question/38299/how-to-check-whether-a-permutation-is-linear/Suppose that there is a permutation from (1, 2, 3, 4, 5, 6) to (2, 3, 5, 4, 6, 1), how could I check whether it is linear or not?
----------
Now I have many permutations from 256 integers to 256 integers, how could i check?
----------
For example, this is a permutation, from (0, 1, ..., 256) to
(0, 29, 142, 147, 199, 218, 73, 84, 227, 254, 109, 112, 36, 57, 170, 183, 113, 108, 255, 226, 182, 171, 56, 37, 146, 143, 28, 1, 85, 72, 219, 198, 184, 165, 54, 43, 127, 98, 241, 236, 91, 70, 213, 200, 156, 129, 18, 15, 201, 212, 71, 90, 14, 19, 128, 157, 42, 55, 164, 185, 237, 240, 99, 126, 220, 193, 82, 79, 27, 6, 149, 136, 63, 34, 177, 172, 248, 229, 118, 107, 173, 176, 35, 62, 106, 119, 228, 249, 78, 83, 192, 221, 137, 148, 7, 26, 100, 121, 234, 247, 163, 190, 45, 48, 135, 154, 9, 20, 64, 93, 206, 211, 21, 8, 155, 134, 210, 207, 92, 65, 246, 235, 120, 101, 49, 44, 191, 162, 238, 243, 96, 125, 41, 52, 167, 186, 13, 16, 131, 158, 202, 215, 68, 89, 159, 130, 17, 12, 88, 69, 214, 203, 124, 97, 242, 239, 187, 166, 53, 40, 86, 75, 216, 197, 145, 140, 31, 2, 181, 168, 59, 38, 114, 111, 252, 225, 39, 58, 169, 180, 224, 253, 110, 115, 196, 217, 74, 87, 3, 30, 141, 144, 50, 47, 188, 161, 245, 232, 123, 102, 209, 204, 95, 66, 22, 11, 152, 133, 67, 94, 205, 208, 132, 153, 10, 23, 160, 189, 46, 51, 103, 122, 233, 244, 138, 151, 4, 25, 77, 80, 195, 222, 105, 116, 231, 250, 174, 179, 32, 61, 251, 230, 117, 104, 60, 33, 178, 175, 24, 5, 150, 139, 223, 194, 81, 76)omggggggTue, 18 Jul 2017 02:51:32 -0500http://ask.sagemath.org/question/38299/ContinuedFractions fail on large integers?http://ask.sagemath.org/question/38309/continuedfractions-fail-on-large-integers/ I've been doing some work with continued fractions, and when I get to a large enough number, I start hitting an error. For example, with the ContinuedFraction from [(18806263158919164762262694978536817267490601162205305175017345804331141023863425152608922362862834892943764814900901973487239748665085369033027389281788183,), [1, 1, 1, 1, 37612526317838329524525389957073634534981202324410610350034691608662282047726850305217844725725669785887529629801803946974479497330170738066054778563576366]]), I get the error below.
Specifically, I get it after I've created a ContinuedFraction with the arguments above, and then call .value() on it. I've tried to make sure all of those are sage Integer types, but it doesn't seem to help, and it looks like internally the CF code is overflowing somewhere. Is there any way around this, or is this a limitation I'll have to live with?
Thanks for any help!
Traceback (most recent call last):
File "/home/tc/Downloads/sagetemp/SageMath/local/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/home/tc/Downloads/sagetemp/SageMath/local/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "/home/tc/code/cfp/pi/piX/ones.py", line 16, in leeloo
v = ocf.value()
File "/home/tc/Downloads/sagetemp/SageMath/local/lib/python2.7/site-packages/sage/rings/continued_fraction.py", line 1423, in value
Q = QuadraticField(DD, 'sqrt%d' % DD)
File "/home/tc/Downloads/sagetemp/SageMath/local/lib/python2.7/site-packages/sage/rings/number_field/number_field.py", line 922, in QuadraticField
return NumberField(f, name, check=False, embedding=embedding, latex_name=latex_name, **args)
File "/home/tc/Downloads/sagetemp/SageMath/local/lib/python2.7/site-packages/sage/rings/number_field/number_field.py", line 524, in NumberField
return NumberField_version2(polynomial=polynomial, name=name, check=check, embedding=embedding, latex_name=latex_name, assume_disc_small=assume_disc_small, maximize_at_primes=maximize_at_primes, structure=structure)
File "sage/structure/factory.pyx", line 362, in sage.structure.factory.UniqueFactory.__call__ (/home/tc/Downloads/sagetemp/SageMath/src/build/cythonized/sage/structure/factory.c:1856)
File "/home/tc/Downloads/sagetemp/SageMath/local/lib/python2.7/site-packages/sage/rings/number_field/number_field.py", line 612, in create_key_and_extra_args
x = number_field_morphisms.root_from_approx(polynomial, embedding)
File "sage/rings/number_field/number_field_morphisms.pyx", line 490, in sage.rings.number_field.number_field_morphisms.root_from_approx (/home/tc/Downloads/sagetemp/SageMath/src/build/cythonized/sage/rings/number_field/number_field_morphisms.c:7640)
File "sage/rings/real_lazy.pyx", line 1584, in sage.rings.real_lazy.LazyAlgebraic.__init__ (/home/tc/Downloads/sagetemp/SageMath/src/build/cythonized/sage/rings/real_lazy.c:17914)
File "sage/rings/polynomial/polynomial_element.pyx", line 7247, in sage.rings.polynomial.polynomial_element.Polynomial.roots (/home/tc/Downloads/sagetemp/SageMath/src/build/cythonized/sage/rings/polynomial/polynomial_element.c:68115)
File "sage/rings/polynomial/polynomial_element.pyx", line 7143, in sage.rings.polynomial.polynomial_element.Polynomial.roots (/home/tc/Downloads/sagetemp/SageMath/src/build/cythonized/sage/rings/polynomial/polynomial_element.c:64632)
File "sage/rings/polynomial/polynomial_element.pyx", line 5786, in sage.rings.polynomial.polynomial_element.Polynomial._pari_ (/home/tc/Downloads/sagetemp/SageMath/src/build/cythonized/sage/rings/polynomial/polynomial_element.c:55229)
File "sage/rings/polynomial/polynomial_element.pyx", line 5839, in sage.rings.polynomial.polynomial_element.Polynomial._pari_with_name (/home/tc/Downloads/sagetemp/SageMath/src/build/cythonized/sage/rings/polynomial/polynomial_element.c:55757)
File "sage/rings/real_mpfr.pyx", line 3103, in sage.rings.real_mpfr.RealNumber._pari_ (/home/tc/Downloads/sagetemp/SageMath/src/build/cythonized/sage/rings/real_mpfr.c:22771)
ValueError: Cannot convert NaN or infinity to Pari floatcappalloTue, 18 Jul 2017 09:31:37 -0500http://ask.sagemath.org/question/38309/How to obtain the resistance distance matrix of a graph?http://ask.sagemath.org/question/38291/how-to-obtain-the-resistance-distance-matrix-of-a-graph/I tried to compute resistance distance matrix of a graph g by first evaluating the Moore-Penrose inverse of the Laplacian matrix, but the result is not accurate, the entries are slightly different. I tried with the following algorithm.
L=g.laplacian_matrix()
from scipy import linalg
M=matrix(linalg.pinv(L))
R=matrix(QQ, g.order())
for i in range(g.order()):
for j in range(g.order()):
if i!=j:
R[i,j]=M[i,i]+M[j,j] -M[i,j]-M[j,i]Deepak SarmaMon, 17 Jul 2017 23:32:29 -0500http://ask.sagemath.org/question/38291/