[sage-support] Re: How to move Sage to a different computer?

2021-11-14 Thread Simon King
Hi Dima,

just for the record: Both the master and the develop version are now
built and they work.

Thank you! Best regards,
Simon

On 2021-11-14, Dima Pasechnik  wrote:
> Hi Simon,
>
> On Sun, Nov 14, 2021 at 1:26 AM Simon King  wrote:
>>
>> Hi Dima,
>>
>> On 2021-11-14, Dima Pasechnik  wrote:
>> > hmm, if you really checked out the latest version and have done
>> > `make distclean`, then it should have worked (it does work, you know).
>> >
>> > Do you mean to say that you merged in (or rebased over) the latest
>> > develop branch, and getting errors trying to build?
>>
>> I did git checkout develop and git pull. Then, git status shows a lot of
>> "Unversionierte Dateien", in build/..., but also many things in src/
>> No idea if that is because of permissions being corrupted when using
>> "cp -r". "git reset --hard" is no remedy.
>
> You need to clean old stuff, I suppose
>
> git clean -fdx
>
> should do it.
>
> HTH
> Dima
>>
>> Anyway, git log tells me the commit is
>> 6ec717a56dcb0fd629ca850d9b9391ea8d96ccac,
>> Updated SageMath version to 9.5.beta6
>>
>> Now, make distclean complains that the Sage source tree is unconfigured,
>> and I shall type "./configure". So, I did. Famous last words:
>>
>> configure: error: The content of
>> "/home/king/Sage/git/py3/build/pkgs/beautifulsoup/type" must be
>> 'base', 'standard', 'optional', or 'experimental'
>>
>> autoreconf, to rebuild the configure script, didn't help either.
>>
>> Best regards,
>> Simon
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "sage-support" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to sage-support+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/sage-support/smpojh%24h4k%241%40ciao.gmane.io.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/smr2ov%2447e%241%40ciao.gmane.io.


[sage-support] Re: How to move Sage to a different computer?

2021-11-14 Thread Simon King
Dear Dima,

On 2021-11-14, Dima Pasechnik  wrote:
> You need to clean old stuff, I suppose
>
> git clean -fdx
>
> should do it.

Thank you! It seems that it did the trick.

In the development version, "make" now says to do "./configure" first
(which in the past was done automatically, but I guess ./configure is
the normal thing to do before "make" in most software), which
recommended to install further stuff (which I did), and now "make" is
running!

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/smqhgq%24dun%241%40ciao.gmane.io.


[sage-support] Re: How to move Sage to a different computer?

2021-11-14 Thread Simon King
PS:

On 2021-11-14, Simon King  wrote:
> On 2021-11-14, Dima Pasechnik  wrote:
>> hmm, if you really checked out the latest version and have done
>> `make distclean`, then it should have worked (it does work, you know).

In other words: With the latest develop version, even "make distclean"
didn't work. And with the latest master version, "make distclean" did
eventually work, but "make" didn't.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/smqfm0%24ncf%241%40ciao.gmane.io.


[sage-support] Re: How to move Sage to a different computer?

2021-11-13 Thread Simon King
Hi Dima,

On 2021-11-14, Dima Pasechnik  wrote:
> hmm, if you really checked out the latest version and have done
> `make distclean`, then it should have worked (it does work, you know).
>
> Do you mean to say that you merged in (or rebased over) the latest
> develop branch, and getting errors trying to build?

I did git checkout develop and git pull. Then, git status shows a lot of
"Unversionierte Dateien", in build/..., but also many things in src/
No idea if that is because of permissions being corrupted when using
"cp -r". "git reset --hard" is no remedy.

Anyway, git log tells me the commit is
6ec717a56dcb0fd629ca850d9b9391ea8d96ccac,
Updated SageMath version to 9.5.beta6

Now, make distclean complains that the Sage source tree is unconfigured,
and I shall type "./configure". So, I did. Famous last words:

configure: error: The content of 
"/home/king/Sage/git/py3/build/pkgs/beautifulsoup/type" must be
'base', 'standard', 'optional', or 'experimental'

autoreconf, to rebuild the configure script, didn't help either.

Best regards,
Simon


-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/smpojh%24h4k%241%40ciao.gmane.io.


[sage-support] Re: How to move Sage to a different computer?

2021-11-13 Thread Simon King
PS:

When I go to the master branch instead of develop branch, I do not have
the problem with the spkg type "pip" --- but "make" soon fails, because
when the "patch" spkg is built, configure claims that the C compiler
cannot create executables - which is wrong: I tested, and I can create
an executable from some "Hello World" program.

Again: How to debug? The only "failed program" mentioned in config.log
is with "#include " -- so, it is supposed to fail.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/smpjsf%2414st%241%40ciao.gmane.io.


[sage-support] How to move Sage to a different computer?

2021-11-13 Thread Simon King
Hi!

I have some Sage installation on one laptop, including many branches.
Now I want to move on a different laptop, keeping these branches.

I tried to do something like "cp -r", then checking out the latest
development version. I think it worked so far. But, when trying "make
distclean" or "make", I get a lot of AssertionErrors: Apparently
sage_bootstrap/package.py expects the package types 'base',
'standard', 'optional' or 'experimental', but nowadays many packages
have the type 'pip'.

How to find out what went wrong? And: What would be the recommended way
to get a working Sage installation on the new laptop that can use my old
branches?

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/smpf07%24588%241%40ciao.gmane.io.


[sage-support] Re: differentiation in InfinitePolynomialRing

2021-09-09 Thread Simon King
Hi Nils,

can you open a ticket for it?

Best regards,
Simon

On 2021-09-08, Nils Bruin  wrote:
> On Wednesday, 8 September 2021 at 09:24:15 UTC-7 max...@gmail.com wrote:
>
>> Hi Simon,
>>
>> Thank you for your insight, and let me state that I 
>> find InfinitePolynomialRing useful in combinatorics to deal with 
>> (truncated) multivariate generating functions with apriori unknown number 
>> of variables, and so basic operations (such as differentiation) on 
>> polynomials would be very welcome here. Btw, is there 
>> InfinitePowerSeriesRing or alike available by any chance?
>>
>> From what you said, I think it should be easy to fix (making it work) at 
>> least ISSUE#2 -- one just needs to extend the underlying finite 
>> PolynomialRing with the differentiating variable(s) before delegating the 
>> actual differentiation to it.
>>
>  
> I don't think any extending is required: if the differentiation variables 
> do no lie in the parent of the representing finite polynomial ring for the 
> actual element then the answer is 0.
>
> def derivative(self, *args):
> R=self._p.parent()
> try:
> L=[R(c) for c in args]  
> except TypeError:  #perhaps test a little more here
> return 
> self.parent().zero()
> return R(self._p.derivative(*L))
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/shc8q8%245f3%241%40ciao.gmane.io.


[sage-support] Re: differentiation in InfinitePolynomialRing

2021-09-08 Thread Simon King
Hi Max,

