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

2018-11-19 Thread Peter Luschny
You say: "hijack vs shut up, which one is more serious?  Accusing 
someone hijacking something is a very serious accusation."

I certainly didn't mean it as a 'very serious accusation' like
hijacking people or planes. I used the term "hijacked" as a 
technical term like it is defined in the urban dictionary: 

https://www.urbandictionary.com/define.php?term=Thread%20Hijacking

I'm sorry if it reached you differently, in a stronger sense. 

You say: "And not a completely different topic." 

I deny this. It didn't add anything to the topic. My question 
was excellently answered, and in all your posts and those of 
the experts not the slightest new information has been added 
to the original question. Why? Because you have a completely
different topic. In your own words:

"Hi, I’m trying to translate this Sage syntax to Python syntax 
Do you think it is realistic to use sage as a Python library 
and completely not using sage (as an interpreter) itself?"

Does this has anything to do with the question of how to 
calculate efficiently with the Quaternion algebra?

In your own words, a recommendation you gave above to someone 
who wanted to help you:

"But if you're reading carefully this isn't what I'm asking."

-- 
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 HG
sage-support is one of the best list. English is not my mother language and 
sometimes I don't explain myself well but always people here are very kind 
and trying to help... It's very important this can long !

Le vendredi 14 septembre 2018 18:00:55 UTC+2, Peter Luschny a écrit :
>
> How can I speed up this computation?
>
> H. = QuaternionAlgebra(SR, -1, -1)
> def Q(a, b, c, d): return H(a + b*i + c*j + d*k)
> def P(n): return Q(x+1,1,1,1)*P(n-1) if n > 0 else Q(1,0,0,0)
> def p(n): return P(n)[0].list()
> for n in (0..20): print [n], p(n)
>
> [0] [1]
> [1] [1, 1]
> [2] [-2, 2, 1]
> [3] [-8, -6, 3, 1]
> [4] [-8, -32, -12, 4, 1]
> [5] [16, -40, -80, -20, 5, 1]
> [6] [64, 96, -120, -160, -30, 6, 1]
> ...
>
> With Mathematica this takes 6 sec, with Sage it takes 
> hours, (in fact I interrupted after n=15). 
>
> Thanks, Peter
>
>
>

-- 
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.


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

2018-11-19 Thread John H Palmieri


On Monday, November 19, 2018 at 5:32:39 AM UTC-8, Kolen Cheung wrote:
>
> And if anyone has language issue it surely is OP. hijack vs shut up, which 
> one is more serious? Accusing someone hijacking something is a very serious 
> accusation.


Since you asked what kind of community this is, from 
https://wiki.sagemath.org/Community?action=show=CodeOfConduct 
(abridged):

>
> The Sage community is comprised of an international mixture of 
> mathematicians, 
> computer scientists, engineers, researchers, teachers, amateurs, and 
> others with varied backgrounds. This diversity is one of our strengths, 
> but it can also lead to communication problems and unhappiness. People 
> who love working on Sage can more effectively collaborate with others if 
> they follow this code. 
> 1) Be friendly and patient. 
>
> 2) Be welcoming.
>
> 3) Be considerate.
> 4) Be respectful and polite.
>

Telling someone to "shut up" and calling someone selfish do not adhere to 
these guidelines. Maybe accusing someone of hijacking also does not, but in 
any case, your response was not "friendly and patient" nor "welcoming", etc.

-- 
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.


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

2018-11-19 Thread John Cremona
On Mon, 19 Nov 2018 at 13:45, Dima Pasechnik  wrote:

>
>
> On Monday, November 19, 2018 at 1:14:38 PM UTC, Kolen Cheung wrote:
>>
>> "shut up" is language issue? You dont know whats bad language.
>
>
> I bet I can swear in more languages than you do: English, Russian, Dutch,
> German, Ukrainian, Polish, Yiddish, French, Italian...
> And when I worked in Singapore I even picked up some Hokkein and Tamil bad
> words, and other local words such as "ang moh" :-)
>
> So, yes, I do consider "shut up" rude. Please don't use it here.
>

Seconded (by a polite Englishman).


>
>
>
>
> --
> 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.


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

2018-11-19 Thread Dima Pasechnik


On Monday, November 19, 2018 at 1:14:38 PM UTC, Kolen Cheung wrote:
>
> "shut up" is language issue? You dont know whats bad language.


I bet I can swear in more languages than you do: English, Russian, Dutch, 
German, Ukrainian, Polish, Yiddish, French, Italian... 
And when I worked in Singapore I even picked up some Hokkein and Tamil bad 
words, and other local words such as "ang moh" :-)

So, yes, I do consider "shut up" rude. Please don't use it here.




-- 
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.


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

2018-11-19 Thread Kolen Cheung
And if anyone has language issue it surely is OP. hijack vs shut up, which one 
is more serious? Accusing someone hijacking something is a very serious 
accusation.

-- 
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.


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

2018-11-19 Thread Kolen Cheung
*can't

-- 
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.


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

