Ask Your Question

Luca's profile - activity

2024-02-09 00:14:15 +0200 received badge  Enlightened (source)
2024-02-06 15:00:29 +0200 received badge  Good Answer (source)
2024-02-06 13:02:15 +0200 answered a question Quick check that an elliptic curve has composite order

No, there is not. The Schoof-Elkies-Atkin algorithm actually computes the order of the curve modulo small primes, and t

2024-02-05 13:48:18 +0200 received badge  Nice Answer (source)
2024-02-04 20:26:50 +0200 answered a question Get a half point of a point on elliptic curve.

The method P.division_points(n) gives the list of all rational points Q such that nQ = P. It works for any base field.

2022-10-28 21:59:05 +0200 commented question distortion map phi(x,y) = (-x, i*y) where i = sqrt(-1)

The error is what the message says: p and q are not points of the same curve. Indeed p is a point of E59 and q is a poin

2022-04-26 14:05:25 +0200 answered a question Reductions of elliptic curves over number fields

Identifying the curves depends on an isomorphism between the residue field generated by lbar and the finite field genera

2022-04-26 13:24:38 +0200 commented question Reductions of elliptic curves over number fields

Can you please fix your code so that the example works? p is undefined on line 7.

2022-02-01 16:59:21 +0200 received badge  Nice Answer (source)
2022-02-01 12:43:29 +0200 answered a question How to construct an isogeny [i] such that [i]^2= -1?

You can use the .automorphisms() method to get all the automorphisms of $E$. sage: E = EllipticCurve(GF(13), [1, 0]) sa

2021-11-03 23:04:43 +0200 commented question Lifting an Isogeny without Starting All Over

I don't believe there is a better method than what you suggest, at the moment.

2021-11-03 23:01:57 +0200 answered a question Isogeny from Two Curves

E1.isogeny(E2, ell) works if the isogeny between E1 and E2 is a Vélu isogeny, but there is nothing for the general case.

2021-11-03 22:52:15 +0200 answered a question Instantiating Elliptic Curve Isogenies using rational maps

This is not supported. Your best option is to pass the kernel polynomial, i.e., the denominator of $\phi_x$, as lone par

2021-04-03 08:26:10 +0200 received badge  Good Answer (source)
2019-05-07 01:05:32 +0200 received badge  Necromancer (source)
2017-09-18 02:08:58 +0200 received badge  Nice Answer (source)
2017-03-25 17:50:35 +0200 received badge  Nice Answer (source)
2015-05-20 20:49:41 +0200 commented question Elements in the lattice $A_n$

Sorry, misread your question. Here's some facts

  • The positive entries in your vector form a composition of k of length a ≤ n.
  • The absolute values of the negative entries form a composition of k of length b ≤ n + 1 - a.
  • The rest are zero entries.

So, a sketch of algorithm to generate one such vector would be :

  • Form all compositions of k of length at most n.
  • Choose a and b so that a+b ≤ n+1.
  • Choose the positions for the a positive coefficients, fill with a composition of length a.
  • Chose the positions for the b negative cofficients, fill with a composition of length b.
  • Fill the rest with zeros.

To iterate over all such vectors, you can use Sage's Compositions and Permutations.

2015-05-19 14:23:21 +0200 commented question Elements in the lattice $A_n$

I think you are looking for the integer partitions of k of length n+1. Have a look at the iterator Partitions(k,length=n+1).

2015-03-31 17:23:16 +0200 answered a question notebook versus terminal session

The notebook is all about the web. Everything you can do at the terminal, you can do in the notebook. And _vice versa_. Some things, are just more nicely shared via a notebook. See http://nbviewer.ipython.org/ (not Sage, but close enough).

Other good reasons to use notebooks :

Personally, I always use the terminal for personal or one shot computations, and Sage inside an IPython notebook for collaborating and sharing.

2015-02-28 16:33:00 +0200 commented question Using from Python (breaking the monolith)

