Ask Your Question

nbruin's profile - activity

2020-04-30 15:53:46 -0500 answered a question Changing fonts in mark down cells.

According to https://jupyter-notebook.readthedocs.... markdown is a superset of HTML. Since you can change fonts in HTML, it would follow that you can change fonts in markdown cells too. I suspect it's going to be quite painful to do, and would result in worksheets that don't fare very well under other export methods.

In fact, one of the best ways to get things in Computer Modern would be by exporting your sheet to LaTeX (and probably to PDF from there)

2020-04-27 18:07:10 -0500 commented answer how can i convert the elliptic curve point representation

It works a little better if you call the routine different:

def random_point_in_integer_representation(E):
    P = E.random_point()
    return (P[0].integer_representation(), P[1].integer_representation())

A good computer algebra system gives you the tools to get the output/representation you want, rather than provide little custom routines to provide each possibility individually. Sagemath gives you the tools. You do the programming.

2020-04-26 22:53:36 -0500 answered a question how can i convert the elliptic curve point representation

You could try


etc. The coordinates are given are not polynomials, although they are written as a polynomial expression in the generator of the field. With "integer representation" you basically take the bitstring obtained by looking at the coefficients of z101^i and interpreting that bitstring as an integer.

2020-04-18 17:24:42 -0500 received badge  Nice Answer (source)
2020-04-17 14:05:02 -0500 commented question Rational parametrization of plane curves. Is this a bug?

It looks like both: apparently singular crashes, sage restarts singular, and then expects that a previously defined object sage19 is still in place, which of course it isn't.

2020-04-06 15:21:37 -0500 commented answer Express Groebner basis in terms of original basis

It may not be convenient but it does exactly reflect what happens: to obtain that relation, you'd need to take f1^3 in terms of your original basis.

2020-04-01 10:47:59 -0500 commented question Express Groebner basis in terms of original basis

I think the quick way for this is to carry around marker variables, say b1,b2 and then compute the groebner basis of the ideal (b1-f1,b2-f2), making sure you have a block order that prioritizes the original variables (that occur in f1,f2). You can then see in the resulting basis from the part of the polynomials in the b1,b2 how your original generators were combined. It's comparable to the trick of augmenting a matrix for Gaussian elimination to find the transformation that gets you there (i.e., the inverse of the matrix).

2020-03-29 12:50:09 -0500 commented question C-STACK overflow during integration

As a side note: the error is one that can come from "maximalib", so it doesn't seem like your option algorithm="fricas" is working. The C-stack overflow is probably an infinite recursion that probably happens in maxima itself as well (if the options are set in the same way as sage does). That would be reportable to maxima.

2020-03-27 15:23:29 -0500 received badge  Nice Answer (source)
2020-03-26 16:10:47 -0500 answered a question What is the point 𝑃1=(βˆ’1,3) on the y^2=7π‘₯4+π‘₯3+π‘₯2+π‘₯+3 curve and the point corresponding to P on the x^2=x^3βˆ’250/3xβˆ’124927 curve?

The question is, unfortunately, not well-defined. The curves mentioned, while isomorphic, are not uniquely so. First you should specify which point on E1 is supposed to be mapped to the "origin" (0:1:0) on "E2", and then there is still a choice of sign.

The routine Jacobian mentioned in another answer does not give you a (birational) isomorphism; it only expresses "E1" as a cover of "E2". There is even more choice in that.

As an example:

sage: P2.<x,y,z>=ProjectiveSpace(QQ,2)
sage: C=Curve(3*x^3+4*y^3+5*z^3)
sage: phi=Jacobian(C,morphism=True)
sage: phi.codomain()
Elliptic Curve defined by y^2 = x^3 - 24300 over Rational Field