On 2021-09-08, Max Alekseyev  wrote:
> I've found a couple of issues with differentiation in InfinitePolynomialRing
>
> (ISSUE #1) Differentiation fails in InfinitePolynomialRing(QQ), e.g. the 
> following code
>
> R. = InfinitePolynomialRing(QQ)
> f = x[0] + x[1]
> derivative(f,x[1])
>
> gives an error
> TypeError: Argument 'var' has incorrect type (expected 
> sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular, 
> got InfinitePolynomial_dense)

Sure, that's not supposed to work. InfinitePolynomialRing knows nothing
about symbolic calculus. That would be the job of symbolic expressions.

> However, if we replace QQ with something more sophisticated, 
> differentiation starts suddenly work:
>
> K. = PolynomialRing(QQ)
> R. = InfinitePolynomialRing(K)
> f = x[0] + x[1]
> derivative(f,x[1])
>
> gives 1 as expected.

Interesting. That's not supposed to work either.

A possible explanation: InfinitePolynomialRing uses a *finite*
polynomial ring under the hood, which is extended when a generator
is requested with a higher index.

If I recall correctly, methods that aren't explicitly implemented for
elements of InfinitePolynomialRing are forwarded to the underlying finite
polynomials. That could explain why it works at all. But I don't know
why it only works if the base ring is a polynomial ring.

> (ISSUE #2) Slightly modifying the second example above:
>
> K. = PolynomialRing(QQ)
> R. = InfinitePolynomialRing(K)
> f = x[0] + x[1]
> derivative(f,x[2])
>
> we get an error
> ValueError: cannot differentiate with respect to x_2
>
> However, if we try to execute the same 'derivative(f,x[2])' command again 
> in the same Sage session, it will succeed.

> So, it appears that if we differentiate with respect to a new variable, 
> which was not accessed before, then differentiation would fail. I hope this 
> is not an intended behavior and can be easily fixed.

When you create f, then it is implemented based on a ring with two variables
x0 and x1. Thus, a method of an element of K['x0','x1'] is called, on
x[2], which K['x0','x1'] doesn't know about. But by calling x[2], the
underlying finite ring in the meantime is extended to K['x0', 'x1',
'x2'], thus, when you try to differentiate a second time, it is done in
a ring in which x2 is known.

At least that's my guess.

As I said, differentiation is not supposed to work. But I (as original
author) don't fully understand *why* it sometimes works and how to fix
that (by "fix", I mean "make it not work and, in the best case, suggest
to convert to a symbolic expression").

InfinitePolynomialRing was created for a very narrow purpose, namely
computing symmetric Gröbner bases. In particular, calculus was not in
the scope. If someone wants to extend its functionality, I wouldn't
mind though.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/shahdk%245et%241%40ciao.gmane.io.


[sage-support] Re: What's the easiest way to calculate a Hironaka standard basis using SageMath?

2020-12-13 Thread Simon King
Hi Joshua,

SageMath uses Singular to compute Gröbner and standard bases.

I think that Singular (and thus, SageMath) doesn't strictly distinguish
between a Gröbner basis and a standard basis, because in a global term
ordering (i.e. 1 is smallest), both notions coincide, and thus in local
term orderings (i.e. 1 is biggest), they don't distinguish either,
although Buchberger (coining the notion "Gröbner basis") only considered
global orderings, whereas Hironaka (coining the notion "standard basis")
was more into local orderings.

Example from the docs:
"""
   Sage also supports local orderings:

  sage: P. = PolynomialRing(QQ,3,order='negdegrevlex')
  sage: I = P * (  x*y*z + z^5, 2*x^2 + y^3 + z^7, 3*z^5 +y^5 )
  sage: I.groebner_basis()
  [x^2 + 1/2*y^3, x*y*z + z^5, y^5 + 3*z^5, y^4*z - 2*x*z^5, z^6]
"""

Note that Singular seems to give a different answer:

sage: singular(I).std() 
2*x^2+y^3+z^7,
x*y*z+z^5,
y^5+3*z^5,
y^4*z-2*x*z^5,
3*z^6+2*x*y*z^5

But in fact it isn't, because by default, in local orderings, Singular
doesn't seem to do tail reductions and also wouldn't automatically
normalise the leading monomials, whereas SageMath does. I'm
demonstrating that Singular's and SageMath's answers coincide:

sage: singular.option('redTail')
sage: singular(I).std().interred().normalize()  
x^2+1/2*y^3,
x*y*z+z^5,
y^5+3*z^5,
y^4*z-2*x*z^5,
z^6

Best regards,
Simon

On 2020-12-12, Joshua Holden  wrote:
>  
>
> Hi, everyone!
>
> I'm trying to do some computations with (truncated) multivariable power 
> series, which I'd like to put into Hironaka standard basis form. This is 
> almost the same as a Groebner basis, except that the "leading" terms have 
> smallest degree instead of largest. This requires slight changes to the 
> algorithms in order to make sure they terminate. Does anyone know if this 
> has been implemented in Sage or have a good way to fake it? I don't use 
> Sage a lot and I can't find anything obvious in the documentation so I 
> thought I'd ask before trying to re-implement something.  I tried 
> ask.sagemath.org and someone said this might be a better place.
>
> Thanks very much!
>
> Josh
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/rr4j7d%241el%241%40ciao.gmane.io.


[sage-support] Re: factorial

2020-11-29 Thread Simon King
Hi Nils,

fair enough. I didn't deeply think about it, my naive impression was
that what the preparser does to
  R. = QQ[]
is at least as complicated as dealing with the exclamation mark. But
I guess you're right: It isn't.

Best regards,
Simon

On 2020-11-29, Nils Bruin  wrote:
> With the current regexp-based rewriting we'd need a pattern of the kind 
> '!' -> 'factorial( are doing an operator substitution already '^' -> '**" but that's very 
> basic and doesn't need any context. To change an implicit unary postfix 
> operator to an explicitly parenthesized prefix operator need almost 
> complete parsing. Had the factorial been explicitly parenthesized as well, 
> it would be a little easier, since now you could do it with parenthesis 
> counting -- still not regex territory, but possibly reasonably efficiently 
> done if one concentrates on the case where the expected string before the ! 
> is short.
>
> Insisting on parens does not satisfy the people who'd request this, I 
> imagine. Writing (5)! instead of 5! doesn't really do the trick.
>
> I consider this weird postfix notation as a peculiarity that works somewhat 
> OK in written math but, just as implicit multiplication, as bad in CAS use. 
> So I'm not in favour of it. I estimate that the number of arguments against 
> it is at least 3!
>
> On Sunday, November 29, 2020 at 5:32:30 AM UTC-8 Simon King wrote:
>
>> On 2020-11-29, Simon King  wrote:
>> > Hi Emmanuel,
>> >
>> > On 2020-10-28, Emmanuel Charpentier  wrote:
>> >> Nope. This syntactic sugar is provided by `Maxima`'s and 
>> `Mathematica`'s 
>> >> readers, but not by Sage preparser.
>> >
>> > Would it be nice (and easy) to have in Sage? What prevents the preparser
>> > from understanding "!"?
>>
>> To be more precise: If I understand correctly, the preparser can be made
>> to accept any syntax, provided that this syntax is in no conflict with
>> valid Python syntax.
>>
>> There is a special meaning of "?" and "??" in Python, but I think there
>> isn't a special meaning to "!". Sage accepts "!" at the beginning of a
>> line, meaning that it executes a shell command, such as
>> sage: !ls
>> But it should be possible that the preparser could turn "(expression)!" 
>> into
>> "gamma(expression+1)".
>>
>> Do people agree? Unfortunately I do not volonteer to implement it, I'
>> not familiar with the innards of the preparser.
>>
>> Best regards,
>> Simon
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/rq12u7%244h1%241%40ciao.gmane.io.


[sage-support] Re: factorial

2020-11-29 Thread Simon King
On 2020-11-29, Simon King  wrote:
> Hi Emmanuel,
>
> On 2020-10-28, Emmanuel Charpentier  wrote:
>> Nope. This syntactic sugar is provided by `Maxima`'s and `Mathematica`'s 
>> readers, but not by Sage preparser.
>
> Would it be nice (and easy) to have in Sage? What prevents the preparser
> from understanding "!"?

To be more precise: If I understand correctly, the preparser can be made
to accept any syntax, provided that this syntax is in no conflict with
valid Python syntax.

There is a special meaning of "?" and "??" in Python, but I think there
isn't a special meaning to "!". Sage accepts "!" at the beginning of a
line, meaning that it executes a shell command, such as
  sage: !ls
But it should be possible that the preparser could turn "(expression)!" into
"gamma(expression+1)".

Do people agree? Unfortunately I do not volonteer to implement it, I'
not familiar with the innards of the preparser.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/rq07t2%24o75%242%40ciao.gmane.io.


[sage-support] Re: Groebner bases for supercommutative polynomial algebras.

2020-11-29 Thread Simon King
Hi Reimundo,

On 2020-11-29, 'Reimundo Heluani' via sage-support 
 wrote:
> Well, in the Noetherian case this works fine. The setup I need is a 
> non-noetherian algebra: a polynomial differential algebra, that is 
> polynomials 
> in x_1,...,x_n and all of their formal derivatives. So this is a polynomial 
> algebra infinitely generated by variables x_i^{(j)} for 1 <= i <= n and 0 <= 
> j. 

I see. But this probably means that we are talking about two different
notions of supercommutative algebra.

I really mean a finitely generated polynomial algebra in which some
generators anti-commute among each other.

For the non-Noetherian case, I am not so sure if some implementation is
available. What I said about SCA in Singular *is* about Noetherian
algebras.

> I need to compute Hilbert series of differential ideals, that is ideals 
> generated by some elements of the above plus all of their derivatives. 
>
> This works fine in the commutative case, since I can compute grobner bases up 
> to arbtitrary degree and ask for the hilbert series up to that degree. But I 
> couldn't get it to work in the super-commutative case.

I associate three things with it -- but I'm not sure if one of them helps.

1. There are differential algebras in Singular, but again they seem to
   be finitely generated algebras. See
   https://www.singular.uni-kl.de/Manual/latest/sing_2482.htm,
   but I haven't been able to turn this into an example using the
   pexpect interface.
2. There are several implementations of FreeAlgebra in Sage. One of them
   is based on "letterplace", which is provided by Singular. It allows you
   to choose non-negative integer weights and can compute Gröbner bases out
   to any finite degree, *BUT* it only works for weighted-homogeneous
   ideals (and in fact it won't even let you create an element that isn't
   weighted homogeneous). No idea if it is possible to formulate your
   problem in this very restricted setting.
3. There is a so-called InfinitePolynomialRing in Sage and it can
   compute so-called symmetric Gröbner bases. But probably it doesn't
   match your needs at all, as it is commutative, and the ideals under
   consideration need to be "symmetric" in the sense that your algebra
   has indexed series of generators x_1, x_2, x_3, ..., y_1, y_2, y_3, ...,
   and when you take any element of your ideal and apply any permutation of
   {1,2,3,...} to all indices of the generators, than you again get an
   element of your ideal.

But I'm afraid it seems your use case isn't covered.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/rq07f4%24o75%241%40ciao.gmane.io.


[sage-support] Re: factorial

2020-11-29 Thread Simon King
Hi Emmanuel,

On 2020-10-28, Emmanuel Charpentier  wrote:
> Nope. This syntactic sugar is provided by `Maxima`'s and `Mathematica`'s 
> readers, but not by Sage preparser.

Would it be nice (and easy) to have in Sage? What prevents the preparser
from understanding "!"?

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/rq032t%24ev3%242%40ciao.gmane.io.


[sage-support] Re: Groebner bases for supercommutative polynomial algebras.

2020-11-29 Thread Simon King
Hi Reimundo,

On 2020-06-17, 'Reimundo Heluani' via sage-support 
 wrote:
> Is there an implementation of such a thing as in the title? 

TL;DR: Yes. Singular does have these capabilities. I recall that these
were comfortably wrapped in SageMath, but as it turns out: They aren't.

Note to developers: I think we should have at least two trac tickets
related with Reimundo's question, and we should have these tickets opened
10 years ago already!!!

1. If A is a super-commutative algebra (which exists in Sage), then
   singular(A) should create a copy of A in the Singular pexpect
   interface, but this is broken.
2. Apparently, for ideals over A, Sage is using a generic implementation
   that doesn't know about Gröbner bases. It should of course use an
   implementation based on libsingular.

Longer answer:

I suppose "supercommutative" means that you have something
that resembles a polynomial ring, with the difference that some of the
generators anti-commute among each other, whereas some generators
commute with all generators.

> I am facing the following design problem, and I'd love to get some pointers.

Can one not find it by searching in the SageMath documentation? Anyway,
I suppose it is explained in the docs how to create a SCA
(SuperCommutativeAlgebra) with grading, create ideals
over such algebras, and compute Gröbner bases.

This is how one could search during a SageMath session:

  sage: search_src('supercommutative')  
  
However, the answers to that search have not really been helpful. So,
perhaps the search in the documentation wasn't successful either. It
points to a lot of places in "sage.categories", but not where I recall
the actual implementation.

Fortunately I recall that supercommutative algebra is abbreviated as
sca. Hence, the following search succeeded:

  sage: search_def('sca', whole_word=True)  
  
It tells you that you find it (of course with documentation and
examples) in sage.rings.polynomial.plural

> Now the issue is to compute the graded dimension of the quotient as a formal 
> power series.

You talk about Hilbert-Poincaré series? That's already implemented in
SageMath

Actually I need Hilbert-Poincaré series for my computation of modular
cohomology rings of finite groups; these rings are graded-commutative
(for odd prime characteristic at least) and can thus be implemented as
supercommutative algebras.

Here is a non-trivial example from my cohomology computations
(translated to boilerplate singular):

sage: names = '(x1a,x1b,x3a,x3b,y2a,y2b,y2c,y2d,y6)'
sage: Igens = ['x1a*x1b',
 'y2b*x1a-y2a*x1b',
 'y2c*x1a-y2b*x1b-y2a*x1b',
 'y2c*x1b-y2b*x1b-y2a*x1b',
 'y2d*x1a-y2b*x1b+y2a*x1b',
 '-y2b^2+y2a*y2c-y2a*y2b',
 'y2b*y2c-y2b^2-y2a*y2b',
 'y2c^2+y2b^2+y2a*y2b',
 'y2b^2-y2a*y2d-y2a*y2b+x1a*x3a',
 '-y2b*y2d-y2b^2+y2a*y2b+x1b*x3a',
 '-y2b*y2d-y2a*y2d+x1a*x3b',
 '-y2c*y2d+x1b*x3b',
 'y2d*x3a-y2d^2*x1b-y2c*x3a-y2b*x3a+y2a*y2b*x1b-y2a^2*x1b',
 '-y2b*x3a+y2a*x3b-y2a*x3a-y2a*y2b*x1b',
 '-y2c*x3a+y2b*x3b-y2a^2*x1b',
 'y2c*x3b+y2c*x3a-y2a*y2b*x1b-y2a^2*x1b',
 'x3a*x3b-y2d*x1b*x3b+y2a*x1b*x3b-y2a*x1a*x3b+y2a*x1a*x3a']

Create the super commutative algebra:

sage: R = singular.ring(3,names,'wp(1,1,3,3,2,2,2,2,6)')
sage: A = singular.superCommutative(4,9)
sage: A.set_ring()

Create an ideal and compute its Hilbert series (note that the quotient
of A by this ideal is isomorphic to the cohomology ring of the Sylow
3-subgroup of U_3(8) with coefficients in GF(3)):

sage: I = singular.ideal(Igens)
sage: from sage.rings.polynomial.hilbert import hilbert_poincare_series
sage: HP = hilbert_poincare_series(I.twostd().lead(), (1,1,3,3,2,2,2,2,6))

Now we can read off the number of standard monomials in each (weighted)
degree. Unfortunately, Singular doesn't have a function to return
standard monomials in WEIGHTED degree. Hence, just as a proof of
concept, I collect the standard monomials in unweighted degree up to 8,
then filter and count by weighted degree.

sage: SM = []
sage: for d in range(1,9): 
: SM.extend(list(I.twostd().kbase(d)))
:
sage: for d in range(1,9):
: print(d,len([m for m in SM if m.deg()==d]))
:
1 2
2 6
3 8
4 7
5 8
6 6
7 6
8 11

And this coincides with what the Hilbert series predicts:

sage: HP
(t^14 + t^13 + 3*t^12 - 3*t^10 - 7*t^9 - 3*t^8 + t^7 + 2*t^6 - 2*t^5 - 5*t^4 - 
7*t^3 - 6*t^2 - 2*t - 1)/(t^3 - 1)
sage: PowerSeriesRing(ZZ,'t')(HP)
1 + 2*t + 6*t^2 + 8*t^3 + 7*t^4 + 8*t^5 + 6*t^6 + 6*t^7 + 11*t^8 + 13*t^9 + 
9*t^10 + 11*t^11 + 10*t^12 + 8*t^13 + 10*t^14 + 10*t^15 + 8*t^16 + 10*t^17 + 
10*t^18 + 8*t^19 + O(t^20)

Note that in princible Singular can compute Hilbert series, too, but 
it has an awkward syntax, refuses to work in non-commutative settings,
and occasionally suffers from integer overflows.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this 

[sage-support] Different ways of rounding

2020-04-03 Thread Simon King
Hi!

According to IEEE 754, the default rounding mode for floating-point
operations is "round half to even". However, if one calls "round" on
elements of RR, the rounding apparently is "round half away from zero if
the total number of digits in the result is odd and towards zero if
the total number of digits of the result is even":

sage: round(3.5, ndigits=0)
4
sage: round(3.55, ndigits=1)
3.5
sage: round(3.555, ndigits=2)
3.56
sage: round(-3.5, ndigits=0)
-4
sage: round(-3.55, ndigits=1)
-3.5
sage: round(-3.555, ndigits=2)
-3.56
sage: round(-13.555, ndigits=2)
-13.55
sage: round(13.555, ndigits=2)
13.55
sage: builtins.round(13.555)
---
TypeError Traceback (most recent call last)
 in ()
> 1 builtins.round(RealNumber('13.555'))

TypeError: type sage.rings.real_mpfr.RealLiteral doesn't define __round__ method


This gives rise to loads of questions:

1. Is the rule that I formulated really what is used?
2. Is it documented somewhere? It is neither documented in the round()
   function nor in the .round() method of sage.rings.real_mpfr.RealLiteral.
3. Is there some "official" standard (similar to IEEE 754) supporting
   Sage's rounding?
4. Shouldn't the rounding be defined in a .__round__() method rather
   than in a .round() method?
5. Is it possible to explicitly request "half to even" rounding?

Best regards,
Simon


-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/r67qsf%24hha%241%40ciao.gmane.io.


[sage-support] Re: naive question

2020-03-07 Thread Simon King
On 2020-03-07, Eric Gourgoulhon  wrote:
> You should use simplify_full() instead of simplify():

Or you should rather use *polynomials* instead of general symbolic
variables, provided of course that all your expressions are multivariate
rational functions (which is the case here):

> sage: var('s t')
> (s, t)

sage: R. = QQ[]

> sage: thirdroot = ((s^2 - 1)*t^2 - s^2 + 1)/(s^2 + 2*s*t + t^2)

sage: thirdroot = ((s^2 - 1)*t^2 - s^2 + 1)/(s^2 + 2*s*t + t^2)

> sage: factor(thirdroot + 1)
> (s*t + 1)^2/(s + t)^2

sage: factor(thirdroot + 1)
(s + t)^-2 * (s*t + 1)^2

> sage: a = thirdroot + 1 - (s*t + 1)^2/(s+t)^2
> sage: a
> ((s^2 - 1)*t^2 - s^2 + 1)/(s^2 + 2*s*t + t^2) - (s*t + 1)^2/(s + t)^2 + 1
> sage: a.simplify_full()
> 0

sage: a = thirdroot + 1 - (s*t + 1)^2/(s+t)^2; a
0

That's because thirdroot is an element of the quotient field of a
polynomial ring, which does automatic simplifications (which in the
special context of polynomials is a lot easier than in the general
context of symbolic variables).

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/r40ug5%241rii%241%40ciao.gmane.io.


[sage-support] Re: Approximating integral with infinite bounds

2020-02-29 Thread Simon King
Hi Emmanuel,

On 2020-02-29, Emmanuel Charpentier  wrote:
> This question would have been more properly posed on ask.sagemath.org...

Why?

I for one totally dislike ask.sagemath.org and would never post a
question or an answer there. It is of course a matter of taste. But it
is certainly not appropriate to discourage people using sage-support,
IMHO.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/r3en92%243k25%241%40ciao.gmane.io.


[sage-support] Re: Output in characteristic 2

2020-02-03 Thread Simon King
Hi Samanta,

On 2020-02-03, Samanta  wrote:
> I have defined the input variables in characteristic 2.

No, you haven't, see below.

> But when I assign a 
> particular value to the input, output gives the result in simple algebra 
> not in characteristic 2. Here is my code: 
> sage: P. = GF(2)[]

Here, you define P as multivariate polynomial ring over the field
GF(2), the four generators being x0, x1, x2, x3. 

> : x3=0
> : x2=1
> : x1=0
> : x0=1

Here, you override the previous definition and assign to x0,...,x3 some
integers. The ring P still knows how its variables are called, but after
the re-definition x0 does not belong to P any more.

> Can anyone guide me how to get the output values in characteristic 2 if I 
> assign a value to the input? 

It is not totally clear to me what you want to do, so, I'm giving two
different answers.

1. If you want four variables x0, x1, x2, x3 with values in GF(2),
then you should simply define them as such:
sage: x0 = GF(2)(1)
sage: x1 = GF(2)(0)
sage: x2 = GF(2)(1)
sage: x3 = GF(2)(0)
There is no need at all to define P in the first place.

2. If you want to symbolically work with polynomial expressions over
GF(2) in indeterminates x0,...,x3, and want to eventually insert
special values into the expressions, you could do the following:
sage: P. = GF(2)[]
sage: f = ((x0+x1)^2+(x2+x3)^2)^2
sage: f
x0^4 + x1^4 + x2^4 + x3^4
sage: f(x0=1, x1=0, x2=1, x3=0)
0

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/r18las%243nai%241%40ciao.gmane.io.


[sage-support] Re: help cartesian_product?

2019-12-08 Thread Simon King
Hi Roland,

On 2019-12-07, Rolandb  wrote:
> I did not expect parts of the help text; see Class docstring:
>
> Is there a reason for it?

What exactly is your question?

Are you asking for the reason why you did not expect parts of the help
text? Only you can answer that question.

Are you asking because you didn't expect some of the *facts* stated in
the help text? Then your question is rather about the behaviour of
cartesian_product than about its help text.

Are you asking because you see a difference between the text shown in
`cartesian_product.__doc__` and `cartesian_product?`? Then, please be
more specific: Are you missing important information in the text shown
by `cartesian_product?`? Are you simply wondering why there is a
difference? Are you asking how to implement documentation for objects
that are somehow wrapped (such as lazy_import, cached_function etc.)

Best regards,
Simon

> Type:LazyImportString form: The cartesian_product functorial 
> constructionFile:
> /opt/sagemath-8.9/local/lib/python2.7/site-packages/sage/misc/lazy_import.pyxDocstring:
>   
>A singleton class for the Cartesian product functor.
>
>EXAMPLES:
>
>   sage: cartesian_product
>   The cartesian_product functorial construction
>
>"cartesian_product" takes a finite collection of sets, and
>constructs the Cartesian product of those sets:
>
>   sage: A = FiniteEnumeratedSet(['a','b','c'])
>   sage: B = FiniteEnumeratedSet([1,2])
>   sage: C = cartesian_product([A, B]); C
>   The Cartesian product of ({'a', 'b', 'c'}, {1, 2})
>   sage: C.an_element()
>   ('a', 1)
>   sage: C.list() # todo: not implemented
>   [['a', 1], ['a', 2], ['b', 1], ['b', 2], ['c', 1], ['c', 2]]
>
>If those sets are endowed with more structure, say they are monoids
>(hence in the category Monoids()), then the result is automatically
>endowed with its natural monoid structure:
>
>   sage: M = Monoids().example()
>   sage: M
>   An example of a monoid: the free monoid generated by ('a', 'b', 'c', 
> 'd')
>   sage: M.rename('M')
>   sage: C = cartesian_product([M, ZZ, QQ])
>   sage: C
>   The Cartesian product of (M, Integer Ring, Rational Field)
>   sage: C.an_element()
>   ('abcd', 1, 1/2)
>   sage: C.an_element()^2
>   ('abcdabcd', 1, 1/4)
>   sage: C.category()
>   Category of Cartesian products of monoids
>
>   sage: Monoids().CartesianProducts()
>   Category of Cartesian products of monoids
>
>The Cartesian product functor is covariant: if "A" is a subcategory
>of "B", then "A.CartesianProducts()" is a subcategory of
>"B.CartesianProducts()" (see also
>"CovariantFunctorialConstruction"):
>
>   sage: C.categories()
>   [Category of Cartesian products of monoids,
>Category of monoids,
>Category of Cartesian products of semigroups,
>Category of semigroups,
>Category of Cartesian products of unital magmas,
>Category of Cartesian products of magmas,
>Category of unital magmas,
>Category of magmas,
>Category of Cartesian products of sets,
>Category of sets, ...]
>
>   [Category of Cartesian products of monoids,
>Category of monoids,
>Category of Cartesian products of semigroups,
>Category of semigroups,
>Category of Cartesian products of magmas,
>Category of unital magmas,
>Category of magmas,
>Category of Cartesian products of sets,
>Category of sets,
>Category of sets with partial maps,
>Category of objects]
>
>Hence, the role of "Monoids().CartesianProducts()" is solely to
>provide mathematical information and algorithms which are relevant
>to Cartesian product of monoids. For example, it specifies that the
>result is again a monoid, and that its multiplicative unit is the
>Cartesian product of the units of the underlying sets:
>
>   sage: C.one()
>   ('', 1, 1)
>
>Those are implemented in the nested class
>"Monoids.CartesianProducts" of "Monoids(QQ)". This nested class is
>itself a subclass of "CartesianProductsCategory".Class docstring:
>EXAMPLES:
>
>   sage: from sage.misc.lazy_import import LazyImport
>   sage: my_integer = LazyImport('sage.rings.all', 'Integer')
>   sage: my_integer(4)
>   4
>   sage: my_integer('101', base=2)
>   5
>   sage: my_integer(3/2)
>   Traceback (most recent call last):
>   ...
>   TypeError: no conversion of this rational to integerInit docstring: 
>EXAMPLES:
>
>   sage: from sage.misc.lazy_import import LazyImport
>   sage: my_isprime = LazyImport('sage.all', 'is_prime')
>   sage: my_isprime(5)
>   True
>   sage: my_isprime(55)
>   FalseCall docstring: 
>Calling self calls the wrapped object.
>
>EXAMPLES:
>
>   sage: from sage.misc.lazy_import import 

[sage-support] Re: sage building with python3

2019-11-03 Thread Simon King
Hi Dima,

On 2019-11-02, Dima Pasechnik  wrote:
> There "python" is Sage's Python, "pip" manages its modules, etc.

IIRC, that's not true for Sage's py-3 version. Namely, if one opens a
sage-with-py-3 shell, then "python" still means "python2". So, if you
really want Sage-with-py-3's Python installation, you should either do
"sage -python" or (in a Sage shell) "python3". And I think the same
holds for pip.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qpnel6%24itu%241%40blaine.gmane.org.


[sage-support] Re: Tracking memory usage and time

2019-09-03 Thread Simon King
On 2019-09-03, Jori Mäntysalo  wrote:
> On Mon, 2 Sep 2019, J wrote:
>
>> Thanks get_memory_usage sounds good; I want to run several decoders from
>> the coding theory module to see better show there ups and downs;
>
> There is also at least %mprun magic. Googling that will give you some 
> examples.

Cool! I didn't know about %mprun before.

Thanks!
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qkm6b8%241593%242%40blaine.gmane.org.


[sage-support] Re: Cannot load session create in another version of sage

2019-09-03 Thread Simon King
Hi Vincent,

On 2019-09-03, Vincent Delecroix <20100.delecr...@gmail.com> wrote:
>> In fact it isn't compatible, but that of course means it must be
>> attempted to make it compatible.
>
> It is already compatible. You just need to specify which kind of
> data has been pickled ('bytes' vs 'str')

I disagree. When you pickle a Python-2 str and unpickle with Python-3,
you get a Python-3 str. And that's a problem, as Python-2 str
corresponds to Python-3 bytes, whereas Python-3 str corresponds to
Python-2 unicode. Moreover, the attempt to unpickle a Python-2 str as a
Python-3 str can fail.

Of course it is possible that you tell Python-3 to unpickle Python-2 str
as bytes (namely by pickle.load(, encoding="bytes")). But can we
really say that things are *compatible* if an apple (Python-2 str) is
unpickled as a banana (Python-3 str)? And can we really say that things
*are* compatible when compatibility can only be achieved by providing an
optional keyword argument?

Anyway. After I learned about the `encoding` keyword, I opened #28444,
where I propose to add the `encoding` keyword to Sage's `load` function,
so that it can be passed to pickle.load.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qkm69r%241593%241%40blaine.gmane.org.


[sage-support] Re: Cannot load session create in another version of sage

2019-09-03 Thread Simon King
Hi Vincent,

On 2019-09-03, Vincent Delecroix <20100.delecr...@gmail.com> wrote:
>> I believe a CAS which doesn't even *attempt* to offer a way to store user
>> data permanently and reliably is a failure. I'll rant more on it on the
>> ticket.
>
> I strongly agree that this is a needed feature! But, I was told on the
> ticket that pickling is not the way to do it... I am not Python expert
> enough to judge this.

Then I misunderstood. By your comment on the ticket, you found that
Python actually states that the pickle protocol IS supposed to be
compatible.

In fact it isn't compatible, but that of course means it must be
attempted to make it compatible.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qklbo7%24561i%241%40blaine.gmane.org.


[sage-support] Re: Cannot load session create in another version of sage

2019-09-03 Thread Simon King
Hi Vincent,

On 2019-09-03, Vincent Delecroix <20100.delecr...@gmail.com> wrote:
>> If I understand correctly, saving/loading individual objects is supposed to
>> be backwards compatible.
>
> This is not correct. Saving individual object is not supposed to
> be backward compatible. See
>
> https://trac.sagemath.org/ticket/28302

Thank you for the pointer.

I believe a CAS which doesn't even *attempt* to offer a way to store user
data permanently and reliably is a failure. I'll rant more on it on the
ticket.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qkl3fl%243eaj%241%40blaine.gmane.org.


[sage-support] Re: Tracking memory usage and time

2019-09-02 Thread Simon King
Hi J,

On 2019-08-24, J  wrote:
> to do a overview of a rather different set of `SAGE` methods, I would
> like to not only track the time used to run a command, but also the
> memory usage of the commands.
>
> Is there a recommended way to do this?

I am a bit surprised that nobody answered this question yet. Sorry.

There is the get_memory_usage command, that might provide what you asked
for. But I am not sure if I understand correctly what you want to
achieve: Do you have a lengthy program and you want to understand how
much resources each individual command in your program takes? In that
case, it might make sense to use a profiler (e.g., %prun or %crun). Or do
you only want to know how much time and memore the program takes in total?
In that case, %time and get_memory_usage would probably give you the
answer.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qkir96%245tgi%242%40blaine.gmane.org.


[sage-support] Re: SageMath for non-Debian/Ubuntu Linux?

2019-09-02 Thread Simon King
Hi!

On 2019-09-02, Szabolcs Horvát  wrote:
> Are there pre-built binaries for other Linux varieties than Debian/Ubuntu, 
> or perhaps a "generic" variety that works on all common Linuxes?
>
> I am looking to install Sage into my home directory on an openSUSE system 
> where I do not have root access. Am I stuck with compiling from source?

I don't know if there are other pre-built binaries (I didn't look at the
download pages). In any case, it is explained at
http://doc.sagemath.org/html/en/installation/binary.html#linux how to
install from a pre-built binary on Linux.

However, provided that the prerequisites mentioned at
http://doc.sagemath.org/html/en/installation/source.html#prerequisites
are available, building from source shouldn't be much of a problem (I
did use openSUSE till a couple of years ago). It just takes some time to
compile.

Note that you don't need root access. In fact, it is recommended AGAINST
building Sage as root, which is also mentioned in the installation guide
(i.e., the pointer above).

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qkiqtc%245tgi%241%40blaine.gmane.org.


Re: [sage-support] Cannot load session create in another version of sage

2019-08-30 Thread Simon King
Hi Steve,

On Friday, August 30, 2019 at 11:55:45 AM UTC+2, Dima Pasechnik wrote:
>
> On Fri, Aug 30, 2019 at 12:48 PM 'SteveJJ' via sage-support 
> > wrote: 
> > 
> > I saved a session when using sage 8.0. 
> > 
> > When I try to load that session into sage 8.8, I get errors such as: 
> > 
> > RuntimeError: invalid pickle data 
> > ValueError: unknown matrix implementation 'flint' over Symbolic Ring 
> > 
> > The full error output is below. 
> > 
> > Am I missing some packages or do I need to somehow convert the session 
> file? 
>
> I don't think that sage/load_session is guaranteed w.r.t. any kind of 
> backward/forward compatibility. 
> It relies on internals being unchanged, which is certainly not the 
> case from one Sage version to another. 
>

If I understand correctly, saving/loading individual objects is supposed to 
be backwards compatible. But saving whole sessions (which I never tried and 
even didn't know that it exists in Sage, btw.) probably not. There are 
systems (such as GAP), in which one can save the whole session but cannot 
save individual objects; that's a flawed approach, IMHO.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/9e56f166-4bcd-4315-9d90-c2f6df770f15%40googlegroups.com.


[sage-support] Re: Help/Pointers on using docker with travis-ci

2019-07-30 Thread Simon King
Hi!

It seems that the following works:

- Start the container and wait until everything is functional, using
  docker's health check:
docker run --name=test -dit --health-cmd='sage -c "print(1)"' 
--health-interval='20s' --health-timeout='20s' --health-start-period='50s' 
sagemath/sagemath-dev:latest /bin/bash && until docker inspect --format "{{json 
.State.Health.Status }}" test | grep -m 1 -w "healthy"; do sleep 5; done