I fully agree with you, and I am certainly not the only one. Unfortunately, Sage is a monolith, and there is little you can do right now. Making Sage more modular is one of the goals of this submitted EU project https://github.com/sagemath/grant-europe, that will hopefully begin next september.

2014-12-28 15:26:38 +0200 answered a question Variables in Sage

You must have forgotten the multiplication sign *. Quite obviously, $(c^2+d^2)$ was substituted for $a$ in the expression, thus you got $(c^2+d^2)^2 + b^2$. If you are using a recent version of Sage, you must have gotten a warning when evaluating the expression, saying that the correct form for expression substitution is

(a^2 + b^2)(a=(c^2 + d^2))

In Sage 6.4.1

sage: var('a,b')
(a, b)
sage: (a+b)(a+b)
/home/dfl/sage/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py:2883: DeprecationWarning:
Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future
release of Sage; you can use named arguments instead, like EXPR(x=..., y=...)
See http://trac.sagemath.org/5930 for details.
  exec(code_obj, self.user_global_ns, self.user_ns)
a + 2*b
sage: (a+b)*(a+b)
(a + b)^2
2014-11-30 21:50:26 +0200 commented answer Why does Sage return negative number when evaluating 181.0%360

Exactly for the reason I said: so that the output is consistent with the output of a/b, the rounding mode, and the mathematical definition of Euclidean division (which in truth does not make much sense for floats).

In Python rounding is done to the lowest integer, so it makes sense to return 181, indeed

>>> 360 * int(181.0 / 360) + (181.0 % 360)
181.0

In Mathematica, rounding is done to the closest integer, and indeed

360*round(181.0 / 360) + (181.0 mod 360)

answers 541 on WolframAlpha. Oups! Guess Mathematica does not really care for mathematical consistency.

2014-11-24 18:00:29 +0200 commented answer Lower prime divisor

Didn't know about trial_division. It is probably better than my answer, as it does the same thing, but with dedicated code.

2014-11-24 17:59:13 +0200 answered a question Lower prime divisor

It depends on the numbers you are factoring. Factorization algorithms for large numbers do not find factors in increasing order, thus you need to compute all factors in order to know which is smallest.

If your number is small, or has very small factors, this might be faster :

sage: n = 123456789
sage: bound = 100
sage: next(p for p in primes(bound) if n % p == 0)
3

play around with bound to find the value that works for you. Be aware that if no prime up to bound divides n, the last instruction will raise an exception, in that case you can try a higher bound, or use prime_divisors.

2014-11-23 19:43:29 +0200 answered a question Why does Sage return negative number when evaluating 181.0%360

So that this code works

sage: a = 181.0
sage: b = 360
sage: n = (a / b).round()
sage: b * n + (a % b) == a
True

From the sage docstring (which you can read by typing a.__mod__?)

Return the value of "left - n*right", rounded according to the rounding mode of the parent, where "n" is the integer quotient of "x" divided by "y". The integer "n" is rounded toward the nearest integer (ties rounded to even).

2014-09-19 16:25:39 +0200 answered a question Converting polynomials between rings

Because of the order you've defined the objects, L(t=t) will be an element of R2. Slightly more robustly, in your example you can do any of the following.

sage: L(t=R2.gen(4)).parent()
Multivariate Polynomial Ring in A, B, C, D, t over Rational Field
sage: L(t=R2.4).parent()
Multivariate Polynomial Ring in A, B, C, D, t over Rational Field
2014-08-30 00:47:38 +0200 received badge  Nice Answer (source)
2014-07-29 20:49:17 +0200 received badge  Nice Answer (source)
2014-07-22 14:55:31 +0200 received badge  Nice Answer (source)
2014-07-20 12:39:29 +0200 answered a question "divides" in ring of integers

With your input,

( r(gens[1]) / r(x) ).is_integral()

returns True. So, no, I see no problem here. However

sage: f = CyclotomicField(3)
sage: r.<z> = f.ring_of_integers()
sage: r(2).divides(z)
True
sage: (z/2).is_integral()
False

which is fishy.