2018-11-19 Thread Kolen Cheung
If one don't have an authority to dictate, why can't he told to be shut up? 
Instead ask him to continue to dictate? What kind of community is this?

-- 
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.


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

2018-11-19 Thread Kolen Cheung
Snd if someone say something trying to dictate what can or cannot be asked 
without backing up with an authority to dictate (such as a guideline), he 
should really shut up literally and I wonder why this is a 'language issue". 
Did you guys not literally means shut up when you say shut up? Do you guys use 
shut up as foul language like you don't mean it? (I wonder why guys will say 
f**k up to guys if they are not gay, you know, like they don't mean it.)

-- 
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.


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

2018-11-19 Thread Kolen Cheung
And do point out where's the guideline saying I can ask follow up questions 
like this.

-- 
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.


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

2018-11-19 Thread Kolen Cheung
Do ban me if you think "shut up" is language issue. It must be a joke.

-- 
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.


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

2018-11-19 Thread Kolen Cheung
How's your behavior so good? you are a selfish guy that only want to consumea 
others time and ask question and cannot stand people asking following up 
question on the same piece of code. You should really have shutted up and may 
be mark it as spam but not speak up.

-- 
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.


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

2018-11-19 Thread Kolen Cheung
"shut up" is language issue? You dont know whats bad language.

-- 
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.


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

2018-11-19 Thread Dima Pasechnik
On Mon, Nov 19, 2018 at 12:53 PM Kolen Cheung  wrote:
>
> And if anyone is dictating this, that one is surely not you, even if you're 
> the OP. Shut up.

Language!!! You might get banned for this...

>
> On Monday, November 19, 2018 at 4:43:44 AM UTC-8, Peter Luschny wrote:
>>
>> > Hi, I’m trying to translate this Sage syntax to Python syntax (i.e. using 
>> > sage as a Python library.) But I got stuck even on the first command.
>>
>> Why do you hijack this thread with a completely different topic?
>>
>> I'm sure that your question and the answers of the experts are of
>> interest to many, but they will not expect them under this subject.
>>
>> Please open in the future new threads for your questions!  Thanks!
>>
> --
> 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.


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

2018-11-19 Thread Peter Luschny
Kolen Cheung:
>
> And if anyone is dictating this, that one is surely not you, even if 
> you're the OP. Shut up.
>

You reconfirm the obvious, namely that you cannot behave. 


> On Monday, November 19, 2018 at 4:43:44 AM UTC-8, Peter Luschny wrote:
>>
>> > Hi, I’m trying to translate this Sage syntax to Python syntax (i.e. 
>> using sage as a Python library.) But I got stuck even on the first command.
>>
>> Why do you hijack this thread with a completely different topic?
>>
>> I'm sure that your question and the answers of the experts are of 
>> interest to many, but they will not expect them under this subject.
>>
>> Please open in the future new threads for your questions!  Thanks!
>>
>>

-- 
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.


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

2018-11-19 Thread Kolen Cheung
And if anyone is dictating this, that one is surely not you, even if you're 
the OP. Shut up.

On Monday, November 19, 2018 at 4:43:44 AM UTC-8, Peter Luschny wrote:
>
> > Hi, I’m trying to translate this Sage syntax to Python syntax (i.e. 
> using sage as a Python library.) But I got stuck even on the first command.
>
> Why do you hijack this thread with a completely different topic?
>
> I'm sure that your question and the answers of the experts are of 
> interest to many, but they will not expect them under this subject.
>
> Please open in the future new threads for your questions!  Thanks!
>
>

-- 
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.


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

2018-11-19 Thread Kolen Cheung
Because I use exactly the code shown here as an example. And I did open a 
thread posting a direct question on how to use sage as a library but the 
question is too general. So I figure I should use an example and so happen 
I saw this thread with an interesting example.

So this is not hijack. And not a completely different topic. The piece of 
code is exactly the same.

On Monday, November 19, 2018 at 4:43:44 AM UTC-8, Peter Luschny wrote:
>
> > Hi, I’m trying to translate this Sage syntax to Python syntax (i.e. 
> using sage as a Python library.) But I got stuck even on the first command.
>
> Why do you hijack this thread with a completely different topic?
>
> I'm sure that your question and the answers of the experts are of 
> interest to many, but they will not expect them under this subject.
>
> Please open in the future new threads for your questions!  Thanks!
>
>

-- 
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.


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

2018-11-19 Thread Peter Luschny
> Hi, I’m trying to translate this Sage syntax to Python syntax (i.e. using 
sage as a Python library.) But I got stuck even on the first command.

Why do you hijack this thread with a completely different topic?

I'm sure that your question and the answers of the experts are of 
interest to many, but they will not expect them under this subject.

Please open in the future new threads for your questions!  Thanks!

-- 
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.


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

2018-11-19 Thread Kolen Cheung
Thanks. This answer my question and I put the tip 
in https://groups.google.com/d/msg/sage-support/NFtI5XqjQWg/sz5WPcFMAgAJ