- Execute commands:
docker exec test command1
docker exec test command2
...

- Stop and remove the docker container.

Would you recommend a different solution?

Best regards,
Simon

On 2019-07-30, Simon King  wrote:
> Nathan,
>
> On 2019-07-29, Nathan Dunfield  wrote:
>> You can start a container and open a shell on it via:
>>
>> docker run -it image_name /bin/bash
>>
>> The container will keep running until you exit the shell, if not longer.  
>> You can open a shell on any running container via
>>
>> docker exec -it container_name /bin/bash
>
> It works to some extent: When I do
>   docker run -it --name bla sagemath/sagemath-dev:latest /bin/bash
> then (after waiting for some time because apparently the docker image
> does some compilation of Sage before doing anything else) I am indeed in
> a bash in docker - and stay there, interactively, which is not what I
> want.
>
> I.e., I need to leave with ctrl-p and ctrl-q, and then I can execute
> commands in that container (such as
>docker container exec bla sage -i meataxe
> )
>
> How can I start/run the container so that I don't need ctrl-p and
> ctrl-q? After all, I want to use the container with a script, not
> interactively. I tried the option "-dit", but then I don't know (and the
> script doesn't know) how long I need to wait until the preparatory steps
> of the container are done. Right after 
>   docker run -dit --name bla sagemath/sagemath-dev:latest /bin/bash
> the command
>   docker container exec bla sage -c "print('Hello')"
> fails, because "sage.all" is not there yet:
> Traceback (most recent call last):
>   File "/home/sage/sage/src/bin/sage-eval", line 4, in 
>   from sage.all import *
> ImportError: No module named sage.all
>
> The same command works after waiting long enough.
>
> Best regards,
> Simon
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qhplk0%246b50%241%40blaine.gmane.org.


[sage-support] Re: Help/Pointers on using docker with travis-ci

2019-07-30 Thread Simon King
Nathan,

On 2019-07-29, Nathan Dunfield  wrote:
> You can start a container and open a shell on it via:
>
> docker run -it image_name /bin/bash
>
> The container will keep running until you exit the shell, if not longer.  
> You can open a shell on any running container via
>
> docker exec -it container_name /bin/bash

It works to some extent: When I do
  docker run -it --name bla sagemath/sagemath-dev:latest /bin/bash
then (after waiting for some time because apparently the docker image
does some compilation of Sage before doing anything else) I am indeed in
a bash in docker - and stay there, interactively, which is not what I
want.

I.e., I need to leave with ctrl-p and ctrl-q, and then I can execute
commands in that container (such as
   docker container exec bla sage -i meataxe
)

How can I start/run the container so that I don't need ctrl-p and
ctrl-q? After all, I want to use the container with a script, not
interactively. I tried the option "-dit", but then I don't know (and the
script doesn't know) how long I need to wait until the preparatory steps
of the container are done. Right after 
  docker run -dit --name bla sagemath/sagemath-dev:latest /bin/bash
the command
  docker container exec bla sage -c "print('Hello')"
fails, because "sage.all" is not there yet:
Traceback (most recent call last):
  File "/home/sage/sage/src/bin/sage-eval", line 4, in 
  from sage.all import *
ImportError: No module named sage.all

The same command works after waiting long enough.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qhovbd%246m21%241%40blaine.gmane.org.


[sage-support] Help/Pointers on using docker with travis-ci

2019-07-29 Thread Simon King
Hi!

Last week at Sage Days 100 I learned how to put the code for my group
cohomology spkg on github and got an introduction on using travis-ci.
However, it seems that I need more help/pointers, in particular on docker.

The things that I want travis-ci to do are:
- Install dependencies of my code into a docker container. I guess that
  goes to the "before_install" section of my .travis.yml file. So, it
  should be pulling the latest sagemath-dev docker image, creating a
  container and sending the commands "sage -i meataxe" and "sage -b" to
  the container.
- Install the package itself. I guess that goes to the "install"
  section. It involves opening a sage shell, installing some C library
  with configure/make/make install, and install some Python/cython code
  with "pip install .".
- Run some tests; I guess that goes to the "script" section.

My problems:
How to keep a docker container running? Currently, after executing a
command, the docker container simply exits. It was suggested to me at
the workshop to put all commands used to install and test my software
into a single shell script and execute that (which means to send only
a single command to the docker container), but it doesn't seem clean
to me (better separate before_install, install and script).

I tried to create and start a container and send commands using "docker
container exec". It did work sometimes, i.e., after some commands the
container stays up and running, but, e.g., it happened that after
"docker container exec  sage -i meataxe" the container exited.

What is the recommendet way to proceed?

PS: I just tried some things again, getting a different error:
  docker container create --name bla sagemath/sagemath-dev:latest 
  docker container start bla
  docker container exec bla ls
  docker container exec bla sage -i meataxe
results in an error in the last command, namely

make build/make/Makefile --stop
make[1]: Entering directory '/home/sage/sage'
rm -f config.log
mkdir -p logs/pkgs
ln -s logs/pkgs/config.log config.log
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... yes
checking for root user... no
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for a sed that does not truncate output... /bin/sed
checking for ar... yes
checking for m4... yes
checking for pkg-config... no
checking for ranlib... yes
checking for strip... yes
checking for GNU or BSD tar... /bin/tar
checking for GNU make... /usr/bin/make
checking for latex... no
configure: You do not have 'latex', which is recommended, but not
configure: required. Latex is only really used for building pdf
configure: documents and for %latex mode in the Sage notebook.
checking for perl... /usr/bin/perl
checking for Perl version 5.8.0 or later... yes
checking for gcc... gcc
sed: can't read conftest.err: No such file or directory
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... configure: error: in `/home/sage/sage':
configure: error: cannot compute suffix of executables: cannot compile and link
See `config.log' for more details
If you would like to try to build Sage anyway (to help porting),
export the variable 'SAGE_PORT' to something non-empty.
make[1]: *** [build/make/Makefile] Error 1
Makefile:39: recipe for target 'build/make/Makefile' failed
make[1]: Leaving directory '/home/sage/sage'
Makefile:31: recipe for target 'all-toolchain' failed
make: *** [all-toolchain] Error 2

Why is that? "sage -i meataxe" did work before (at least with
  "cocker container run ...")

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qhmm3s%2444lt%241%40blaine.gmane.org.


[sage-support] Re: How to export notebook worksheet to text file

2019-07-23 Thread Simon King
Hi,

The post you are replying to is about 9 years old. Meanwhile, it is (I
think) recommended to not use the legacy Sage notebook (sagenb), but use
jupyter.

So, do you really have the problem of converting a Sage notebook, or a
jupyter worksheet?

Best regards,
Simon

On 2019-07-23, 'Perez Verona Isabel Cristina' via sage-support 
 wrote:
> Hi David, 
>
> I'm facing same problem.
> Did you found an elegant way to solve this problem?
>
> On Thursday, July 8, 2010 at 8:26:01 PM UTC+2, David Sanders wrote:
>>
>>
>>
>> On Jul 8, 5:45 am, TianWei  wrote: 
>> > > I built a worksheet with several cells in the notebook, and then 
>> > > wanted to try to run it on a remote computer using the command line 
>> > > interface.  But I could not find a convincing way to export the 
>> > > worksheet to a simple text file that I could import directly to sage, 
>> > > i.e. a "something.sage" file. 
>> > > In the end, I had to copy and paste each cell separately into a text 
>> > > file on the remote machine, which I then imported with "load 
>> > > something.sage"  But this is clearly not a reasonable solution for a 
>> > > long worksheet. 
>> > > I tried the "Text" option in the worksheet, but that produced output 
>> > > which I could not just copy straight into the sage command line, or 
>> > > import with "load". 
>> > 
>> > If Sage has an easy, automatic way of doing this, I'm not aware of it. 
>> > However, there's a couple ways to accomplish what you want to do 
>> > without doing a bunch of repetitive actions (for example, manually 
>> > copying out each the text cell). Unfortunately, both of my suggestions 
>> > require a bit of work: 
>> > 
>> > (1) Open the worksheet through the notebook interface, then click on 
>> > the "Text" tab. Copy the text there, then write a little script to 
>> > strip out every line that doesn't begin with "sage: ". The lines that 
>> > have "sage: " prepended are lines in the input cells (assuming you 
>> > didn't type "sage: " somewhere in the worksheet itself). Strip out the 
>> > "sage: " text. 
>>
>> OK, this is the idea that I came up with. 
>> It is also necessary to strip out the "..." that come at the start of 
>> indented lines, the  lines corresponding to the pretty-printed 
>> output, etc. 
>>
>> I guess I just assumed that this must already have been done and be 
>> easily accessible, since it seems like a reasonably obvious thing to 
>> want to do -- use the nice notebook interface to create a document, 
>> and then convert it to plain Python and/or Sage to use for whatever. 
>>
>> > 
>> > (2) You could tinker around with Notebook, Worksheet, and Cell objects 
>> > in Sage (using a script, command-line, or notebook interface). In 
>> > summary, you could create a Notebook object; get the desired Worksheet 
>> > object using one of the methods of the Notebook object; get a list of 
>> > Cell objects from the Worksheet; then pull out the input text from 
>> > each Cell object. The documentation for these objects are: 
>> > 
>> > 
>> http://www.sagemath.org/doc/reference/sagenb/notebook/notebook.htmlhttp://www.sagemath.org/doc/reference/sagenb/notebook/worksheet.htmlhttp://www.sagemath.org/doc/reference/sagenb/notebook/cell.html
>>  
>> > 
>> > Again, I'm (obviously) not aware of a cleaner way to just pull out the 
>> > input text from a worksheet, and these two suggestions are just the 
>> > work-arounds I could think of. 
>>
>> Thanks to all for the suggestions. 
>>
>> David. 
>>
>> > 
>> > As a side-note, the inverse process (converting from plain-text 
>> > commands to a sage worksheet) is easy; just upload it through the 
>> > notebook interface. 
>> > 
>> > -- Tianwei
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qh769h%242kbh%241%40blaine.gmane.org.


[sage-support] Re: problem with matrix over finite field

2019-07-13 Thread Simon King
Hi Harald,

On 2019-07-12, Harald Schilly  wrote:
>> Do you literally mean "user", not the specific name of a single user?
>
> yes, all cocalc projects run under the same user "user" in their own 
> container.
> No, /home/user is a read/write mounted volume and ~/.sage is a
> directory inside of it. i.e.
>
> $ ls -ld ~/.sage
> drwx-- 14 user user 20 Aug 19  2018 /home/user/.sage
>
> $ touch ~/.sage/foo
> $ ls -l ~/.sage/foo
> -rw-r--r-- 1 user user 0 Jul 12 17:38 /home/user/.sage/foo

So, users ARE able to write to /home/user/.sage/meataxe, right? Then I
don't see what goes wrong here. Is there a symbolic link involved? I
could imagine that MeatAxe needs to be given an absolute path.

>> That would explain why the files are missing (because they are
>> created when missing, which requires write permission).
>
> Is there a way to explicitly trigger the creation of such a file?
> Maybe some error pops up that reveals more information.

In very old MeatAxe versions, there was an executable called maketab
that was responsible for table creation. But now it is just a library
function. The trigger is: Create a matrix over a non-prime finite field
of size <255 in odd characteristic.

Anyway, I created #28188 and would appreciate getting some explanation
on the specific situation on CoCalC and some feedback on the potential
ways out (such as: Keep the arithmetic tables in memory, not on disk).

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qgcmkm%241kkj%241%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: problem with matrix over finite field

2019-07-12 Thread Simon King
Hi Harald,

On 2019-07-12, Harald Schilly  wrote:
> Interestingly, this works:
>
> matrix(GF(16), [[1,0], [0, 1]]) while matrix(GF(25), [[1,0], [0, 1]]) fails 
> with the above error. 

MeatAxe is only used for finite non-prime fields of order <255, and I
forgot to add: Only in odd characteristic (in characteristic 2, M4RIE is
used).

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qga3dj%242lit%242%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: problem with matrix over finite field

2019-07-12 Thread Simon King
Hi Harald,

On 2019-07-12, Harald Schilly  wrote:
> Ok... To me, this sounds like we have to uninstall MeatAxe on CoCalc.
>
> The CoCalc setup is quite easy to explain, and so far I wasn't aware of any 
> issues. Sage is in a globally shared read-only directory 
> /ext/sage/sage- and permissions are set such that a user "user" 
> can read/exec it.

But not write? Then there is the underlying reason why meataxe doesn't
work. I created the SharedMeatAxe wrapper under the assumption that a
user has write permissions in DOT_SAGE.

> I'm wondering which other packages depend on it...

p_group_cohomology. I guess that's all. And of course matrix arithmetic
over non-prime finite fields is a lot faster with MeatAxe as backend
than with Sage's generic matrix implementation (that is used when
MeatAxe is not installed).

> I'll try to install MeatAxe again, though. Maybe that reveals a problem … 
> but in that case I think it's weird that while the installation is broken, 
> the branching for selecting the matrix implementation is still trying to 
> pick it.

I don't believe the installation is broken. It is just that the
installation relies on a contract that is broken on CoCalc (if missing
write permission to DOT_SAGE is the problem).

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qga3ae%242lit%241%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: problem with matrix over finite field

2019-07-12 Thread Simon King
Hi Dima,

On 2019-07-12, Dima Pasechnik  wrote:
> Hi Simon,
> isn't MeatAxe interfaced via a library, rather than via files?!
> Doing arithmetics on small matrices storing them on a disk is insanely
> inefficient...

Maybe. Do you mean one should instead compute a new multiplication table
in memory in each individual Sage session, rather than reloading
previously computed tables? Would that be more efficient?

Reloading is the design choice of MeatAxe, which I preserved when I
forked it to create SharedMeatAxe.

Of course, it might be possible to diverge even further from upstream
and change SharedMeatAxe (which is used in Sage) to not use these files.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qga2lu%24d4r%242%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: problem with matrix over finite field

2019-07-12 Thread Simon King
Hi Harald,

On 2019-07-12, Harald Schilly  wrote:
> On Friday, July 12, 2019 at 11:48:40 AM UTC+2, Simon King wrote: 
>>
>> sage: DOT_SAGE 
>> '/home/king/.sage/' 
>
> It's
>
> sage: DOT_SAGE
> '/home/user/.sage/' 

Do you literally mean "user", not the specific name of a single user?
Does that perhaps mean that some users have no write permission to
it? That would explain why the files are missing (because they are
created when missing, which requires write permission).

Cheers,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qga2fi%24d4r%241%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: problem with matrix over finite field

2019-07-12 Thread Simon King
Hi Hal,

On 2019-07-11, Hal Snyder  wrote:
> sage: a = var('a')
> : matrix(GF(25, a), [[1,0], [0, 1]])
> : 
> p025.zzz: No such file or directory
> ---
> RuntimeError  Traceback (most recent call last)
> in ()
>   1 a = var('a')
> > 2 matrix(GF(Integer(25), a), [[Integer(1),Integer(0)], [Integer(0), 
> Integer(1)]])
>
> /ext/sage/sage-8.8_1804/local/lib/python2.7/site-packages/sage/matrix/constructor.pyx
>  
> in sage.matrix.constructor.matrix 
> (build/cythonized/sage/matrix/constructor.c:2417)()
> 623   :class:`MatrixArgs`, see :trac:`24742`
> 624 """
> --> 625 return MatrixArgs(*args, **kwds).matrix()
> 626 
> 627 
>
> /ext/sage/sage-8.8_1804/local/lib/python2.7/site-packages/sage/matrix/args.pyx
>  
> in sage.matrix.args.MatrixArgs.matrix 
> (build/cythonized/sage/matrix/args.c:7765)()
> 656 break
> 657 else:
> --> 658 M = self.space(self, coerce=convert)
> 659 
> 660 # Also store the matrix to support multiple calls of 
> matrix()
>
> /ext/sage/sage-8.8_1804/local/lib/python2.7/site-packages/sage/matrix/matrix_space.pyc
>  
> in __call__(self, entries, coerce, copy)
> 815 [t]
> 816 """
> --> 817 return self.element_class(self, entries, copy, coerce)
> 818 
> 819 def change_ring(self, R):
>
> /ext/sage/sage-8.8_1804/local/lib/python2.7/site-packages/sage/matrix/matrix_gfpn_dense.pyx
>  
> in sage.matrix.matrix_gfpn_dense.Matrix_gfpn_dense.__init__ 
> (build/cythonized/sage/matrix/matrix_gfpn_dense.c:5245)()
> 427 cdef long nc = ma.ncols
> 428 
> --> 429 self.Data = MatAlloc(fl, nr, nc)
> 430 self._converter = FieldConverter(ma.base)
> 431 
>
> RuntimeError: Cannot select field GF(25) in file matcore.c (line 130)
>
> This is on Ubuntu 18.04, on CoCalc.

Apparently this Sage installation uses MeatAxe as a backend for matrices
over finite non-prime fields. The file p025.zzz is supposed to be
automatically written to $DOT_SAGE/meataxe

So, I wonder: What is DOT_SAGE in your Sage environment? Is there
trouble with writing permissions? Or perhaps blank-space in the path
name?

For comparison (the value of DOT_SAGE can be obtained inside a Sage
shell or alternatively in a usual Sage session):

sage: DOT_SAGE
'/home/king/.sage/'
sage: !ls /home/king/.sage/meataxe
p002.zzz  p005.zzz  p013.zzz  p025.zzz  p064.zzz  p125.zzz  p243.zzz
p003.zzz  p007.zzz  p017.zzz  p027.zzz  p081.zzz  p127.zzz
p004.zzz  p009.zzz  p019.zzz  p049.zzz  p121.zzz  p169.zzz

Best regards,
Simon


-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qg9l1e%241n6b%241%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: need help in entering the values of trigonometric functions

2019-06-24 Thread Simon King
Hi,

On 2019-06-24, Prof K.A.Venkatesh  wrote:
> 1.  how to enter cot(pi*x)?

Did you try to type cot(pi*x) after the Sage prompt?

The result is indeed cot(pi*x) as a symbolic expression. It can be
evaluated by inserting special values for x (which is a pre-defined
symbolic variable).

A nice possibility (assuming that you do want to create a symbolic
function based on cotangent function) is this:
  sage: f(x) = cot(pi*x)
  sage: f
  x |--> cot(pi*x)
  sage: f(3)
  Infinity
  sage: f(3/2)
  0
  sage: f(3/4)
  -1

Hope that I understood and answered your question.
Best regards,
Simon
 

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/qepvbg%2464ol%241%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: How to define variables over integer

2019-05-09 Thread Simon King
Hi Santanu,

Am Mittwoch, 8. Mai 2019 15:15:06 UTC+2 schrieb Santanu:
>
> I know how to define variables over BooleanPolynomialRing.
> This is as follows.
>
> n=4
> V=BooleanPolynomialRing(n+1,['z%d'%(i) for i in range(n+1)] )
> V.inject_variables()
>

The above is what you could do *in an interactive session* in the case that 
the number of variables isn't known in advance. If it is known that you 
have exactly four variables, simply do
   sage: V. = BooleanPolynomialRing()
which would automatically define z0,...,z3 in the global namespace.

Similarly, you can do
   sage: V. = ZZ[]
to create a polynomial ring over the integers with generators z0,...,z3

But the above is not what you could do *in a python module* and in a module 
it is also a bad idea to inject variables.

So, simply put the variables in a list or access them by methods of V.


> Can we define similar code over integers (ZZ) or rationals (QQ)?
>

Actually I wonder if we mean the same when we say "variables over ZZ". I 
mean "generators of a polynomial ring with integer coefficients". When the 
number of generators isn't known in advance, but the generators are named 
z0,z1,z2,..., such ring can be created, e.g., by
sage: P = PolynomialRing(ZZ, 'z', 5)
sage: P
Multivariate Polynomial Ring in z0, z1, z2, z3, z4 over Integer Ring

However, I could imagine that you wanted to ask how to create a symbolic 
variable that is assumed to take values in ZZ --- and that's totally 
different from a generator of a polynomial ring over ZZ. So, if that's what 
you mean, you could do (in an interactive session)

sage: var('z0 z1 z2 z3', domain='integer')
(which would inject the variables into the global namespace) or
Z = var('z0 z1 z2 z3', domain='integer')
(which would also work in a python module and puts the variables into a 
tuple).

Also I want to store variables in an array like Z=[z0,z1,z2,z3]
> but it should be automatic. I will change only n.
>

If you really want to work with symbolic variables, you could do
sage: n = 5
sage: Z = var(['z{}'.format(i) for i in range(n)], domain='integer')
sage: Z
(z0, z1, z2, z3, z4)
sage: z0
z0
(thus, the variables are both put in a tuple and injected into the global 
name space.

However, I believe that very many Sage users work with symbolic variables 
when they should better use generators of polynomial rings. So, perhaps 
code such as the following
sage: P = PolynomialRing(ZZ, 'z', n)
sage: Z = P.gens()
sage: Z
(z0, z1, z2, z3, z4)
sage: P.gen(0)
z0
sage: P.inject_variables()
Defining z0, z1, z2, z3, z4
(the latter only in an interactive session) suites your needs better.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/d7d49151-5dc8-445c-b0dc-e494eb558965%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: A case of immaculate conception...

2019-03-20 Thread Simon King
Hi John,

On 2019-03-20, john_perry_usm  wrote:
> ...
>
> 2) In Catholic theology it is not actually "necessary" for Mary to be free 
> of original sin; rather, it is "fitting".

Right, "fitting" may be the better wording. And concerning the necessity of
the doctrine of immaculate conception: 13th till 19th century (before pope
Pius IX. turned immaculate conception into a dogma), the Dominicans provided
alternative facts, namely "Sanctificatio Mariae" instead of immaculate
conception. Whereas virginal conception is accepted doctrine in Catholicism,
Protestantism and Islam, immaculate conception is dogma in Catholicism, not
accepted as a dogma in most other branches of Christian theology, and
irrelevant to Islam.

So, back to SageMath, hoping to not hurt people's feelings: According to
the scripture (SageMath documentation), in
   sage: f(x,y) = x^2+y
x and y are virginally conceived by the symbolic ring through the power
of the preparser, which is commonly accepted by SageMath's followers.
However, the scripture does not assert that the symbolic ring is free of
sin (bugs), and thus not all followers agree on the immaculate conception
of the symbolic ring.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: A case of immaculate conception...

2019-03-20 Thread Simon King
Hi Emmanuel,

On 2019-03-20, Emmanuel Charpentier  wrote:
> Nice one, Simon ! I'm sorely tempted to mark is as "best answer":-)...

No, it was off-topic. But when a question is raised, I generally try to
answer.
Cheers,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: A case of immaculate conception...

2019-03-20 Thread Simon King
On 2019-03-20, Deepak Pawar  wrote:
> looking for the plotting tutorials in 2D and 3D in sagemath. Can anyone
> suggest me the good resources or link for the same?

Hi Deepak,

this thread is about a totally different topic. Next time please open a
new thread when you want to discuss a new topic.

Concerning your question: You can find SageMath's documentation starting
here: https://www.sagemath.org/

There is a tutorial Plotting:
http://doc.sagemath.org/html/en/tutorial/tour_plotting.html

Also, in the list thematic tutorials
http://doc.sagemath.org/html/en/thematic_tutorials/index.html
you find further tutorials "Symbolics and Plotting" and "Advanced-2D
Plotting".

And of course, the reference manual
http://doc.sagemath.org/html/en/reference/index.html
contains chapters on 2D and 3D graphics.

Best regards,
Simon