This is Selmer's famous example: the curve C isn't isomorphic to the elliptic curve over Q, because C does not have rational points. The map phi computed is of degree larger than 1 (presumable degree 9, but I didn't check)

2020-03-26 11:40:23 -0500 commented answer What is the point 𝑃1=(βˆ’1,3) on the y^2=7π‘₯4+π‘₯3+π‘₯2+π‘₯+3 curve and the point corresponding to P on the x^2=x^3βˆ’250/3xβˆ’124927 curve?

Note, though, that the map phi is not uniquely determined. You can compose phi with a translation on E1 and/or negation.

2020-03-24 11:10:57 -0500 commented answer can one now set a timelimit on operation in sagemath?

I would not trust the results of a sage session that regularly has been interrupted (by alarms or user interrupts): while the code generally tries to block interrupts in critical parts and then deal with them once the system is in a more consistent state, I would expect sage doesn't entirely succeed: I expect in some cases the system will be left in an inconsistent state (there are bugs, so this is also true without interrupts...)

If you want to time-limit computations "safely", I would trust a fork-and-kill method more: then you at least discard the state of the computing processif it didn't complete. I think that indeed needs you to put some plumbing in place yourself, but that could be wrapped up in convenient routines.

2020-03-19 17:55:44 -0500 received badge  Nice Answer (source)
2020-03-19 00:42:01 -0500 answered a question Interact in Jupyterlab vs Jupyter

It looks like lab takes a different approach than notebook regarding javascript in output cells. It would be nice to have a more official source, but the following Q/A seems to contain some valuable info:

it looks like there's some work to do once sagemath starts moving to lab in earnest.

2020-03-17 03:02:05 -0500 answered a question Strange behaviour with distributivity of multiplication

In Python, the rule is that if a line ends with a bracket/brace/parenthesis waiting to be closed, then the newline is read as whitespace and the expression is considered to continue on the next line. This explains the behaviour in the second example.

In the first example, the preparser gets involved, which does not handle newlines in the same way. Indeed, you can get a syntax error by putting the newline in a slightly different position:

sage: Qpart(x) = 5*( unit_step(x)*
....: sin(x) -
....: sin(x))
SyntaxError: invalid syntax

You can see what happens if you look at what the preparser does:

sage: preparse("""Qpart(x) = 5*( unit_step(x)*
....: sin(x) -
....: sin(x))""") 
'__tmp__=var("x"); Qpart = symbolic_expression(Integer(5)*( unit_step(x)*).function(x)\nsin(x) -\nsin(x))'

The rewriting only happens on the first line, regardless of whether that maintains proper syntax: it's a fairly basic regexp replacement. Ideally the preparser would actually PARSE, but that's not what it does.

2020-03-03 15:55:01 -0500 commented question Error when using non ASCII characters as symbolic function name

Using unicode in SR names is a recipe for disaster: these names get shipped to all kinds of interfaces. I would not expect those to react kindly to unicode identifiers.

2020-02-28 14:04:00 -0500 commented question Kernel Crash

That indicates there is something broken in your installation. The expected output is:

sage: f =cos(x)^2+sin(x)^2
sage: f
cos(x)^2 + sin(x)^2
sage: f.full_simplify()

The first thing to try is to reinstall sage, since this indicates something rather fundamental is broken (at least for the maxima/lisp subsystem that is used for simplification). If that doesn't help, you might get help by giving exact details about your operating system and the way you've installed sage.!for... is probably a better forum to get help for this.

2020-02-27 11:11:53 -0500 answered a question 20 monomials of degree 3 in 4 variables in lexicographic ordering

A function to get a list of monomials of specified degree would be good to have in sage. Perhaps it is already by now. Otherwise it's not hard to define once you know which primitives to use:

def monomials_of_degree(P,n):
      V=[P({tuple(a):1}) for a in WeightedIntegerVectors(n,[1]*P.ngens())]
      return V

With this you can do:

M=[h(R.gens()+(1,)) for h in m]
2020-02-25 12:16:08 -0500 commented question Performance Question

You wouldn't be doing this on large groups, so I expect that the multiplication in h *= g and the exponentiation in g^i get swamped in all the overhead. It's hard nowadays to measure the "actual" complexity of operations, partially because software like GMP is so optimized that you need really big integers before operations are not negilible compared to the memory shuffling and interpreter overhead that needs to happen anyway.

In your example, G.identity() already costs a method lookup and a function call. I suspect that if you assign id=G.identity() before the while loop and use id instead, you'll get a more measurable performance increase. Whether replacing it with a more specific test like h.is_one() makes it faster is a toss-up.

2020-02-16 05:00:50 -0500 received badge  Nice Answer (source)
2020-02-15 14:02:40 -0500 answered a question Symbolic expression of `sng()` which isn’t zero at `sgn(0)`
side(u) = sign(u) + kronecker_delta(u,0)

would do the trick ...

2020-02-12 10:57:15 -0500 commented answer Error while creating augmented matrix: TypeError: unable to convert a to an integer

Any "abstract algebra" book would work. For a "rings first" approach there is also Anderson-Feil's "A first course in abstract algebra", which is appropriate for an introctory course in the subject.

2020-02-05 13:29:29 -0500 commented answer Sagemath 9.0 Markdown inconsistency Cocalc vs. Local

That only works if you have only one single character that needs to be bolded/italicized, because then you can use a unique pair of delimiters. in __a__ and **b** and __c__ and **d** you run into the same problem again.

2020-02-05 13:25:10 -0500 answered a question Sagemath 9.0 Markdown inconsistency Cocalc vs. Local

It looks like this is a problem in the markdown processor for the standard Jupyter notebook server (so for sage, it's an upstream bug). The jupyter notebook server in cocalc is a custom one. The problem seems to be that the markdown for a single bold character doesn't get processed right if there are further bold markers: in **a** and **b** the "middle" if there's another such string. The same thing seems to happen with italics, so *a* and *b* and *c* and *d* and *e* gets misrendered as (italics) a* and *b (roman) and (italics) c* and *d (roman) and (italics) e. This should definitely be reported (to jupyter). In the mean time, the workaround would be to avoid bolding single characters ... In this case, you can just spell it out as **three**, which is recommended english style anyway.

2020-01-19 13:09:24 -0500 commented answer Automatically attach file on starting shell?

I think you may want to use a different name in the %runfile command; otherwise starting up sage with ~/.sage as current directory could lead to an unpleasant experience.

2020-01-15 07:53:18 -0500 received badge  Good Answer (source)
2020-01-08 20:44:48 -0500 commented question Is it error in Sage or mwrank

The more diplomatic ,specific, and constructive version of your "sage is terrible" would be: "It looks like there are many opportunities to make "E.gets()" succeed on a lot more elliptic crurves."

It does look like a lot of the higher descent techniques (and 3-descent) that are available in magma, aren't available in sage. It's hard to find someone motivated to do the hard work again -- the first time (for the implementation in magma) the author got a nice paper out of it. That's hard to replicate for the person who'd implement these routines in sage.

2020-01-08 07:27:39 -0500 commented question too complicated algebra => memory leak

If an added assumption causes a crash consistent with running out of memory, then a likely explanation is that the extra assumption makes the program try some manipulations that might be a good idea in other situations, but in this situation leads to intermediate results that might not be practically representable.

2020-01-08 04:06:21 -0500 received badge  Nice Answer (source)
2020-01-07 22:56:38 -0500 answered a question Is it error in Sage or mwrank

The reason why this curve is a little problematic is because it has nontrivial Sha[2]. It would be fairly straightforward to get E.gens() to work: this is a rank 1 elliptic curve and enough of BSD is proved that this can be proven analytically. Sage knows how to do that too:

sage: E.rank(only_use_mwrank=False,proof=True)

So the only thing to do is to prove that the point you found isn't divisible by any $n>1$. It is a little surprising that E.gens doesn't seem to have obvious options to help it discover this. The basic elements for implementing this are available.

2020-01-07 11:50:53 -0500 commented question too complicated algebra => memory leak

That error message means that the sage process HAS crashed and has been restarted for you. Everything you've done is now wiped from the kernel state, so you'll have to reexecute your initialization code.

If your computer system gets into extreme memory shortage, it may have to do strange things. Look up OOM killer if you're interested. One result might be that your process just gets killed, without a clear trace of what happened (the memory shortage can prevent the system from even sending you a meaningful message). This is rare, but might be what you previously experienced.

It doesn't look particularly fishy to me. Most of the behaviour you describe is consistent with a computer program running out of memory.

2020-01-07 11:26:36 -0500 commented answer Should I avoid using unicode in names of variables?

I would not be pleased if I were to be forced to type gro\ddot<tab>bner_basis. Also, whatever tab completion exists in interactive shells is unlikely to be available in many code editors, so relying on tab completion would make for a very poor "transportable" sage experience. I think keyboards worldwide are just not very unicode capable. Given the prevalence of english as an international language, I suspect this won't change very quickly. Perhaps the situation will change when mandarin takes over.

2020-01-06 23:02:08 -0500 received badge  Good Answer (source)
2020-01-06 22:56:03 -0500 commented question too complicated algebra => memory leak

When I set a lowish memory limit with your code, I get a rather quick "segmentation fault". It looks like the code gets stuck in the limit computation, which gets done by maxima. The expression that you're taking the limit of is rather awful, so I suspect that maxima is simply running out of memory, trying to expand some horrible expression. The limit you're trying to compute is undoubtably computable, but you may have to go about it a little more carefully.

2020-01-05 14:51:29 -0500 received badge  Nice Answer (source)
2020-01-05 02:36:00 -0500 answered a question Should I avoid using unicode in names of variables?

See python's PEP-8 for the policy for python's standard library (identifiers must be ASCII) and PEP-3131 for the proposal that led to unicode identifiers being possible. Sage library code has more-or-less been following PEP-8, so I expect non-ascii identifiers will not be allowed there. What you do in your own files is your own concern (go wild and name your eigenvalue $\lambda$).

Non-ascii unicode characters may be difficult to type (depending on keyboard layout) and they can be extremely confusing, because unicode contains different code-points that have (nearly) identical print-shapes. I'd be strongly in favour for keeping them out of library code.

2020-01-04 11:32:38 -0500 commented question Lengths of preperiod and period of a rational number

Ah, I see period is a method on a rational number, not on a float. That makes perfect sense then. Apologies for the noise.

2020-01-04 05:18:28 -0500 received badge  Nice Answer (source)
2020-01-04 05:18:08 -0500 received badge  Nice Answer (source)
2020-01-03 21:42:34 -0500 commented answer Cython: undeclared name not builtin

If you check the contents of sage.all, you'll see that it consists entirely of imports from other modules. There is something to say for importing symbols from their original location, which is why import_statements traces the import to its actual origin. I wouldn't say the import from sage.all is wrong but it's definitely not the right answer.

2020-01-03 14:13:37 -0500 commented answer DeprecationWarning on SageCell (Python 3)

Yes, it is unfortunate that Py2/Py3 have some incompatibilities. However, Py2 is now officially unsupported, so I don't think anyone running a public-facing SageCell server will be willing to run Py2 on it. SageCell already allows for different kernels, so setting it up with both 8.9 and 9.0 is technically definitely possible.

The Ubuntu binary should become available soon now -- 9.0 has just come out. You can build from source if you don't want to wait for that (you'll be waiting for your local build to finish, though ...)

2020-01-03 13:11:49 -0500 answered a question Cython: undeclared name not builtin

It looks like you should:

sage: import_statements(RootSystem)
from sage.combinat.root_system.root_system import RootSystem

As you can see in the documentation of import_statements, it tries to find out from where the symbol requested should be imported and returns a string that describes a command to do that import. So, in your case, it suggests to use

from sage.combinat.root_system.root_system import RootSystem