On Monday, November 19, 2018 at 3:58:50 AM UTC-8, John Cremona wrote:
>
> I recommend importing anything you need from sage.all since the details of 
> where everything is might change in time.  This works perfectly well:
>
> $ sage -python  # so we use Sage's python not my system-wide one
> Python 2.7.15 (default, Nov  2 2018, 14:32:42) 
> [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from sage.all import PolynomialRing, QQ
> >>> R = PolynomialRing(QQ,'x')
> >>> x = R.gen()
> >>> f = x^3+1 # no good as no preparser
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "sage/structure/element.pyx", line 944, in 
> sage.structure.element.Element.__xor__ 
> (build/cythonized/sage/structure/element.c:9006)
> RuntimeError: Use ** for exponentiation, not '^', which means xor
> in Python, and has the wrong precedence.
>
> # Now we can work with this:
>
> >>> f = x**3+1  # that's better
> >>> f.factor()
> (x + 1) * (x^2 - x + 1)
>
> Another thing I do is to put my commands into a .py file and run pyflakes 
> on it, as that reveals what things need to be imported.  Then import them 
> all from sage.all.
>
> John Cremona
>
> On Mon, 19 Nov 2018 at 11:48, Kolen Cheung  > wrote:
>
>> Thank you both for the answers. However, I’m still stuck:
>>
>> Focusing on just translating the first line: R. = QQ[]
>>
>> In sage,
>>
>> >>> preparse("R. = QQ[]")"R = QQ['x']; (x,) = R._first_ngens(1)">>> 
>> >>> import_statements(QQ)# ** Warning **: several names for that object: Q, 
>> >>> QQfrom sage.rings.rational_field import Q>>> import_statements(R)from 
>> >>> sage.rings.qqbar import QQx
>>
>> Immediately I have a question: how come the import_statements of QQ is ... 
>> import Q, and the import statement of R is ... import QQx? In either 
>> case the namespace in question is not imported. Does it mean ... import 
>> Q as QQ and ... import QQx as R respectively?
>>
>> Then I’ve a problem: In sage, I can import them using these import 
>> statements. But when entering these 2 import statements in Python,
>>
>> >>> from sage.rings.rational_field import Q
>> ---
>> ImportError   Traceback (most recent call last)
>>  in ()
>> > 1 from sage.rings.rational_field import Q
>>
>> /usr/lib/python2.7/site-packages/sage/rings/rational_field.py in ()
>>  62 _long_type = int
>>  63 
>> ---> 64 from .rational import Rational
>>  65 from .integer import Integer
>>  66 
>>
>> /usr/lib/python2.7/site-packages/sage/rings/rational.pyx in init 
>> sage.rings.rational (build/cythonized/sage/rings/rational.c:40976)()
>>  94 
>>  95 
>> ---> 96 import sage.rings.real_mpfr
>>  97 import sage.rings.real_double
>>  98 from libc.stdint cimport uint64_t
>>
>> /usr/lib/python2.7/site-packages/sage/rings/real_mpfr.pyx in init 
>> sage.rings.real_mpfr (build/cythonized/sage/rings/real_mpfr.c:44298)()
>> > 1 r"""
>>   2 Arbitrary Precision Real Numbers
>>   3 
>>   4 AUTHORS:
>>   5 
>>
>> /usr/lib/python2.7/site-packages/sage/rings/complex_number.pxd in init 
>> sage.libs.mpmath.utils (build/cythonized/sage/libs/mpmath/utils.c:8831)()
>>   4 from .real_mpfr cimport RealNumber
>>   5 
>> > 6 cdef class ComplexNumber(sage.structure.element.FieldElement):
>>   7 cdef mpfr_t __re
>>   8 cdef mpfr_t __im
>>
>> /usr/lib/python2.7/site-packages/sage/rings/complex_double.pxd in init 
>> sage.rings.complex_number 
>> (build/cythonized/sage/rings/complex_number.c:24212)()
>>   8 
>>   9 
>> ---> 10 cdef class ComplexDoubleField_class(sage.rings.ring.Field):
>>  11 pass
>>  12 
>>
>> /usr/lib/python2.7/site-packages/sage/rings/complex_double.pyx in init 
>> sage.rings.complex_double 
>> (build/cythonized/sage/rings/complex_double.c:24230)()
>>  96 from cypari2.convert cimport new_gen_from_double, 
>> new_t_COMPLEX_from_double
>>  97 
>> ---> 98 from . import complex_number
>>  99 
>> 100 from .complex_field import ComplexField
>>
>> ImportError: cannot import name complex_number
>> >>> from sage.rings.qqbar import QQx
>> ---
>> ImportError   Traceback (most recent call last)
>>  in ()
>> > 1 from sage.rings.qqbar import QQx
>>
>> /usr/lib/python2.7/site-packages/sage/rings/qqbar.py in ()
>> 512 rich_to_bool, richcmp_not_equal,
>> 513 op_EQ, op_NE)
>> --> 514 from sage.rings.real_mpfr import RR
>> 515 from sage.rings.real_mpfi import RealIntervalField, RIF, 
>> is_RealIntervalFieldElement, RealIntervalField_class
>> 516 from 

[sage-support] Re: Documentation on using sage as a library?

2018-11-19 Thread Kolen Cheung


Here’s the way to translate any Sage program to Python. From 
https://groups.google.com/d/msg/sage-support/ZtlmX3zE0b8/cdecLnbUAwAJ:

The key are these:

from sage.all import *
def sage_parse(expr):
'''exec a sage expression in globals
'''
expr_str = preparse(expr)
# print to show what's run
print(expr_str)
exec(expr_str, globals())

Example (taken from 
https://groups.google.com/d/msg/sage-support/ZtlmX3zE0b8/mqmG5KuiEgAJ):

Sage program:

R. = QQ[]
K = R.fraction_field()
H. = QuaternionAlgebra(K, -1, -1)def Q(a, b, c, d): return H(a + b*i + 
c*j + d*k)@cached_functiondef P(n):
return Q(x+1,1,1,1)*P(n-1) if n > 0 else Q(1,0,0,0)def p(n): return 
P(n)[0].numerator().list()for n in (0..20): print [n], p(n)

Python translation: (grey boxes are the stdouts)

from sage.all import *
def sage_parse(expr):
'''exec a sage expression in globals
'''
expr_str = preparse(expr)
# print to show what's run
print(expr_str)
exec(expr_str, globals())

sage_parse('R. = QQ[]')

R = QQ['x']; (x,) = R._first_ngens(1)

K = R.fraction_field()

sage_parse('H. = QuaternionAlgebra(K, -1, -1)')

H = QuaternionAlgebra(K, -Integer(1), -Integer(1), names=('i', 'j', 'k',)); (i, 
j, k,) = H._first_ngens(3)

def Q(a, b, c, d):
return H(a + b * i + c * j + d * k)

@cached_functiondef P(n):
return Q(x + 1, 1, 1, 1) * P(n - 1) if n > 0 else Q(1, 0, 0, 0)

def p(n):
return P(n)[0].numerator().list()

for n in range(21):
print [n], p(n)

[0] [1]
[1] [1, 1]
[2] [-2, 2, 1]
[3] [-8, -6, 3, 1]
[4] [-8, -32, -12, 4, 1]
[5] [16, -40, -80, -20, 5, 1]
[6] [64, 96, -120, -160, -30, 6, 1]
[7] [64, 448, 336, -280, -280, -42, 7, 1]
[8] [-128, 512, 1792, 896, -560, -448, -56, 8, 1]
[9] [-512, -1152, 2304, 5376, 2016, -1008, -672, -72, 9, 1]
[10] [-512, -5120, -5760, 7680, 13440, 4032, -1680, -960, -90, 10, 1]
[11] [1024, -5632, -28160, -21120, 21120, 29568, 7392, -2640, -1320, -110, 11, 
1]
[12] [4096, 12288, -33792, -112640, -63360, 50688, 59136, 12672, -3960, -1760, 
-132, 12, 1]
[13] [4096, 53248, 79872, -146432, -366080, -164736, 109824, 109824, 20592, 
-5720, -2288, -156, 13, 1]
[14] [-8192, 57344, 372736, 372736, -512512, -1025024, -384384, 219648, 192192, 
32032, -8008, -2912, -182, 14, 1]
[15] [-32768, -122880, 430080, 1863680, 1397760, -1537536, -2562560, -823680, 
411840, 320320, 48048, -10920, -3640, -210, 15, 1]
[16] [-32768, -524288, -983040, 2293760, 7454720, 4472832, -4100096, -5857280, 
-1647360, 732160, 512512, 69888, -14560, -4480, -240, 16, 1]
[17] [65536, -557056, -4456448, -5570560, 9748480, 25346048, 12673024, 
-9957376, -12446720, -3111680, 1244672, 792064, 99008, -19040, -5440, -272, 17, 
1]
[18] [262144, 1179648, -5013504, -26738688, -25067520, 35094528, 76038144, 
32587776, -22404096, -24893440, -5601024, 2036736, 1188096, 137088, -24480, 
-6528, -306, 18, 1]
[19] [262144, 4980736, 11206656, -31752192, -127008768, -95256576, 32672, 
206389248, 77395968, -47297536, -47297536, -9674496, 3224832, 1736448, 186048, 
-31008, -7752, -342, 19, 1]
[20] [-524288, 5242880, 49807360, 74711040, -158760960, -508035072, -317521920, 
317521920, 515973120, 171991040, -94595072, -85995520, -16124160, 4961280, 
2480640, 248064, -38760, -9120, -380, 20, 1]

Interested in adding this to the documentation / FAQ? It just wasn’t very 
clear in the FAQ.
​

-- 
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.


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

2018-11-19 Thread Kolen Cheung


I wonder why for me the result is

>>> import_statements(QQ)
# ** Warning **: several names for that object: Q, QQ from 
sage.rings.rational_field import Q

On Monday, November 19, 2018 at 4:05:55 AM UTC-8, Dima Pasechnik wrote:

On Mon, Nov 19, 2018 at 11:58 AM John Cremona  > wrote: 
> > 
> > I recommend importing anything you need from sage.all since the details 
> of where everything is might change in time.  This works perfectly well: 
> > 
> > $ sage -python  # so we use Sage's python not my system-wide one 
> > Python 2.7.15 (default, Nov  2 2018, 14:32:42) 
> > [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2 
> > Type "help", "copyright", "credits" or "license" for more information. 
> > >>> from sage.all import PolynomialRing, QQ 
> > >>> R = PolynomialRing(QQ,'x') 
> > >>> x = R.gen() 
> > >>> f = x^3+1 # no good as no preparser 
> > Traceback (most recent call last): 
> >   File "", line 1, in  
> >   File "sage/structure/element.pyx", line 944, in 
> sage.structure.element.Element.__xor__ 
> (build/cythonized/sage/structure/element.c:9006) 
> > RuntimeError: Use ** for exponentiation, not '^', which means xor 
> > in Python, and has the wrong precedence. 
> > 
> > # Now we can work with this: 
> > 
> > >>> f = x**3+1  # that's better 
> > >>> f.factor() 
> > (x + 1) * (x^2 - x + 1) 
> > 
> > Another thing I do is to put my commands into a .py file and run 
> pyflakes on it, as that reveals what things need to be imported.  Then 
> import them all from sage.all. 
>
> you can also find out exactly what you need to import: 
>
> sage: import_statements("QQ") 
> from sage.rings.rational_field import QQ 
>
>
> > 
> > John Cremona 
> > 
> > On Mon, 19 Nov 2018 at 11:48, Kolen Cheung  > wrote: 
> >> 
> >> Thank you both for the answers. However, I’m still stuck: 
> >> 
> >> Focusing on just translating the first line: R. = QQ[] 
> >> 
> >> In sage, 
> >> 
> >> >>> preparse("R. = QQ[]") 
> >> "R = QQ['x']; (x,) = R._first_ngens(1)" 
> >> >>> import_statements(QQ) 
> >> # ** Warning **: several names for that object: Q, QQ 
> >> from sage.rings.rational_field import Q 
> >> >>> import_statements(R) 
> >> from sage.rings.qqbar import QQx 
> >> 
> >> Immediately I have a question: how come the import_statements of QQ is 
> ... import Q, and the import statement of R is ... import QQx? In either 
> case the namespace in question is not imported. Does it mean ... import Q 
> as QQ and ... import QQx as R respectively? 
> >> 
> >> Then I’ve a problem: In sage, I can import them using these import 
> statements. But when entering these 2 import statements in Python, 
> >> 
> >> >>> from sage.rings.rational_field import Q 
> >> 
> --- 
> >> ImportError   Traceback (most recent call 
> last) 
> >>  in () 
> >> > 1 from sage.rings.rational_field import Q 
> >> 
> >> /usr/lib/python2.7/site-packages/sage/rings/rational_field.py in 
> () 
> >>  62 _long_type = int 
> >>  63 
> >> ---> 64 from .rational import Rational 
> >>  65 from .integer import Integer 
> >>  66 
> >> 
> >> /usr/lib/python2.7/site-packages/sage/rings/rational.pyx in init 
> sage.rings.rational (build/cythonized/sage/rings/rational.c:40976)() 
> >>  94 
> >>  95 
> >> ---> 96 import sage.rings.real_mpfr 
> >>  97 import sage.rings.real_double 
> >>  98 from libc.stdint cimport uint64_t 
> >> 
> >> /usr/lib/python2.7/site-packages/sage/rings/real_mpfr.pyx in init 
> sage.rings.real_mpfr (build/cythonized/sage/rings/real_mpfr.c:44298)() 
> >> > 1 r""" 
> >>   2 Arbitrary Precision Real Numbers 
> >>   3 
> >>   4 AUTHORS: 
> >>   5 
> >> 
> >> /usr/lib/python2.7/site-packages/sage/rings/complex_number.pxd in init 
> sage.libs.mpmath.utils (build/cythonized/sage/libs/mpmath/utils.c:8831)() 
> >>   4 from .real_mpfr cimport RealNumber 
> >>   5 
> >> > 6 cdef class ComplexNumber(sage.structure.element.FieldElement): 
> >>   7 cdef mpfr_t __re 
> >>   8 cdef mpfr_t __im 
> >> 
> >> /usr/lib/python2.7/site-packages/sage/rings/complex_double.pxd in init 
> sage.rings.complex_number 
> (build/cythonized/sage/rings/complex_number.c:24212)() 
> >>   8 
> >>   9 
> >> ---> 10 cdef class ComplexDoubleField_class(sage.rings.ring.Field): 
> >>  11 pass 
> >>  12 
> >> 
> >> /usr/lib/python2.7/site-packages/sage/rings/complex_double.pyx in init 
> sage.rings.complex_double 
> (build/cythonized/sage/rings/complex_double.c:24230)() 
> >>  96 from cypari2.convert cimport new_gen_from_double, 
> new_t_COMPLEX_from_double 
> >>  97 
> >> ---> 98 from . import complex_number 
> >>  99 
> >> 100 from .complex_field import ComplexField 
> >> 
> >> ImportError: cannot import name complex_number 
> >> >>> from sage.rings.qqbar import QQx 
> >> 
> --- 
> >> ImportError

Re: [sage-support] Sage Crash Report

2018-11-19 Thread Kolen Cheung


Thanks. This is it. I’m glad we discussed about the channel priority (if 
you noticed my original attachment sage-environment.yml, conda-forge is 
last.)

I’m curious why this ABI incompatibility are allowed when satisfying the 
dependencies. I don’t know if the conda forge formula is written 
incorrectly or if this is a deficiency of conda. My original hope is to 
prioritize the intel channel so I can get libraries such as numpy and scipy 
from intel which is built using MKL instead of openblas. The bigger picture 
is to use sage together with the existing stack of libraries I already am 
using (where most are from intel then defaults).

For others’ reference, this is the minimal example to install sage in conda:

name: sage
channels:
  # this must be the first
  - conda-forge
  - intel
  - defaults
dependencies:
  # or just sage if you don't care versions
  - sage=8.3=py36_3

Save it as env-sage.yml, then run

conda env create -f ~/Dropbox/env-sage.yml
. activate sage

​

-- 
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.


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

2018-11-19 Thread Dima Pasechnik
On Mon, Nov 19, 2018 at 11:58 AM John Cremona  wrote:
>
> I recommend importing anything you need from sage.all since the details of 
> where everything is might change in time.  This works perfectly well:
>
> $ sage -python  # so we use Sage's python not my system-wide one
> Python 2.7.15 (default, Nov  2 2018, 14:32:42)
> [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from sage.all import PolynomialRing, QQ
> >>> R = PolynomialRing(QQ,'x')
> >>> x = R.gen()
> >>> f = x^3+1 # no good as no preparser
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "sage/structure/element.pyx", line 944, in 
> sage.structure.element.Element.__xor__ 
> (build/cythonized/sage/structure/element.c:9006)
> RuntimeError: Use ** for exponentiation, not '^', which means xor
> in Python, and has the wrong precedence.
>
> # Now we can work with this:
>
> >>> f = x**3+1  # that's better
> >>> f.factor()
> (x + 1) * (x^2 - x + 1)
>
> Another thing I do is to put my commands into a .py file and run pyflakes on 
> it, as that reveals what things need to be imported.  Then import them all 
> from sage.all.

you can also find out exactly what you need to import:

sage: import_statements("QQ")
from sage.rings.rational_field import QQ


>
> John Cremona
>
> On Mon, 19 Nov 2018 at 11:48, Kolen Cheung  wrote:
>>
>> Thank you both for the answers. However, I’m still stuck:
>>
>> Focusing on just translating the first line: R. = QQ[]
>>
>> In sage,
>>
>> >>> preparse("R. = QQ[]")
>> "R = QQ['x']; (x,) = R._first_ngens(1)"
>> >>> import_statements(QQ)
>> # ** Warning **: several names for that object: Q, QQ
>> from sage.rings.rational_field import Q
>> >>> import_statements(R)
>> from sage.rings.qqbar import QQx
>>
>> Immediately I have a question: how come the import_statements of QQ is ... 
>> import Q, and the import statement of R is ... import QQx? In either case 
>> the namespace in question is not imported. Does it mean ... import Q as QQ 
>> and ... import QQx as R respectively?
>>
>> Then I’ve a problem: In sage, I can import them using these import 
>> statements. But when entering these 2 import statements in Python,
>>
>> >>> from sage.rings.rational_field import Q
>> ---
>> ImportError   Traceback (most recent call last)
>>  in ()
>> > 1 from sage.rings.rational_field import Q
>>
>> /usr/lib/python2.7/site-packages/sage/rings/rational_field.py in ()
>>  62 _long_type = int
>>  63
>> ---> 64 from .rational import Rational
>>  65 from .integer import Integer
>>  66
>>
>> /usr/lib/python2.7/site-packages/sage/rings/rational.pyx in init 
>> sage.rings.rational (build/cythonized/sage/rings/rational.c:40976)()
>>  94
>>  95
>> ---> 96 import sage.rings.real_mpfr
>>  97 import sage.rings.real_double
>>  98 from libc.stdint cimport uint64_t
>>
>> /usr/lib/python2.7/site-packages/sage/rings/real_mpfr.pyx in init 
>> sage.rings.real_mpfr (build/cythonized/sage/rings/real_mpfr.c:44298)()
>> > 1 r"""
>>   2 Arbitrary Precision Real Numbers
>>   3
>>   4 AUTHORS:
>>   5
>>
>> /usr/lib/python2.7/site-packages/sage/rings/complex_number.pxd in init 
>> sage.libs.mpmath.utils (build/cythonized/sage/libs/mpmath/utils.c:8831)()
>>   4 from .real_mpfr cimport RealNumber
>>   5
>> > 6 cdef class ComplexNumber(sage.structure.element.FieldElement):
>>   7 cdef mpfr_t __re
>>   8 cdef mpfr_t __im
>>
>> /usr/lib/python2.7/site-packages/sage/rings/complex_double.pxd in init 
>> sage.rings.complex_number 
>> (build/cythonized/sage/rings/complex_number.c:24212)()
>>   8
>>   9
>> ---> 10 cdef class ComplexDoubleField_class(sage.rings.ring.Field):
>>  11 pass
>>  12
>>
>> /usr/lib/python2.7/site-packages/sage/rings/complex_double.pyx in init 
>> sage.rings.complex_double 
>> (build/cythonized/sage/rings/complex_double.c:24230)()
>>  96 from cypari2.convert cimport new_gen_from_double, 
>> new_t_COMPLEX_from_double
>>  97
>> ---> 98 from . import complex_number
>>  99
>> 100 from .complex_field import ComplexField
>>
>> ImportError: cannot import name complex_number
>> >>> from sage.rings.qqbar import QQx
>> ---
>> ImportError   Traceback (most recent call last)
>>  in ()
>> > 1 from sage.rings.qqbar import QQx
>>
>> /usr/lib/python2.7/site-packages/sage/rings/qqbar.py in ()
>> 512 rich_to_bool, richcmp_not_equal,
>> 513 op_EQ, op_NE)
>> --> 514 from sage.rings.real_mpfr import RR
>> 515 from sage.rings.real_mpfi import RealIntervalField, RIF, 
>> is_RealIntervalFieldElement, RealIntervalField_class
>> 516 from sage.rings.complex_field import 

Re: [sage-support] plot3d doesn't work in jupyterlab / jupyter notebook

2018-11-19 Thread Kolen Cheung


Thanks all for the comments. In the end I choose this temporary fix 
plot3d(sin(pi 
* sqrt(x**2 + y**2)) / sqrt(x**2 + y**2), (x, -5, 5), (y, -5, 5), 
viewer='threejs', online=True). I prefer to stick to jupyterlab hub and 
using conda to manage it so I didn’t try symlink those from sage in the 
jupyterlab environment.

Regarding the three.js shipped by Arch, may be it didn’t work. But it isn’t 
the original of the problem I’m experiencing since in the browser’s console 
it clearly indicates the three.js cannot be found. I tried to install 
three.js the “jupyter way”, i.e. jupyter labextension install 
jupyter-threejs, but it didn’t work for both jupyterlab and jupyter 
notebook.
​

-- 
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 Kolen Cheung


Thank you both for the answers. However, I’m still stuck:

Focusing on just translating the first line: R. = QQ[]

In sage,

>>> preparse("R. = QQ[]")"R = QQ['x']; (x,) = R._first_ngens(1)">>> 
>>> import_statements(QQ)# ** Warning **: several names for that object: Q, 
>>> QQfrom sage.rings.rational_field import Q>>> import_statements(R)from 
>>> sage.rings.qqbar import QQx

Immediately I have a question: how come the import_statements of QQ is ... 
import Q, and the import statement of R is ... import QQx? In either case 
the namespace in question is not imported. Does it mean ... import Q as QQ 
and ... import QQx as R respectively?

Then I’ve a problem: In sage, I can import them using these import 
statements. But when entering these 2 import statements in Python,

>>> from sage.rings.rational_field import Q
---
ImportError   Traceback (most recent call last)
 in ()
> 1 from sage.rings.rational_field import Q

/usr/lib/python2.7/site-packages/sage/rings/rational_field.py in ()
 62 _long_type = int
 63 
---> 64 from .rational import Rational
 65 from .integer import Integer
 66 

/usr/lib/python2.7/site-packages/sage/rings/rational.pyx in init 
sage.rings.rational (build/cythonized/sage/rings/rational.c:40976)()
 94 
 95 
---> 96 import sage.rings.real_mpfr
 97 import sage.rings.real_double
 98 from libc.stdint cimport uint64_t

/usr/lib/python2.7/site-packages/sage/rings/real_mpfr.pyx in init 
sage.rings.real_mpfr (build/cythonized/sage/rings/real_mpfr.c:44298)()
> 1 r"""
  2 Arbitrary Precision Real Numbers
  3 
  4 AUTHORS:
  5 

/usr/lib/python2.7/site-packages/sage/rings/complex_number.pxd in init 
sage.libs.mpmath.utils (build/cythonized/sage/libs/mpmath/utils.c:8831)()
  4 from .real_mpfr cimport RealNumber
  5 
> 6 cdef class ComplexNumber(sage.structure.element.FieldElement):
  7 cdef mpfr_t __re
  8 cdef mpfr_t __im

/usr/lib/python2.7/site-packages/sage/rings/complex_double.pxd in init 
sage.rings.complex_number (build/cythonized/sage/rings/complex_number.c:24212)()
  8 
  9 
---> 10 cdef class ComplexDoubleField_class(sage.rings.ring.Field):
 11 pass
 12 

/usr/lib/python2.7/site-packages/sage/rings/complex_double.pyx in init 
sage.rings.complex_double (build/cythonized/sage/rings/complex_double.c:24230)()
 96 from cypari2.convert cimport new_gen_from_double, 
new_t_COMPLEX_from_double
 97 
---> 98 from . import complex_number
 99 
100 from .complex_field import ComplexField

ImportError: cannot import name complex_number
>>> from sage.rings.qqbar import QQx
---
ImportError   Traceback (most recent call last)
 in ()
> 1 from sage.rings.qqbar import QQx

/usr/lib/python2.7/site-packages/sage/rings/qqbar.py in ()
512 rich_to_bool, richcmp_not_equal,
513 op_EQ, op_NE)
--> 514 from sage.rings.real_mpfr import RR
515 from sage.rings.real_mpfi import RealIntervalField, RIF, 
is_RealIntervalFieldElement, RealIntervalField_class
516 from sage.rings.complex_field import ComplexField

/usr/lib/python2.7/site-packages/sage/rings/real_mpfr.pyx in init 
sage.rings.real_mpfr (build/cythonized/sage/rings/real_mpfr.c:44298)()
> 1 r"""
  2 Arbitrary Precision Real Numbers
  3 
  4 AUTHORS:
  5 

/usr/lib/python2.7/site-packages/sage/rings/complex_number.pxd in init 
sage.libs.mpmath.utils (build/cythonized/sage/libs/mpmath/utils.c:8831)()
  4 from .real_mpfr cimport RealNumber
  5 
> 6 cdef class ComplexNumber(sage.structure.element.FieldElement):
  7 cdef mpfr_t __re
  8 cdef mpfr_t __im

/usr/lib/python2.7/site-packages/sage/rings/complex_double.pxd in init 
sage.rings.complex_number (build/cythonized/sage/rings/complex_number.c:24212)()
  8 
  9 
---> 10 cdef class ComplexDoubleField_class(sage.rings.ring.Field):
 11 pass
 12 

/usr/lib/python2.7/site-packages/sage/rings/complex_double.pyx in init 
sage.rings.complex_double (build/cythonized/sage/rings/complex_double.c:24230)()
 96 from cypari2.convert cimport new_gen_from_double, 
new_t_COMPLEX_from_double
 97 
---> 98 from . import complex_number
 99 
100 from .complex_field import ComplexField

ImportError: cannot import name complex_number

Thanks. 
​

-- 
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 

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

2018-11-19 Thread Kolen Cheung
But if you're reading carefully this isn't what I'm asking.

On Monday, November 19, 2018 at 12:30:22 AM UTC-8, Dima Pasechnik wrote:
>
> Sage uses a preparer to translate things like R.=QQ[] into usual Python 
> R=PolynomialRing(...).
>
> In the library code the preparer is not used.
>
>
> On Mon, 19 Nov 2018 03:13 Kolen Cheung  
> wrote:
>
>> Hi, I’m trying to translate this Sage syntax to Python syntax (i.e. using 
>> sage as a Python library.) But I got stuck even on the first command.
>>
>> In Sage,
>>
>> >>> R. = QQ[]>>> type(R)
>>
>> > 'sage.rings.polynomial.polynomial_ring.PolynomialRing_field_with_category'>
>>
>> Then I thought I can import it in Python like this:
>>
>> import sage.rings
>> # OK
>>
>> sage.rings.polynomial.polynomial_ring.PolynomialRing_field
>> # AttributeError
>>
>> sage.rings.polynomial.polynomial_ring.PolynomialRing_field_with_category
>>
>> 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. Do you think it is realistic to use sage 
>> as a Python library and completely not using sage (as an interpreter) 
>> itself?
>>
>> c.f. Documentation on using sage as a library? 
>> 
>>
>> Thanks.
>> ​
>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to sage-s...@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.


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

2018-11-19 Thread slelievre
Mon 2018-11-19 09:41:03 UTC+1, Simon King:
>
> 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. 

That is sage_input, which can be used as follows:

sage: R. = QQ[]
sage: sage_input(R)
QQ['x']
sage: sage_input(x)
R. = QQ[]
x

Note that it does not always work:

sage: K = R.fraction_field()
sage: sage_input(K)
Traceback (most recent call last)
...
ValueError: Can't convert Fraction Field of Univariate Polynomial Ring 
in x over Rational Field to sage_input form

-- 
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.


Re: [sage-support] plot3d doesn't work in jupyterlab / jupyter notebook

2018-11-19 Thread slelievre
Mon 2018-11-19 05:50:09 UTC+1, Antonio Rojas:
>
> The three.js version shipped by Arch is too new and not
> supported by Sage. Either use jsmol (which is still the default),
> or use the online version of three.js (viewer='threejs', online=True)
> (with sagemath 8.4-4, in previous versions the online version
> doesn't work either)

See Sage Trac ticket 26718 for upgrading to the latest version of three.js:

https://trac.sagemath.org/ticket/26718

-- 
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.