>
>
> Thank you
>
> On Wed, Mar 20, 2019 at 4:32 AM Isuru Fernando  wrote:
>
>> If the sage preparser did something like,
>>
>> __tmp__ = SR.var("x, y"); __tmp_g__ = lambda x, y:
>> symbolic_expression(x+y**Integer(2)).function(x,y); f = __tmp_g__(*__tmp__)
>>
>> for
>>
>> f(x, y)  = x + y ** 2
>>
>> you wouldn't have this problem and it should be easy enough to change in
>> the preparsesr.
>>
>> Isuru
>>
>> On Tue, Mar 19, 2019 at 12:38 PM john_perry_usm 
>> wrote:
>>
>>> Apologies for the pedantry, but unless the indeterminates so generated
>>> are free of all bugs, then strictly speaking this is not immaculate
>>> conception; it is spontaneous generation, or perhaps virginal conception.
>>> ;-)
>>>
>>> john perry
>>>
>>> On Tuesday, March 19, 2019 at 6:52:19 AM UTC-5, Emmanuel Charpentier
>>> wrote:

 Defining a symbolic function seems to declare its arguments. Case
 illustrated in this sagecell example
 
  :

 reset()
 Id1=set(show_identifiers())
 foo(p,a,b)=p^(a-1)*(1-p)^(b-1)
 Id2=set(show_identifiers())
 Id2 - Id1

 which happily prints :

 {'Id1', 'a', 'b', 'foo', 'p'}


 Is this expected ?



 --
>>> You received this message because you are subscribed to the Google Groups
>>> "sage-support" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to sage-support+unsubscr...@googlegroups.com.
>>> To post to this group, send email to sage-support@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/sage-support.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sage-support" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to sage-support+unsubscr...@googlegroups.com.
>> To post to this group, send email to sage-support@googlegroups.com.
>> Visit this group at https://groups.google.com/group/sage-support.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> -- 
> *Regards*
>
> Deepak K Pawar
> Research Scholer
> ME16D034
> Machine Design Section
> Department of Mechanical Engineering
> IIT Madras, Chennai, India
> Email: deepakpawar.2...@gmail.co m
>me16d...@smail.iitm.ac.in
> Mob No: +91-7208385265
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: A case of immaculate conception...

2019-03-20 Thread Simon King
Hi Henri,

On 2019-03-19, henri.gir...@gmail.com  wrote:
> What is the difference between virginal conception and immaculate 
> conception ?

"Virginal conception" in the context of Christian dogmatics concerns how
Jesus was conceived. "Immaculate conception" concerns how Jesus' *mother*
was conceived. Thus, two totally different things.

Namely, the dogma of immaculate conception says that Mary was exempt
from the "original sin" (which for ordinary people is hereditary, but in
order to let Mary be able to give birth to God she needed to be free of
*any* sin, including the sins of Adam and Eve).
The dogma of "virginal conception" says that Mary conceived Jesus
although she was virgin.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: A case of immaculate conception...

2019-03-20 Thread Simon King
Hi Isuru,

On 2019-03-19, Isuru Fernando  wrote:
> If the sage preparser did something like,
>
> __tmp__ = SR.var("x, y"); __tmp_g__ = lambda x, y:
> symbolic_expression(x+y**Integer(2)).function(x,y); f = __tmp_g__(*__tmp__)
>
> for
>
> f(x, y)  = x + y ** 2
>
> you wouldn't have this problem and it should be easy enough to change in
> the preparsesr.

By "problem" you mean that f(x,y)=x+y^2 creates symbolic variables
called x and y? I don't think that's a problem, but a useful feature.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: A case of immaculate conception...

2019-03-19 Thread Simon King
Hi Emmanuel,

On 2019-03-19, Jeroen Demeyer  wrote:
> On 2019-03-19 12:52, Emmanuel Charpentier wrote:
>> Defining a symbolic function seems to declare its arguments.
>
> I tend to think that everything on the left of the '=' sign in an 
> assignment is stuff that is assigned to. So
>
>(a, b, c) = range(3)
>
> assigns to a, b and c.
>
>R. = ZZ[]
>
> assigns to R and x.
>
>func(x) = x
>
> assigns to func and x.
>
> So in this sense, it's expected.

Some addition: While the first example
   (a,b,c) = range(3)
is standard Python behaviour, the other examples work because Sage uses
a preparser to make it possible to use nicer syntax in maths:
   f(x) = x^2
is a lot more concise and easier to understand for non-programmers than
   __tmp__=var("x"); f = symbolic_expression(x**Integer(2)).function(x)
(which is what the preparser makes of it).

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: simplification options

2019-03-11 Thread Simon King
Hi Michael,

On 2019-03-11, Michael Beeson  wrote:
> I tried various simplification functions.I suppose I could start over, 
>  not using "symbolic expressions" but 
> declaring K to be a suitable field or ring, maybe a quadratic extension of 
> the field of rational functions in a. 
> That is probably the "right" way to do it.

Probably!

> But I wish there were a simpler way.

Why do you think using a sub-optimal far too general tool (e.g., symbolic
variables when in fact the problem is about polynomial) is "simpler"?

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: groebner basis algorithm: intended way of calling (out of other method)

2019-02-08 Thread Simon King
On 2019-02-08, Daniel Krenn  wrote:
> Which algorithm does not return a *reduced* Gröbner basis?

Singular has some options that determine whether or not a reduced GB is
returned. I simply don't know (and have at the moment no time to look at
the code) whether this option is used. Also, IIRC, there is some toy
implementation of Buchberger's algorithm (which is mainly for teaching,
not for production), and I am not sure if it returns a reduced GB.