2014-07-19 02:40:34 +0200 commented answer How Do I Extract Terms Containing Certain Coefficients From A Polynomial?

Careful: there's an indentation level missing after the second for

2014-07-19 02:37:15 +0200 commented answer How Do I Extract Terms Containing Certain Coefficients From A Polynomial?

To convert back to polynomial, just sum() over the list.

2014-07-19 00:48:16 +0200 answered a question How Do I Extract Terms Containing Certain Coefficients From A Polynomial?

I am not sure how I should interpret your criterion: do you want to allow a variable to appear more than once in the same monomial? Supposing you do, and supposing p is your polynomial expression, here's a fancy solution

[m for m in p.iterator() if sum(m({x:0}).is_zero() for x in (i_L, d, v_g, v_C)) == 1]

There's certainly many other, but I am afraid none is going to be very simple. A word of explanation:

  • The first for loops over each monomial.
  • For each monomial m, m({x:0}) evaluates the monomial at the point x=0, where x ranges over i_L, d, etc.
  • If is_zero() returns True, the variable is obviously in the monomial.
  • In a summation, True and False get converted to 0 and 1, thus sum(...) == 1 guarantees that the monomial contains exactly one of the variables i_l, d, etc.

Thanks for this refreshing riddle :)

2014-07-18 16:37:45 +0200 commented answer How th work with enumerable and infinite set
2014-07-18 16:25:06 +0200 answered a question How th work with enumerable and infinite set

You just found a bug in Sage. Sage does not have enough knowledge to know that the set of rationals that are not prime numbers is infinite. If there was no bug, you'd have an error saying something like "Sage cannot compute the cardinality of B".

However, if you type B.cardinality??, you'll notice that what the function does is simply return len(list(self)), i.e. it constructs the list of ALL rationals that are not prime numbers, and returns its length. You get no answer because it's entered an infinite loop.

2014-06-14 08:24:01 +0200 received badge  Nice Answer (source)
2014-06-13 08:34:34 +0200 answered a question Find algebraic solutions to system of polynomial equations

Yes, you can use Gröbner bases. Here is an example

sage: A.<x,y,z> = QQ[]
sage: I = A.ideal(z*x^2-y, y^2-x*y, x^3+1)
sage: I.variety()
[{y: -1, z: -1, x: -1}, {y: 0, z: 0, x: -1}]

Tis is not implemented with coefficients in RR and will raise an error. However You can still ask for a Gröbner basis

sage: A.<x,y,z> = RR[]
sage: I = A.ideal(z*x^2-y, y^2-x*y, x^3+1)
sage: I.groebner_basis()
[x^3 + 1.00000000000000, x*y + z, y^2 + z, x*z - y*z, z^2 + y]
2014-04-30 12:12:04 +0200 commented question derivative of MPolynomial_polydict

I'm sorry. This doesn't help either. If you want useful help, you must make an useful effort to isolate the potential bug. It is by putting less code, not more, that you will achieve this: I cannot guess what parameters to `lambda_siep` are going to trigger the bug.

2014-04-29 10:37:24 +0200 commented question derivative of MPolynomial_polydict

I cannot reproduce your problem. Please give a complete working example. How much is `n`? Who's `Y`? There's a missing braket in your definition of `R`.

2014-04-17 14:43:01 +0200 answered a question Silverman Appendix G

Don't think so. Maybe you'll have more interesting answers on the sage-nt list https://groups.google.com/forum/#!forum/sage-nt

2014-02-17 13:36:12 +0200 answered a question Cutting unnecessary zeroes in float numbers

You could just check that

type(x) == float

Or, instead of round, you could use python's string formatter.

"{:.5g}".format(x)

will format x using 5 digits of precision (including before and after the decimal separator), removing trailing zeroes and the decimal dot for integers. Not exactly equivalent to your code, but maybe it will be good enough for your use.

If you have a locale configured for French/Italian/whatever notation

"{:.5n}".format(x)

will automatically put a comma instead of a dot for you.