[sage-support] Quaternions and Lorentz Transformations

2022-04-16 Thread Marco Pereira
I am trying to understand how to use Quaternions within sagemath to
replicate Lorentz transforms.

In other words, Lorentz transforms are rotations within a 4D spacetime and
I need to understand how they can be expressed in terms of quaternions.

I looked up examples of quaternions usage and they seem cryptic...

Since I suspect this issue has been solved a long time ago, I am asking for
help finding the appropriate code.

Cheers,

Marco

-- 
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/CABs1CmUsuD-NBZB6AhKGqt%2BDUc44903dqSqT%3DTqPAt5_47_eEg%40mail.gmail.com.


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.


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&redirect=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] 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.


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

2018-11-19 Thread Dima Pasechnik
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  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+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-18 Thread Kolen Cheung


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)



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+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-09-14 Thread Peter Luschny
merci beaucoup!

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-09-14 Thread William Stein
On Fri, Sep 14, 2018 at 9:00 AM, Peter Luschny  wrote:
> How can I speed up this computation?
>
> H. = QuaternionAlgebra(SR, -1, -1)

Do NOT use SR.  Instead use QQ(x).  Then it is 100x faster than Mathematica...

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)
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].numerator().list()
for n in (0..20): print [n], p(n)

This takes 0.05s walltime.  See

https://share.cocalc.com/share/4a5f0542-5873-4eed-a85c-a18c706e8bcd/support/2018-09-14-091151-quat.sagews?viewer=share

Also, if you want to actually push things further, note that your
function P depends on all smaller values of
P, so you could make this massively faster by making P use
@cached_function, like this:

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_function
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].numerator().list()
for n in (0..20): print [n], p(n)

This takes 0.01s walltime, and will work for 20 replaced by a much
larger number.
Read about this cached_function decorator:

http://doc.sagemath.org/html/en/reference/misc/sage/misc/cachefunc.html


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



-- 
William (http://wstein.org)

-- 
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] Quaternions, how to speed up computation

2018-09-14 Thread Peter Luschny
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.


[sage-support] quaternions

2008-03-27 Thread Chris Godsil

I want to extract the "real part" of a quaternion, i.e., if

  L. = QuaternionAlgebra(QQ,-1,-1);

and a is in L, then I want the coefficient of 1 in the expansion of as
a linear
combination of 1, i, j and k.

Is there a way to do this?  A graceful way?

(I have also discovered that using quaternions in combination with
list comprehensions
which have i as the dummy variable - [i for i in range(10)] - leads to
quite unexpected
results.  But I suspect this reflects an underlying problem in
python...)

Thanks in advance for any help.

Chris

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---