In any case, if the documentation says it returns a *reduced* GB, then
we certainly have a bug. Either a bug in the documentation (if in fact
the returned GB is not always reduced) or in caching (if it *is* the
reduced GB and isn't cached).

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: groebner basis algorithm: intended way of calling (out of other method)

2019-02-08 Thread Simon King
Hi Daniel,

On 2019-02-08, Daniel Krenn  wrote:
> Let I be an ideal. Then I might want to compute something involving
> Groebner basis, e.g. computing I.variety().
> Now suppose one wants to select a particular algorithm for the
> computation of the Groebner basis. Then (due to caching) I use something
> along the lines of
>
>   GB = I.groebner_basis(algorithm='libsingular:slimgb')
>   I.groebner_basis.set_cache(GB)
>   I.variety()
>
> Is this the intended way of doing so?

I guess not. I would expect that I.groebner_basis uses caching
regardless of the used algorithm. Are you sure that this is not the
case?

Or do you say that I.groebner_basis sets a cache item for each possible
value of "algorithm" individually? That would probably be a bug (i.e.,
please open a ticket).

Why "probably"? *Reduced* Gröbner bases are unique, hence, they should
be cached independently of the algorithm used to compute them. But some
algorithms would only call *some* Gröbner basis, no *the* reduced
Gröbner basis. So, in these cases it makes sense to not automatically
cache the value.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: taylor versus series

2018-12-30 Thread Simon King
Hi Peter,

On 2018-12-30, Nils Bruin  wrote:
>> Does this only work in interactive mode? As soon as I try to
>> capture it in a function it doesn't work anymore.

The syntax
R. = QQ[[]]
only works interactively. In an interactive session, a preparser is
adding some syntactical sugar:
   sage: preparse('R. = QQ[[]]')
   "R = QQ[['t']]; (t,) = R._first_ngens(1)"

If you want to write a module for Sage, you have to translate it
into Python syntax. One possibility is to copy the above result of the
preparser. Another possibility is
   from sage.rings.power_series_ring import PowerSeriesRing
   R = PowerSeriesRing(QQ, 't')
   t = R.gen()

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: taylor versus series

2018-12-30 Thread Simon King
Hi Nils,

On 2018-12-30, Nils Bruin  wrote:
> In the mean time, you can accomplish your computations without using SR:
>
> sage: R.=QQ[[]]
> sage: (1 - x - sqrt(1 - 6*x + x^2))/(2*x)
> 1 + 2*x + 6*x^2 + 22*x^3 + 90*x^4 + 394*x^5 + 1806*x^6 + 8558*x^7 + 
> 41586*x^8 + 206098*x^9 + 1037718*x^10 + 5293446*x^11 + 27297738*x^12 + 
> 142078746*x^13 + 745387038*x^14 + 3937603038*x^15 + 20927156706*x^16 + 
> 111818026018*x^17 + 600318853926*x^18 + O(x^19)
>
> which is probably why the state of "series" is so abysmal: people don't use 
> it.

Interesting. I often tell people to only use symbolic expressions when it
is really needed --- and I thought that in this particular case the
usage of symbolic expressions is appropriate. But you showed that again
using a more specialised tool is better.

Cheers,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: taylor versus series

2018-12-30 Thread Simon King
PS:

On 2018-12-30, Simon King  wrote:
> It surprises me that .series(x,6) has a pole (after all, LargeSchroeder's 
> discontinuity in x=0 seems removable), so perhaps it's a bug, but
> perhaps it's a feature after all --- I cannot tell from the documentation
> if it is intended or not.

Here is another reason why I think it's a bug: The residue of
LargeSchroeder at x=0 is supposed to be the coefficient of x^(-1) in
its Laurent series expansion. However,

sage: LargeSchroeder.residue(x==0)
0
sage: LargeSchroeder.series(x,6).coefficient(x^-1)
-1/2

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: taylor versus series

2018-12-30 Thread Simon King
Hi Peter,

On 2018-12-30, Peter Luschny  wrote:
> With Sage 8.4:
> LargeSchroeder = SR((1 - x - sqrt(1 - 6*x + x^2))/(2*x))

Putting "SR" around the expression probably isn't needed, as by default
x is a symbolic variable (of course this doesn't hold if you have
defined x to be something else).

> print(LargeSchroeder.taylor(x, 0, 6).list())
> print(LargeSchroeder.series(x, 6).list())

Why "print" (assuming that you are in an interactive session)?

> Bug or feature? Moreover
>
> taylor? .. gives hints
> series? .. Object `series` not found.

It seems that you are confusing functions and methods. If you do
LargeSchroeder.taylor? and LargeSchroeder.series?, you'll see
documentation of both.

Explanation: In addition to "taylor" being a method of symbolic
expressions, it also is a function defined in Sage's global name
space; this is not the case for "series", that's why "series?" doesn't
give you an answer.

Now for the differences of both methods: Unfortunately, the documentation of
LargeSchroeder.series? isn't very clear. Apparently .taylor(x,0,6) returns a
polynomial (or to be precise: A symbolic expression that looks like a
polynomial but is not implemented as an element of a polynomial ring, which
from my experience is a difference that is not sufficiently appreciated by
most calculus students using computer algebra systems), whereas
LargeSchroeder.series(x,6) returns a Laurent series, i.e., it contains
negative exponents:

  sage: LargeSchroeder.series(x,6)
  (-1/2)*x^(-1) + 3/2 + 2*x + 6*x^2 + 22*x^3 + 90*x^4 + 394*x^5 + Order(x^6)
  sage: LargeSchroeder.taylor(x,0,6)
  1806*x^6 + 394*x^5 + 90*x^4 + 22*x^3 + 6*x^2 + 2*x + 1

It surprises me that .series(x,6) has a pole (after all, LargeSchroeder's 
discontinuity in x=0 seems removable), so perhaps it's a bug, but
perhaps it's a feature after all --- I cannot tell from the documentation
if it is intended or not.

Best regards,
Simon


-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Function defined with matrices won't plug in values for function

2018-12-15 Thread Simon King
On 2018-12-15, Simon King  wrote:
> It's not an error but a warning. The absence of a warning doesn't mean
> that the result is more trustworthy than a result of a computation that
> doesn't create a warning. 

Ooops, one negation too many. I meant to say: "The absence of a warning
doesn't mean that the result is more trustworthy than the result of a
computation that DOES create a warning. Sorry.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Function defined with matrices won't plug in values for function

2018-12-15 Thread Simon King
Hi Saad,

sorry that it took long to answer; I thought others would reply sooner
than I.

On 2018-12-05, saad khalid  wrote:
> If I run it, it gives me results with the error: "
>
> UserWarning: Using generic algorithm for an inexact ring, which will probably 
> give incorrect results due to numerical precision issues."

It's not an error but a warning. The absence of a warning doesn't mean
that the result is more trustworthy than a result of a computation that
doesn't create a warning. See below: When doing numerical computations,
it is advisable to assess the results by cross verifications and
consistency checks.

> I expected this error to be some minute difference in the far out decimal 
> place range, like I so often see with 
> complex numbers, but the answer I get is actually Quite a bit off from the 
> correct answer.

No surprise. That's in the nature of numerical computations.

> My question is, why is the default an alg that seems to give incorrect 
> answers, instead of just defaulting to CDF? 
> Also, is there a better way of doing this besides just appending CDF to the 
> beginning every time? 

The default complex field CC has a precision of 53 bits. In principle
you can create a complex field with arbitrary finite precision, by using
ComplexField(bitwise_precision)

CDF is just a wrapper of machine double precision complex numbers, which have a
fixed precision of 53 bit as well. However, computations in CDF are based on 
the GNU
Scientific Library (GSL). Apparently CC uses a generic algorithm to compute
eigenvalues --- which is both slower and more prone to rounding effects
than the algorithm in GSL.

So, as usual when doing numerical computations, one needs to make the
best of the available resources. For example, if in some parts of your
computation you do "ordinary" arithmetic computations and need to do it
in very high precision, you could create a complex field in the required
precision, and build your matrix M on top of it; and when you in another
part of your computations you need a stable numerical algorithm that
isn't offered by CC, then you can always change to CDF.

For example:
  sage: C = ComplexField(500)
  sage: M = random_matrix(C, 10)
  sage: M2 = M.change_ring(CDF)
  sage: abs(M.determinant()^20 - (M^20).determinant())
  
3.22553502188764194905953565908366462673376034391868764719927365055487394028435964347935057202262954253087699368051026966711621636866859093419028355926e-59
  sage: abs(M2.determinant()^20 - (M2^20).determinant())
  2.1231804490158553e+41

Of course, the absolute value of the difference should theoretically be zero.
So, as you can see here, in my example it is many orders of magnitude better
to use a high precision field instead of CDF.

Also, the eigenvalues and characteristic polynomial are more consistent than
those computed in CDF: Let's compare the characteristic polynomial with the
product of (x-eigenvalue):
   sage: R. = C[]
   sage: max(abs(c) for c in (M.charpoly()-prod((x-ev) for ev in
   M.eigenvalues())).list())
   /home/king/Sage/git/sage/src/bin/sage-ipython:1: UserWarning: Using
   generic algorithm for an inexact ring, which will probably give
   incorrect results due to numerical precision issues.
 #!/usr/bin/env sage-python23
   
4.69238225433539279163184034797611678687652260951909375574059096465606393834197062303005271312591139060256023453735495755056822286510738017751316446341e-148
   sage: max(abs(c) for c in (M2.charpoly()-prod((x-ev) for ev in
   M2.eigenvalues())).list())
   3.096434044909977e-12

But if the precision of the field C is only marginally larger than the
precision of CDF, the picture changes:
   sage: C = ComplexField(60)
   sage: R. = C[]
   sage: M = random_matrix(C, 10)
   sage: M2 = M.change_ring(CDF)
   sage: abs(M.determinant()^20 - (M^20).determinant())
   7.9015802853808835e72
   sage: abs(M2.determinant()^20 - (M2^20).determinant())
   4.509812763227185e+43
   sage: max(abs(c) for c in (M.charpoly()-prod((x-ev) for ev in
   M.eigenvalues())).list())
   /home/king/Sage/git/sage/src/bin/sage-ipython:1: UserWarning: Using
   generic algorithm for an inexact ring, which will probably give
   incorrect results due to numerical precision issues.
 #!/usr/bin/env sage-python23
   9.9301366129890920e-16
   sage: max(abs(c) for c in (M2.charpoly()-prod((x-ev) for ev in
   M2.eigenvalues())).list())
   3.5482789005657048e-12

This time, determinant and matrix multiplication are more consistent in
CDF than in C (although the precision used in C is still slightly better
than in CDF!). But the consistency of eigenvalue and charpoly computation
is still better in C and in CDF.

However, the fact that eigenvalues and charpoly are more *consistent* in
CC than in CDF does not mean that the eigenvalues are more close to
reality. So, let's start with a matrix with known eigenvalues, then
compare with computations in CC resp. in CDF resp. in precision 2000:
   sage: EV = [CC.random_element() for _ in range(10)]
   

[sage-support] Re: Solving recursion formula?

2018-12-12 Thread Simon King
On 2018-12-09, Marc Mezzarobba  wrote:
> Simon King wrote:
>> What about
>> a more complicated recurrence, such as the one given by
>> x_(n+1) = 1 + x_n*2/n
>> Any chances to solve those and similar recurrences automatically?
>
> You can try sympy's rsolve() or Maxima's solve_rec(). I don't know how 
> powerful they are.

Hi Marc,

I had a look and it seems that it is doing what I was looking for. Thank
you for the hint!

Coincidentally, William Stein today advertised a multi author book on doing
computations with Sage, and it has a chapter on solving recurrences,
also pointing to sympy.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Solving recursion formula?

2018-12-08 Thread Simon King
Hi Marc,

On 2018-12-08, Marc Mezzarobba  wrote:
> In Sage itself, CFiniteSequence.closed_form() should be able to solve 
> linear recurrence with constant coefficients.

Thank you!
Indeed, after changing my search keyword from resursive to reccurrence,
CFiniteSequence seemed to be the most helpful answer in Sage. What about
a more complicated recurrence, such as the one given by
   x_(n+1) = 1 + x_n*2/n
Any chances to solve those and similar recurrences automatically?

My original hope was that some capability to solve a symbolic recurrence
is standard in Sage; after all, symbolic sums *can* to some extent be
computed in Sage:
  sage: var('k', domain='integer')
  k
  sage: sum(x^k*(k+1)/(k+2), k,0,Infinity)
  (x*(log(-x + 1) - 1) - log(-x + 1))/(x^3 - x^2)

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Solving recursion formula?

2018-12-07 Thread Simon King
Hi again,

On 2018-12-07, slelievre  wrote:
> There's competition between the words "recursion" and "recurrence",
> you might have had more luck with "recurr".

I'll try to do search_def("recur"), then.

However:

> This should be possible using either SymPy, or FriCAS,
> or the optional "Ore algebra" package:
>
>   http://www.kauers.de/software.html
>   https://github.com/mkauers/ore_algebra/

If I understand correctly, this and the "ask sage" and "sage-support"
links that you were providing mainly are about guessing a recurrence
that matches given data.

That's not what I am looking for. No data are given. Given is some
recursion formula; what we want to know is a corresponding closed formula.
Example: The recursion x_0=1 and x_(n+1) := f(x_n) = 2*x_n should result
in the closed formula x_n = 2^n.

I was just wondering if Sage could do such deductions more or less
automatically (and: how).

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Solving recursion formula?

2018-12-07 Thread Simon King
Hi Samuel,

thank you for all the links!

Best regards,
Simon

On 2018-12-07, slelievre  wrote:
> Fri 2018-12-07 13:56:34 UTC+1, Simon King:
>
>> Let x_0 be given, let f be a function defining a sequence (x_0,x_1,...)
>> recursively by x_{n+1}=f(x_n). 
>>
>> Is there a tool in Sage that can (at least in sufficiently simple cases)
>> deduce a closed formula for x_n? I tried search_def('recurs'), but it
>> revealed nothing I could recognise.
>
> There's competition between the words "recursion" and "recurrence",
> you might have had more luck with "recurr".
>
> This should be possible using either SymPy, or FriCAS,
> or the optional "Ore algebra" package:
>
>   http://www.kauers.de/software.html
>   https://github.com/mkauers/ore_algebra/
>
> Some related discussions can be found through the following queries:
>
> - 
> https://groups.google.com/forum/#!searchin/sage-devel/ore_algebra%7Csort:date
> - 
> https://groups.google.com/forum/#!searchin/sage-support/ore_algebra%7Csort:date
> - 
> https://ask.sagemath.org/questions/scope:all/sort:activity-desc/page:1/query:ore_algebra/
> - https://trac.sagemath.org/query?order=id=1=~ore_a
>
> To highlight some relevant results from sage-devel and sage-support:
>
> - sage-devel, 2016-11
>   Recurrences and Sequence Formula Guessing Functions in Sage
>   https://groups.google.com/d/topic/sage-devel/FfJrjaSdkF8/discussion
>
> - sage-support, 2014-09
>   Formula for simple recursive sequences
>   https://groups.google.com/d/topic/sage-support/tTqX2BCzjgY/discussion
>
> - sage-devel, 2014-01
>   class LinearRecurrence
>   https://groups.google.com/d/topic/sage-devel/PTx12wrVG0c/discussion
>
> - sage-devel, 2013-06
>   New ore_algebra Sage package is available
>   https://groups.google.com/d/topic/sage-devel/S7Wv67C6DvE/discussion
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Solving recursion formula?

2018-12-07 Thread Simon King
Hi!

Let x_0 be given, let f be a function defining a sequence (x_0,x_1,...)
recursively by x_{n+1}=f(x_n).

Is there a tool in Sage that can (at least in sufficiently simple cases)
deduce a closed formula for x_n? I tried search_def('recurs'), but it
revealed nothing I could recognise.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Function defined with matrices won't plug in values for function

2018-12-02 Thread Simon King
Hi Saad,

as an algebraist I may be biased, but I have never understood why so
many people try to use symbolics when they are not doing calculus.
Calculus is a pancake, not a panacea (sorry for the bad joke).

Without a joke: Quite many user questions can be answered in that way:
"You try to achieve xy by using symbolic variables, but that's not what
they are made for; use one of the following specialised tools for xy:
..."

On 2018-12-02, saad khalid  wrote:
> Why can't matrices be allowed in SR in a nontrivial way?

I guess the shortest answer is: A matrix knows what to answer when the user
does "M[x,y]". SR is the ring of symbolic variables, and symbolic variables
don't know what a user expects from a matrix. In fact, matrices are a
construction taken from linear algebra, not from calculus. So, it isn't a
surprise that SR can't handle it.

Let's get back to your original post:

>> I'm not sure what is happening, but I defined some matrices:
>> Mz = matrix([[0,1],[1,0]])
>> Mx = matrix([[1,0],[0,-1]])
>> M1 = matrix([[1,0],[0,1]])
>>
>> And then I tried defining a function where I multiply these matrices by 
>> some variable and add them together:
>>
>> h(s) = M1 + s*Mx
>> h(.1)

Apparently what you want is not a function that maps a number s to a
matrix. What you want is a matrix with a parameter s. And in fact all
matrix entries are polynomial in s.

SR is a very general tool, but being "very general" implies being
"sub-optimal for most purposes". So, when you work with polynomials then
define a polynomial ring, and when you work with matrices then define
matrices over that polynomial ring:

sage: R. = QQ[]
sage: Mx = matrix(R,[[1,0],[0,-1]])
sage: M1 = matrix(R, [[1,0],[0,1]])
sage: h = M1 + s*Mx

Calling that matrix specialises the parameter s in the way you expected
(in particular, the syntax h(s=.1) isn't needed):

sage: h(.1)
[ 1.10 0.000]
[0.000 0.900]

And you can still do calculus, to some extent:

sage: h.derivative(s)
[ 1  0]
[ 0 -1]

Summary: If you use tools that were designed to work with the mathematical
notions you are using (matrices over polynomial rings),...
sage: type(h)

... then things are more likely to work in the way you expect it.

Best regards,
Simon


-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Quaternions, how to speed up computation

2018-11-19 Thread Simon King
Hi 

On 2018-11-19, Kolen Cheung  wrote:
> Then I thought I can import it in Python like this:
>
> import sage.rings
> # OK
>
> sage.rings.polynomial.polynomial_ring.PolynomialRing_field
> # AttributeError

Admittedly the following is not an ideal solution, but you can do
  >>> from sage import all
  >>> from sage.rings.polynomial.polynomial_ring import PolynomialRing_field

> sage.rings.polynomial.polynomial_ring.PolynomialRing_field_with_category

The "..._with_category" classes cannot be imported: These are
dynamically created classes.

> How would you write the same program in Python using sage as a library? And 
> in general I see many unfamiliar syntax (from Python’s point of view) like 
> R., QQ[], (0..20), etc.

That's a feature. Syntax such as
  R. = QQ[]
was inspired from Magma (if I recall correctly). This and other
syntactical features are very useful in interactive sessions.

It works because of a preparser. If you want to know how to translate an
interactive session into module code, the "preparse" function is your
friend:
  sage: preparse("R. = QQ[]")
  "R = QQ['x']; (x,) = R._first_ngens(1)"

So, the output of preparse(`interactive sage command`) is `valid python
command`.

Concerning imports of constants, there is the "import_statements"
function:
  sage: R. = QQ[]
  sage: import_statements(R)
  from sage.rings.qqbar import QQx
  sage: R. = QQ[]
  sage: import_statements(R)
  from sage.rings.qqbar import QQxy
  sage: R. = QQ[]
  sage: import_statements(R)
  Traceback (most recent call last):
  ...
  ValueError: no import statement found for 'Multivariate Polynomial
  Ring in x, y, z over Rational Field'.

So, "import_statements" is for stuff that is defined in some Sage
module, not for interactively created objects

If I recall correctly, there is a function that for *many* (not all)
interactively created objects in Sage tells how they can be constructed,
but I don't recall the name of that function.

> Do you think it is realistic to use sage as a 
> Python library and completely not using sage (as an interpreter) itself?

Sure. If you write code (in the sense of "python or cython module") for
Sage, then you are in fact using Sage as a Python library. To execute it
in Python, I think "from sage import all" should be enough to make it
work (but a less thorough import statement might work too).

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Blue on black text

2018-10-31 Thread Simon King
Hi "drl",

you say that your text terminal's default is black background and dark
blue text, and if I understand correctly, you don't like that Sage is
using your own default color scheme. If your question is how to change
the color scheme of your text terminal then I guess it depends on your
computer's operating system. I'm using black on light-yellow.

Not showing error tracebacks means withholding very useful information.
There is not just "a few" people doing development in Sage, and for a
developer, having that information is essential. Opening a log file on
each single of the myriads of errors that may occur in a development
process is just awkward.

On the other hand, a user who doesn't do development can still look at
the bottom line, i.e., the error message, and ignore the traceback.
But the error message itself typically doesn't tell if the error is
because of a bug or because of wrong usage. So, even for a casual user
it makes sense to at least have a short glance at the traceback.

While I think tracebacks should always be shown in the text terminal,
it might be a good idea to make it so that a traceback in the *notebook*
will be folded and will only be visible when the user clicks
on an appropriate button. I don't know how that could be done in the
Jupyter notebook, but perhaps other people know. A user who decided to
wrongly believe that tracebacks are useless won't be bothered, and a
developer can easily enough access the traceback.

Best regards,
Simon



On 2018-10-31, deSitter  wrote:
> While I'm bitching - every error generates a blizzard of pointless 
> information that belongs in a log file, not in front of the user's 
> eyeballs. That also desperately needs to be fixed.
>
> On Wednesday, October 31, 2018 at 7:21:34 AM UTC-4, deSitter wrote:
>>
>> My text terminal uses a black background. The default text is dark blue on 
>> jet black. This is not a winning start to 8.4. How do I change the text 
>> color. Seriously, this is the sort of little thing that is absolutely 
>> exasperating, to get a perfect build right out of the box and then find it 
>> unreadable and so unusable. What Sage really needs is someone to fix these 
>> usage issues and make the thing presentable and the syntax less brittle! 
>> I'm not busy at the moment. Contact me, believe me, I will fix this.
>>
>> -drl
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: "Is 1 zero or nonzero?"

2018-10-24 Thread Simon King
Hi Chris,

On 2018-10-23, Chris Judge  wrote:
>
> Appears to be a bug that comes when integrating expression.
> Maxima asks "Is 1 zero or nonzero?" and then suggests using assume(1>0). 
> Then it fails to accept this assumption...

You just made my day...

Coincidally, this week I told my students about the trivial ring (where
1=0).

In any case, in order to track down the bug you encountered, it would
help if you could give us the expression whose integration triggers the
bug.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Integration bug?

2018-10-02 Thread Simon King
On 2018-10-02, kcrisman  wrote:
> Please do.  It's likely something related to 
> https://trac.sagemath.org/ticket/21440 and 
> https://trac.sagemath.org/wiki/symbolics#Integrationtickets where you can 
> browse to your heart's content :-) For some reason the wrong branch seems 
> to get chosen by Maxima at times.

OK, I'll add the example at #21440.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Integration bug?

2018-10-01 Thread Simon King
Hi!

I get the following with sage-8.4.beta5:
  sage: f(x) = cos(pi*x)
  sage: (f(x)*exp(-I*pi*x)).integral(x)(x=1/2) - 
(f(x)*exp(-I*pi*x)).integral(x)(x=-1/2)
  1/2
  sage: (f(x)*exp(-I*pi*x)).integral(x,-1/2,1/2)
  1

The previous two expressions are not equal, but I think they should be
equal. Is it a stupid mistake of mine (but then, Wolfram alpha does the
same stupid mistake), is it a known bug, or a new bug (in that case I
should create some ticket, that would probably be my first on calculus...)?

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Accessing group generators in libgap

2018-10-01 Thread Simon King
Hi Dima,

On 2018-09-30, Dima Pasechnik  wrote:
> it was written before optional parameters era in GAP, as far as I know.
> Anyhow, you can use GAP's PushOptions() and PopOptions() to achieve more or 
> less
> the same effect, with a big uglier syntax.

"Uglier" only internally. I think it shouldn't be too difficult to
modify libgap's functions so that optional parameters (passed in the
usual pythonic way) are first pushed and eventually popped from GAP's
global optional value stack.

When I first saw your work-around, I though it would have ugly side-effects. 
But I just realise that it wouldn't change GAP's behaviour. For instance:

 gap> test := function()
 >local foo;
 >foo := ValueOption("foo");
 >Print(foo);
 > end;
 function(  ) ... end
 gap> f := function()
 >local foo;
 >foo := ValueOption("foo");
 >Print("Original value ",foo);
 >test();
 > end;
 function(  ) ... end
 gap> f();
 Original value failfail
 gap> f(:foo:=5);
 Original value 55

Note that the option set when calling the outer function is also present
in the inner function, and that's the same when directly pushing to the
global option stack:

 gap> PushOptions(rec(foo:=5));
 gap> f();
 Original value 55
 gap> PopOptions();
 gap> f();
 Original value failfail

So, that would work as desired.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Accessing group generators in libgap

2018-09-30 Thread Simon King
On 2018-09-30, Simon King  wrote:
> D) libgap's and gap's methods should have roughly similar semantics

That said: Of course I see the point of designing the libgap interface
in the way it was done: libgap(X), where X is something in Sage, should
return something in libgap that corresponds to X (hence, if X is a
string, it should return a libgap-string), whereas evaluation of
commands should only happen when explicitly requested (i.e., when doing
libgap.eval(X)).

So, point D) of my wish list actually isn't really a wish. The
differences however make porting my code from gap to libgap go beyond
search-and-replace...

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Accessing group generators in libgap

2018-09-30 Thread Simon King
Hi Vincent,

On 2018-09-30, Vincent Delecroix <20100.delecr...@gmail.com> wrote:
> The main problem is that G is a gap group and not a libgap
> group. By gap group I mean that the interface going through
> the pexpect interface. The two systems gap and libgap do not
> seem to share the namespaces (which make sense).

Oops. You are right. After correcting it, my example works just fine.

Sorry for that.

Nonetheless, I have a wishlist concerning libgap:

A) Generator access with dot syntax

I'd like to have that G.1 returns the first generator of the
group (which it does in GAP language, but neither in the gap pexpect
interface nor in libgap).

---
B) Optional values for libGAP functions

In Gap, it is possible to create functions with
optional arguments. I have a function in Gap whose definition starts
like that:
  regularPermutationAction := function(G)
local gens, N, S, L, gg, forceDefiningGenerators;
forceDefiningGenerators := ValueOption("forceDefiningGenerators");
...

In GAP syntax, having a group G, I would call the function as follows:
   P := regularPermutationAction(G: forceDefiningGenerators);;

How would I call it when G is defined in libgap?
   G.regularPermutationAction(forceDefiningGenerators=True)
doesn't work.


C) Make it possible to refer to an libgap object in a command string

In gap (the pexpect interface), in the example from B), I'd do
   P = gap('regularPermutationAction({}: 
forceDefiningGenerators)'.format(G.name()))
and in the example from A), I'd do
   gap('{}.1'.format(G.name()))
but libgap objects apparently have no name by which they are known in
the libgap interpreter.

---
D) libgap's and gap's methods should have roughly similar semantics

