Ask Your Question

lrfinotti's profile - activity

2021-02-02 11:30:19 +0100 received badge  Popular Question (source)
2020-07-05 10:02:22 +0100 asked a question Syntax Highlight in JupyterLab Editor

Is there a way to have JupyterLab's editor highlight syntax in '.sage' files? (I'm using the version of JupyterLab installed from Sage itself.)

2020-02-26 23:02:37 +0100 commented answer Performance Question

Ah, of course! Thanks for pointing that out (and sorry I missed it).

2020-02-26 23:01:42 +0100 received badge  Supporter (source)
2020-02-26 00:10:30 +0100 commented question Performance Question

I tried with

minp = 50000000
p = next_prime(minp)
G = Zmod(p).unit_group()
g = G.gen()

Then computed (as above) the order of g. This is pretty large, and still the first (computing powers) takes 215s and the second 207s. So it's better, but I expected a larger difference with that many iterations.

2020-02-25 16:42:29 +0100 commented question Performance Question

I tried on unit groups of some Zmod(m)'s.

2020-02-25 15:07:17 +0100 asked a question Performance Question

I asked my students to write a function to check the order of an element in a multiplicative group. Most wrote something like:

def naive_find_order1(g):
    G = g.parent()
    i = 1
    while g^i != G.identity():
        i += 1
    return i

I told them that this was wasteful, as it computes powers in every iteration, and suggested:

def naive_find_order2(g):
    G = g.parent()
    i = 1
    h = g
    while h != G.identity():
        h *= g
        i += 1
    return i

On the other hand, when testing both, they run in practically the same amount of time.

My question is how is that so? The second function only performs one multiplication in the group per loop, while the first I assume computes powers in every iteration. Does Sage/Python cache the powers? Any insight would be greatly appreciated.

2018-08-22 17:51:51 +0100 commented question LaTeX shortcuts in iPython Notebook

No, it does not work. (Assuming you run that command in a cell or load it from a file.) But thanks for the suggestion!

2018-08-21 23:28:16 +0100 received badge  Student (source)
2018-08-21 23:26:25 +0100 asked a question LaTeX shortcuts in iPython Notebook

Is there a way to load a file containing many LaTeX shortcuts (like \newcommand{...}{...}) into an iPython notebook, so that these can be used throughout?

Or is it possible to add to a (hopefully hidden) cell? If so, what would be the syntax?

2018-08-21 23:26:24 +0100 asked a question Loading LaTeX shotcuts in a iPython Notebook

Is it possible to load a file containing many LaTeX shotcuts (like newcommand{..}{..}) into an iPython notebook so that the shortcuts are available while typing in the notebook? Or would it be possible to do by entering the shortcuts in a cell (hopefully hidden)? (If the latter only is possible, what is the syntax?)

Thanks!