It is really unfortunate that it hasn't been attempted
to keep libgap as close to the pexpect interface as possible. For
example:
1.  sage: libgap('SymmetricGroup(8)')
"SymmetricGroup(8)"
sage: type(_)

sage: gap.eval('SymmetricGroup(8)')
'Sym( [ 1 .. 8 ] )'
sage: type(_)

  In other words, libgap() behaves roughly like gap.eval()
2.  sage: libgap.eval('SymmetricGroup(8)')
Sym( [ 1 .. 8 ] )
sage: gap('SymmetricGroup(8)')
SymmetricGroup( [ 1 .. 8 ] )
  In other words, libgap.eval() behaves roughly like gap()

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Accessing group generators in libgap

2018-09-29 Thread Simon King
Here is another question on libgap: Let some libgap elements be given;
how to form the list of these elements in libgap? The purpose would, for
example, be to create a group from that list.

For instance:
sage: G = gap.SmallGroup(48,36)
sage: g1,g2,g3,g4,g5 = G.GeneratorsOfGroup()

Since G is a polycyclic group, its generators look not very informative,
but in any case they are valid elements in libgap:

sage: g1*g2,g1*g2*g3,g4
(f1*f2, f1*f2*f3, f4)

Nonetheless, the following doesn't work:

sage: libgap.List(g1*g2,g1*g2*g3,g4)
Traceback (most recent call last):
...
ValueError: libGAP: Error, Variable: 'f1' must have a value

What to do instead?

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Accessing group generators in libgap

2018-09-29 Thread Simon King
Hi!

Define
  sage: G = libgap.eval('Group([(3,4,5,6,7,8,9,10),(1,2)])')

(By the way, why does libgap.Group([(3,4,5,6,7,8,9,10),(1,2)]) not
work?)

In Gap, also in gap-via-pexpect, one can access the i-th generator of a
group (the count starts with 1) in the form G.i, but unfortunately this
doesn't work in libgap:
  sage: G.1
  Traceback (most recent call last):
  ...
  AttributeError: name "gen" is not defined in GAP.

Explanation: Sage's preparser translates G.1 into G.gen(1), but libgap
doesn't know about gen. Apparently there is gap.gen defined, but not
libgap.gen.

(By the way: gap.gen?? behaves very strange, it shows the documentation
of chapter 7 entitled "Domains" of gap's documentation, and I need to
quit the viewer THREE TIMES to leave the documentation, and then I see
the documentation of the class GapFunction.)

Question 1: Is there an elegant way to access the first generator of G
than G.GeneratorsOfGroup()[0]?

Question 2: Do you think it would be a good idea to provide a libgap.gen
function, so that G.1 would return the first generator of G?

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Problem with Sage's pexpect interface to Gap

2018-09-29 Thread Simon King
Hi Dima,

On 2018-09-29, Dima Pasechnik  wrote:
> How many (single) cosets are you talking about?
> Once you have a permutation representation, these double coset
> computations are very fast.
> I am almost sure GAP first enumerates (single) cosets, anyway.

There are 7 double cosets, but G.Order()/N.Order() is 170775.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Problem with Sage's pexpect interface to Gap

2018-09-29 Thread Simon King
Hi Dima,

On 2018-09-29, Dima Pasechnik  wrote:
> I believe making libGAP the default GAP interface is the way to go, and
> much of the work needed for this conversion is already done...
>
> libgap's GAP objects are just thin cython wrappers around GAP's objects in
> memory.
> So you basically need to send to libgap a complete valid GAP statement
> defining G.

Sure. I was afraid that in some situations I'd need to convert from
gap-pexpect to libgap (e.g., when unpickling cohomology rings that I've
computed in the past). However, unpickling of gap stuff is done in a
custom way anyway -- so, in my unpickling functions I could simply
replace gap by libgap.

It is some work, but hopefully worth-while to do.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Problem with Sage's pexpect interface to Gap

2018-09-29 Thread Simon King
Hi Dima,

On 2018-09-29, Dima Pasechnik  wrote:
> On Sat, Sep 29, 2018 at 9:58 AM Simon King  wrote:
>>
>> On 2018-09-29, Simon King  wrote:
>> > Too bad: When the error occurs and I adjust the pool size then
>> > afterwards the previously defined objects in gap are gone.
>>
>> Additional problem: Even when I increase the memory limit sufficiently,
>> gap-via-pexpect takes substantially longer than libgap to compute the
>> double cosets. Why is that? There shouldn't be big traffic in the
>> interface whan just doing DC = G.DoubleCosetRepsAndSizes(N,N).
>
> Just use libGAP, perhaps?
> (and do the port of the corresponding functionality to libGAP, if you have 
> time)

Rewriting my whole p_group_cohomology package to libGAP would be work
that I'd rather avoid.

Given a group defined in gap-via-pexpect, how to put it into libGAP?
Slight complication: My groups come with a name. Hence, the string
representation of the group is not good, libGAP doesn't understand it:

  sage: G = gap.SymmetricGroup(6)
  sage: G.SetName('"G"')
  sage: libgap.eval(G)
  ...
  ValueError: libGAP: Error, Variable: 'G' must have a value

So, how can I make gap produce data that allow to reconstruct the group?
Is libgap.Group(G.GeneratorsOfGroup()) the way to go? For permutation
groups probably it is. But for polycyclic groups, as provided by the
SmallGroups library?
  sage: G = gap.SmallGroup(720,761)
  sage: G
  Group( [ f1, f2, f3, f4, f5, f6, f7 ] )
  sage: libgap.Group(G.GeneratorsOfGroup())
  ...
  ValueError: libGAP: Error, Variable: 'f1' must have a value

Concerning your hint to use the ACE package: After installing
gap_packages, DC = G.DoubleCosetRepsAndSizes(N,N) takes a very long
time in gap-via-pexpect (much longer than with libGAP), but so far it
didn't crash. But it is VERY long. So, rewriting everything to
libGAP might be the way to go after all. Sigh. Will be tedious work...

Worse: It seems to me that after installing gap_packages, libgap takes
long as well.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Problem with Sage's pexpect interface to Gap

2018-09-29 Thread Simon King
Hi Dima,

On 2018-09-29, Dima Pasechnik  wrote:
> There is no real harm in doing
> set_gap_memory_pool_size(10*get_gap_memory_pool_size())

Yes, there is (see my other post). The computation takes much much
longer than in libgap.

> If coset enumeration is the bottleneck, you should not use GAP's
> built-in one, by use the one in ACE GAP package,
> it is much faster and efficient with memory etc.

Is ACE part of the gap_packages spkg? If so: How to use its double coset
unumerator? Note that it is really about DOUBLE cosets. The cosets are
of no real use here.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Problem with Sage's pexpect interface to Gap

2018-09-29 Thread Simon King
On 2018-09-29, Simon King  wrote:
> Too bad: When the error occurs and I adjust the pool size then
> afterwards the previously defined objects in gap are gone.

Additional problem: Even when I increase the memory limit sufficiently,
gap-via-pexpect takes substantially longer than libgap to compute the
double cosets. Why is that? There shouldn't be big traffic in the
interface whan just doing DC = G.DoubleCosetRepsAndSizes(N,N).

Cheers,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Problem with Sage's pexpect interface to Gap

2018-09-29 Thread Simon King
Hi Dima,

On 2018-09-29, Simon King  wrote:
> Anyway, using set_gap_memory_pool_size(2*get_gap_memory_pool_size())
> till everything works sounds like a reasonable way out.

Too bad: When the error occurs and I adjust the pool size then
afterwards the previously defined objects in gap are gone.

So, is it possible to adjust the pool size dynamically *without* the
need to repeat all computations in Gap from scratch?

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Problem with Sage's pexpect interface to Gap

2018-09-29 Thread Simon King
Hi Dima,

On 2018-09-29, Dima Pasechnik  wrote:
> set_gap_memory_pool_size()
> controls the amount of memory GAP and libGAP get if started from Sage.
> The latter is dynamic, as opposed to "sage --gap"

Do I understand correctly: libgap has dynamic pool size, but
gap-via-pexpect has not? That would explain why libgap can do what
gap-via-pexpect can't. But why does my computation work in "sage -gap",
but not in gap-via-pexpect?

Anyway, using set_gap_memory_pool_size(2*get_gap_memory_pool_size())
till everything works sounds like a reasonable way out.

Thanks and best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Problem with Sage's pexpect interface to Gap

2018-09-29 Thread Simon King
PS:

I just found that libgap is able to compute the double coset
representatives, whereas gap-via-pexpect isn't. So, this might be a way
out, in the sense that I would need to change many lines of code from
gap to libgap, which is not just copy-and-paste, since apparently
gap('foo') corresponds to libgap.eval('foo'), not to libgap('foo').

My preferred solution, however, would be to enable gap-via-pexpect. How?

Best regards,
Simon

On 2018-09-29, Simon King  wrote:
> Hi!
>
> Let G be the third Conway group, S its Sylow 2-subgroup, and
> N the normaliser of the centre of S in G.
>
> Gap is able to compute the list of double coset representatives of N in
> G using the command
> gap> DC := DoubleCosetRepsAndSizes(G,N,N);;
> gap> Length(DC);
> 7
> Actually, if I understand correctly, DC is not a list but an iterator,
> but for a list of size 7 this shouldn't matter so much.
>
> Anyway. If I do the above computation in the Sage pexpect interface to
> gap, the line
> DC = G.DoubleCosetRepsAndSizes(N,N)
> gives an error:
> RuntimeError: Gap produced error output
> Error, reached the pre-set memory limit
> (change it with the -o command line option)
>
>executing
>
> __SAGE_LAST__:="__SAGE_LAST__";;DoubleCosetRepsAndSizes(\$sage1,\$sage8,\$sage8);;
>
>
> If I recall correctly, the above worked fine a couple of years ago, when
> I achieved the first computation of the mod-2 cohomology of the third
> Conway group.
>
> So, what has changed? Is the memory limit for gap-via-pexpect different
> from the memory limit of "sage -gap"? Has that memory limit changed in
> the past years? How can I work around (i.e., set the memory limit of
> gap-via-pexpect to the apparently sufficient memory limit used by "sage
> -gap")?
>
> Best regards,
> Simon
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Problem with Sage's pexpect interface to Gap

2018-09-29 Thread Simon King
Hi!

Let G be the third Conway group, S its Sylow 2-subgroup, and
N the normaliser of the centre of S in G.

Gap is able to compute the list of double coset representatives of N in
G using the command
gap> DC := DoubleCosetRepsAndSizes(G,N,N);;
gap> Length(DC);
7
Actually, if I understand correctly, DC is not a list but an iterator,
but for a list of size 7 this shouldn't matter so much.

Anyway. If I do the above computation in the Sage pexpect interface to
gap, the line
DC = G.DoubleCosetRepsAndSizes(N,N)
gives an error:
RuntimeError: Gap produced error output
Error, reached the pre-set memory limit
(change it with the -o command line option)

   executing
   
__SAGE_LAST__:="__SAGE_LAST__";;DoubleCosetRepsAndSizes(\$sage1,\$sage8,\$sage8);;


If I recall correctly, the above worked fine a couple of years ago, when
I achieved the first computation of the mod-2 cohomology of the third
Conway group.

So, what has changed? Is the memory limit for gap-via-pexpect different
from the memory limit of "sage -gap"? Has that memory limit changed in
the past years? How can I work around (i.e., set the memory limit of
gap-via-pexpect to the apparently sufficient memory limit used by "sage
-gap")?

Best regards,
Simon


-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: solving equations with parameters

2018-08-13 Thread Simon King
Hi Dominique,

On 2018-08-13, Dominique Laurain  wrote:
> PS : use asksagemath.org 

-1!

There are people (I, for instance) who hate the guts of
ask.sagemath.org. Seriously, I find the whole system of badges and tags
and colourful symbols and embedded editors both distracting and
discouraging. I regularly have a look at sage-support, but haven't been
on ask.sagemath.org in the last couple of years.

While it is OK to keep ask.sagemath.org running, I find it very wrong to
forward people to ask.sagemath.org when they ask a question on
sage-support (which clearly is *a* port for those seeking help).

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Can a module suddenly disappear?

2018-07-30 Thread Simon King
Sorry for the noise.

Apparently one needs to import Matrix_gfpn_dense first, which is what
the cohomology module does.

Still, random_matrix(GF(5),20,implementation='meataxe') should work, but
it doesn't. And so doesn't
MatrixSpace(GF(5),4,implementation='meataxe'). I guess I'll open a
ticket for it.

Best regards,
Simon

On 2018-07-30, Simon King  wrote:
>
> To add to my confusion:
>
> I also have p_group_cohomology installed, which makes extensive use of
> matrix_gfpn_dense. And it still works. More precisely, when I import
> something from the cohomology package, then suddenly the
> matrix_gfpn_dense module becomes available:
>
> sage: M = 
> random_matrix(GF(5),20,implementation=sage.matrix.matrix_gfpn_dense.Matrix_gfpn_dense)
> ---
> AttributeErrorTraceback (most recent call
> last)
> in ()
> > 1 M =
> random_matrix(GF(Integer(5)),Integer(20),implementation=sage.matrix.matrix_gfpn_dense.Matrix_gfpn_dense)
>
> AttributeError: 'module' object has no attribute 'matrix_gfpn_dense'
> sage: from pGroupCohomology import CohomologyRing
> sage: M = 
> random_matrix(GF(5),20,implementation=sage.matrix.matrix_gfpn_dense.Matrix_gfpn_dense)
> sage: type(M)
>
>
> So, what the heck is going on there?
>
> Best regards,
> Simon
>
> On 2018-07-30, Simon King  wrote:
>> Hi!
>>
>> I just met a quite troublesome problem: I have MeatAxe installed in
>> Sage, and thus the optional extension sage.matrix.matrix_gfpn_dense was
>> available - till 30 minutes ago (I am sure that it was available, as I
>> did some timings with it).
>>
>> Suddenly, after restarting Sage, the module has gone, it cannot be
>> imported. I tried "sage -i meataxe" (which told me that meataxe was
>> installed already), then "sage -f meataxe" (which did re-install
>> meataxe) followed by "touch src/sage/matrix/matrix_gfpn_dense.pxd",
>> followed by "sage -br", which *did* recompile 
>> src/sage/matrix/matrix_gfpn_dense.pyx
>> -- but still I cannot import the resulting module.
>>
>> So, what has happened? I am totally puzzled now.
>>
>> Best regards,
>> Simon
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Can a module suddenly disappear?

2018-07-30 Thread Simon King


To add to my confusion:

I also have p_group_cohomology installed, which makes extensive use of
matrix_gfpn_dense. And it still works. More precisely, when I import
something from the cohomology package, then suddenly the
matrix_gfpn_dense module becomes available:

sage: M = 
random_matrix(GF(5),20,implementation=sage.matrix.matrix_gfpn_dense.Matrix_gfpn_dense)
---
AttributeErrorTraceback (most recent call
last)
 in ()
> 1 M =
random_matrix(GF(Integer(5)),Integer(20),implementation=sage.matrix.matrix_gfpn_dense.Matrix_gfpn_dense)

AttributeError: 'module' object has no attribute 'matrix_gfpn_dense'
sage: from pGroupCohomology import CohomologyRing
sage: M = 
random_matrix(GF(5),20,implementation=sage.matrix.matrix_gfpn_dense.Matrix_gfpn_dense)
sage: type(M)


So, what the heck is going on there?

Best regards,
Simon

On 2018-07-30, Simon King  wrote:
> Hi!
>
> I just met a quite troublesome problem: I have MeatAxe installed in
> Sage, and thus the optional extension sage.matrix.matrix_gfpn_dense was
> available - till 30 minutes ago (I am sure that it was available, as I
> did some timings with it).
>
> Suddenly, after restarting Sage, the module has gone, it cannot be
> imported. I tried "sage -i meataxe" (which told me that meataxe was
> installed already), then "sage -f meataxe" (which did re-install
> meataxe) followed by "touch src/sage/matrix/matrix_gfpn_dense.pxd",
> followed by "sage -br", which *did* recompile 
> src/sage/matrix/matrix_gfpn_dense.pyx
> -- but still I cannot import the resulting module.
>
> So, what has happened? I am totally puzzled now.
>
> Best regards,
> Simon
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Can a module suddenly disappear?

2018-07-30 Thread Simon King
Hi!

I just met a quite troublesome problem: I have MeatAxe installed in
Sage, and thus the optional extension sage.matrix.matrix_gfpn_dense was
available - till 30 minutes ago (I am sure that it was available, as I
did some timings with it).

Suddenly, after restarting Sage, the module has gone, it cannot be
imported. I tried "sage -i meataxe" (which told me that meataxe was
installed already), then "sage -f meataxe" (which did re-install
meataxe) followed by "touch src/sage/matrix/matrix_gfpn_dense.pxd",
followed by "sage -br", which *did* recompile 
src/sage/matrix/matrix_gfpn_dense.pyx
-- but still I cannot import the resulting module.

So, what has happened? I am totally puzzled now.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: problems installing sage on ubuntu 18.04

2018-07-27 Thread Simon King
Hi Rudolf,

On 2018-07-26, rudolf ordoyne  wrote:
> my guess is that i'm unable to install sage since the most recent release 
> of sage is for 16.04.  after unpacking the .tar, running "sudo ./sage" 
> gives "sudo: ./sage: command not found"

What exact tar ball are you talking about? If you did change into the
directory that untar-ing created (perhaps you forgot "cd "?), then ./sage should definitely be available.

If it is not, then perhaps you didn't get a Sage binary but a Sage
*source* tar ball, in which case (again after cd-ing into the new
directory) you could create your own version of Sage (if the
prerequisites are installed in you computer, then "make" and a long
coffee break are enough).

Moreover, "sudo" is definitely not needed to run Sage, and I think is
even adviced against.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Parallel computation in Sage

2018-07-16 Thread Simon King
PS: I don't know if `algorithm='padic'` would use a parallel computation. 
It would certainly make sense.

Am Montag, 16. Juli 2018 18:08:07 UTC+2 schrieb Simon King:
>
> Hi Chandra,
>
> Am Montag, 16. Juli 2018 07:33:03 UTC+2 schrieb chandra chowdhury:
>>
>> I want to calculate the determinant of a large matrix 
>> with large entries. So it is taking time. In my machine,
>> I have 32 CPUs. Is it possible in Sage to use all CPUs
>> parallelly to find the determinant? 
>>
>
> You said in another post that you're working over the integers. So, you 
> could try a multi-modular approach.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Parallel computation in Sage

2018-07-16 Thread Simon King
Hi Chandra,

Am Montag, 16. Juli 2018 07:33:03 UTC+2 schrieb chandra chowdhury:
>
> I want to calculate the determinant of a large matrix 
> with large entries. So it is taking time. In my machine,
> I have 32 CPUs. Is it possible in Sage to use all CPUs
> parallelly to find the determinant? 
>

You said in another post that you're working over the integers. So, you 
could try a multi-modular approach.

If M is your matrix over the integers, then the documentation of 
M.determinant tells you that you can use M.determinant(algorithm='padic', 
proof=True)
(or proof=False).

Example:

sage: M = random_matrix(ZZ,1000)
sage: %time d2 = M.determinant(algorithm='padic')
CPU times: user 25.5 s, sys: 484 ms, total: 25.9 s
Wall time: 26.1 s
sage: M._cache.clear()
sage: %time d3 = M.determinant()
CPU times: user 10.2 s, sys: 0 ns, total: 10.2 s
Wall time: 10.2 s
sage: M._cache.clear()
sage: %time d4 = M.determinant(algorithm='padic', proof=True)
CPU times: user 25.6 s, sys: 464 ms, total: 26.1 s
Wall time: 26.1 s
sage: d2 == d3 == d4
True

So, at least in this case, the multi modular algoirthm is slower than the 
default algorithm (which uses Flint). But perhaps it helps in your case.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Problem in new Sage version

2018-07-10 Thread Simon King
On 2018-07-10, slelievre  wrote:
> you have the choice between the following:
>
> sage: V = PolynomialRing(GF(2), 49, xxz)
> ...
> sage: V = BooleanPolynomialRing(49, xxz)

I think that's a very dangerous statement, as the boolean polynomial
ring is a *quotient* of the above polynomial ring: In addition to using
coefficients in GF(2), it hard-codes the relation x^2=x for all
variables x:
  sage: R. = BooleanPolynomialRing()
  sage: u^2
  u
  sage: 2*u
  0

So, just to be on the safe side: The choice you mention is between very
different rings.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Cython in jupyter notebook

2018-04-15 Thread Simon King
Hi Nils,

On 2018-04-15, Nils Bruin  wrote:
> The quickest workaround for now is to just eliminate the whole error 
> redirection. We didn't have it before either. If you have control over the 
> distribution you use to teach, that might get you through your lecture.

Indeed I'll just use the Sage installation on my laptop.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Cython in jupyter notebook

2018-04-15 Thread Simon King
Hi Nils,

On 2018-04-15, Nils Bruin  wrote:
> ...
> where this code was committed:
>
> try:
> # Capture errors from distutils and its child processes
> with open(os.path.join(target_dir, name + ".err"), 'w+') as errfile:
> try:
> with redirection(sys.stderr, errfile, close=False):
> dist.run_command("build")
> finally:
> errfile.seek(0)
> distutils_messages = errfile.read()
> except Exception as msg:
> msg = str(msg) + "\n" + distutils_messages
> raise RuntimeError(msg.strip())

Thank you! I'll try to undo that commit till the exercise group is
done...

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Cython in jupyter notebook

2018-04-15 Thread Simon King
Hi!

The following cython code compiles fine in SageMath command line version
and it *used* to compile fine in the jupyter notebook one year ago:

 cython("""
 def mantisse():
 cdef double a = 1
 cdef double b = 2
 cdef int i = 0
 while True:
 a += b**(-i)
 print("%2d: %.53f"%(i,a))
 if a==1:
 return i-1
 i += 1
 a = 1
 """)

However, in the jupyter notebook I no get the error

RuntimeError  Traceback (most recent call last)
 in ()
 12 i += 1
 13 a = 1
---> 14 """)

/home/king/Sage/git/sage/local/lib/python2.7/site-packages/sage/misc/lazy_import.pyx
 in sage.misc.lazy_import.LazyImport.__call__ 
(build/cythonized/sage/misc/lazy_import.c:3756)()
352 True
353 """
--> 354 return self.get_object()(*args, **kwds)
355 
356 def __repr__(self):

/home/king/Sage/git/sage/local/lib/python2.7/site-packages/sage/misc/cython.pyc 
in cython_compile(code, **kwds)
   1005 with open(tmpfile,'w') as f:
   1006 f.write(code)
-> 1007 return cython_import_all(tmpfile, get_globals(), **kwds)

/home/king/Sage/git/sage/local/lib/python2.7/site-packages/sage/misc/cython.pyc 
in cython_import_all(filename, globals, **kwds)
895   code
896 """
--> 897 m = cython_import(filename, **kwds)
898 for k, x in iteritems(m.__dict__):
899 if k[0] != '_':

/home/king/Sage/git/sage/local/lib/python2.7/site-packages/sage/misc/cython.pyc 
in cython_import(filename, **kwds)
870 - the module that contains the compiled Cython code.
871 """
--> 872 name, build_dir = cython(filename, **kwds)
873 
874 oldpath = sys.path

/home/king/Sage/git/sage/local/lib/python2.7/site-packages/sage/misc/cython.pyc 
in cython(filename, verbose, compile_message, use_cache, create_local_c_file, 
annotate, sage_namespace, create_local_so_file)
669 except Exception as msg:
670 msg = str(msg) + "\n" + distutils_messages
--> 671 raise RuntimeError(msg.strip())
672 
673 if verbose >= 0:

RuntimeError: fileno

What goes wrong?

I'd like to have it solved till the day after tomorrow, as the notebook
is to be used in some exercise group.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Graph canonical form directly on matrices

2018-03-07 Thread Simon King
Dear Christian,

On 2018-03-07, Christian Stump  wrote:
> Anyway, looking at sage/graphs/bliss.pyx, it seems easy to modify your 
>> code to directly create a bliss graph.
>>
>
> Help there is highly appreciated :-), I don't know how to do that 
> appropriately...

Just have a look at sage/graphs/bliss.pyx. Apparently it uses c++, so,
that needs to be taken into account when cythoning and compiling. See
module_list.py, where it says:
OptionalExtension("sage.graphs.bliss",
  ["sage/graphs/bliss.pyx"],
  language = "c++",
  libraries = ['bliss'],
  package = 'bliss'),

Apparently, it is then

  cdef Digraph *g = new Digraph(order)

to create a Digraph with a given number of vertices (which are always
numbered in range(order)), and then an edge from v1 to v2 is added like
this:

  g.add_edge(v1,v2)

In your code you basically do the same. Only problem: It seems that
you need to provide the number of vertices during initialisation of g.
But in your code, you add more vertices on the fly, IIRC. But this can
certainly be solved.

Best regards,
Simon


-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Graph canonical form directly on matrices

2018-03-07 Thread Simon King
On 2018-03-07, Dima Pasechnik  wrote:
> Ultimately, the classical canonical form/isomorphism implementations run on 
> (di)graphs represented by 0-1 matrices, often
> with bit entries. So that's how bliss_digraph is represented too.
> Constructing it directly might be beneficial, especially if you have a 
> problem of doing this on many small matrices

For the record: I guess one should then at least provide a
sage/graphs/bliss.pxd header, or better: Move those parts of
sage/graphs/bliss.pyx that are merely library bindings to
sage/libs/bliss.*

Anyway, looking at sage/graphs/bliss.pyx, it seems easy to modify your
code to directly create a bliss graph.

Cheers,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Graph canonical form directly on matrices

2018-03-06 Thread Simon King
PS:

On 2018-03-06, Simon King <simon.k...@uni-jena.de> wrote:
> On 2018-03-06, Christian Stump <christian.st...@gmail.com> wrote:
> I haven't really been able to work around the bottle neck, but got a
> minor improvement (4%) as follows:
> ...
> And of course using cython helps as well. With the following Cython code, I am
> down to 272 µs per loop, while your original Python code gave me 325 µs
> per loop:

Sorry for having been unclear. Your original code gave 339 µs, my code in python
gave 325 µs (that's 4% improvement), and my code in cython is of course
still faster (that's 272 µs, thus almost 20% improvement in total).

Cheers,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: creating regular representation for the quotient ring over a 0-dimensional ideal

2018-03-04 Thread Simon King
Hi Dima,

On 2018-03-05, Dima Pasechnik  wrote:
> I need to do computations with matrices representing elements of the 
> quotient ring A of a polynomial ring k[x1,...,xn] modulo a 0-dimensional 
> ideal.
> I don't seem to find such basic functionality as constructing these 
> matrices implemented. 
>
> It is of course easy, once you have a Groebner basis; from this you can 
> find a basis of the regular representation of A as
> "monomials under the staircase" (i.e. all the monomials occurring in the 
> Groebner basis elements on the non-leading positions),
> and compute matrices representing multiplication of variables x1,..., xn 
> with these elements, my question is whether this is already
> implemented in Sage.

Not to my knowledge. I had to do similar things and was missing that
functionality, too. Actually not just for polynomial rings but for
non-commutative versions thereof.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Find_root not finding a root

2018-03-01 Thread Simon King
Hi Khalid,

On 2018-03-02, saad khalid  wrote:
> I'm running this code:
> find_root(e^(-2*x*1)-(1 - 4*x),-2,2)
>
> It returns 
>
> 2.4011774461136836e-13
>
> which is approximately 0. However, there should be another root around x = 
> -0.628. Why isn't it finding this root? 
> Is there any way I can make sure it finds all of them?

I suppose you know that in Python (which is the underlying language 
of SageMath), you can access the documenation of an object by putting a
question mark after it. So, do

   sage: find_root?

and you can read:
   Numerically find a root of "f" on the closed interval [a,b] (or
   [b,a]) if possible, where "f" is a function in the one variable.
   Note: this function only works in fixed (machine) precision, it is
   not possible to get arbitrary precision approximations with it.

So, it says *a* root, not *all* roots. The solution returned above
obviously is in the given intervall, and so SageMath's answer complies
with the specification.

If you want other solutions, you need to provide a smaller intervall:

   sage: f(x) = e^(-2*x*1)-(1-4*x)
   sage: find_root(f, -1,0)
   0.0
   sage: f(x=0)
   0
   
--> one gets yet another solution, the intervall is still too large. Again
smaller:

   sage: find_root(f, -1,-0.5)
   -0.6282156043130847
   sage: f(x=_)
   -4.440892098500626e-16

And that was what you were looking for.

Best regards,
Simon


-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Is this a bug?

2018-02-28 Thread Simon King
On 2018-02-28, Ralf Stephan  wrote:
> On Wednesday, February 28, 2018 at 9:09:04 AM UTC+1, Dima Pasechnik wrote:
>>
>> I would be for dropping 'x' as the only "default" variable (defined at 
>> start time).
>>
>
> I agree but does it solve the problem I demonstrated. Can you then add x to 
> the minpoly?

If you define x as the variable of the minpoly, then certainly you can.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Is this a bug?

2018-02-28 Thread Simon King
Hi Ralf,

On 2018-02-28, Ralf Stephan  wrote:
> The reason is apparently that the polynomial ring was not created by the 
> user on the command line but by the charpoly() code.

The parent of the pre-defined variable x wasn't created by the user
either, so, please don't blame polynomial rings or the
minpoly()/charpoly() code for it.

 sage: QQbar(sqrt(2)).minpoly().parent()
 Univariate Polynomial Ring in x over Rational Field
 sage: x.parent()
 Symbolic Ring


> i would consider this a high priority bug. Is there a ticket?

Not in the way you think, IMHO.

One problem that I see is the fact that it is possible to create rings
in which one variable name occurs twice, such as here:
  sage: RR['x']['x']
  Univariate Polynomial Ring in x over Univariate Polynomial Ring in x
  over Real Field with 53 bits of precision
  sage: RR['x'].gen()-RR['x']['x'].gen()
  -x + x
  sage: _==0
  False

So, we have two x with different roles. It would make sense to disallow
the creation of such rings.

Also, I belive it is a bug that x is pre-defined as a symbolic variable;
we should finally drop that pseudo-courtesy. Users mistake FAR too often
symbolics with polynomials; by pre-defining x, we let the users believe
that x is good for *all* computations. So, I believe it would be better
to let the user create x him/herself, for the specific application that
he/she has in mind. However, I am aware that I belong to a minority with
that opinion.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] How to get special values of arccos

2018-02-26 Thread Simon King
Hi!

SageMath knows a couple of special values for the cosine function, such
as
  sage: cos(pi/8)
  1/2*sqrt(sqrt(2) + 2)

However, SageMath's knowledge of special values of the arccos function
seems a lot more limited:
  sage: arccos(_)
  arccos(1/2*sqrt(sqrt(2) + 2))
  sage: arccos(1/2)
  1/3*pi

Question: How can one get the exact value of arccos(1/2*sqrt(sqrt(2) + 2))
(which is pi/8)? I tried .simplify_full() and so on, but to no avail.

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: Fwd: Re: Re: numpy

2018-01-09 Thread Simon King
Hi,

On 2018-01-09, Girard Henri  wrote:
> Am 09.01.2018 um 12:18 schrieb Girard Henri:
>> An exemple
>>
>> from matplotlib import pyplot as plt
>> from scipy.io import wavfile
>> import numpy as np
>> samplerate,data=wavfile.read("test.wav")
>> times=np.arange(len(data))/float(samplerate)
>> plt.plot(data[:1000])

What exactly goes wrong if you do the above in Sage? Please be more
specific.

In another message to me, you wrote:
> Most of the time I don't want to make heavier "import"... First because
> I don't master it and it's much better to do sqrt() instead np.sqrt() or
> np.pi()

I don't see why sqrt() is better than np.sqrt().

Anyway, as usual in Python, you can import functions like this:
  sage: from numpy import sqrt
  sage: sqrt
  
  sage: sqrt(4)
  2.0
  sage: type(_)
  

The disadvantage is that it overwrites Sage's sqrt() function. That's why
I believe it is better to do np.sqrt().

Best regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] Re: numpy

2018-01-09 Thread Simon King
Hi,

On 2018-01-09, Girard Henri  wrote:
> I would like to know how to make this command numpy :
>
> import numpy as np
>
> times=np.arange ?

What do you mean by "make this command"? numpy is included in SageMath.
Therefore,
  import numpy as np
  times = np.arange
just works.

Regards,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


  1   2   3   4   5   6   7   8   9   10   >