Re: [sage-devel] Re: How much do we support the casual user

2021-08-30 Thread seb....@gmail.com
FYI: Note that there currently is a ticket(#32321 ) to make changes to the global `is_prime` function treating the subject discussed here. wst...@gmail.com schrieb am Dienstag, 10. April 2018 um 07:02:18 UTC+2: > On Mon, Apr 9, 2018 at 8:12 PM saad

Re: [sage-devel] Re: How much do we support the casual user

2018-04-09 Thread William Stein
On Mon, Apr 9, 2018 at 8:12 PM saad khalid wrote: > Have we come to any conclusions on what steps should be taken after this > topic? What seems to be the concensus? Or, at the very least, could someone > give a listing of the options we have so that we can give it a poll or

[sage-devel] Re: How much do we support the casual user

2018-04-09 Thread saad khalid
Have we come to any conclusions on what steps should be taken after this topic? What seems to be the concensus? Or, at the very least, could someone give a listing of the options we have so that we can give it a poll or something similar? On Monday, April 2, 2018 at 2:58:36 AM UTC-5, Sebastian

[sage-devel] Re: How much do we support the casual user

2018-04-02 Thread Sebastian Oehms
Hello, This topic is a good example, that wrong names can be worse than wrong code. Only the user knows what he has in mind using the adjective "prime": 1) prime in a "narrower sense": being a prime number 2) prime in a "broader sense": being a prime element of a unital commutative ring

Re: [sage-devel] Re: How much do we support the casual user

2018-03-30 Thread Volker Braun
On Friday, March 30, 2018 at 6:35:12 PM UTC+2, John Cremona wrote: > > I don't think this will satisfy Ralf's casual user who will see 100 > warnings output from their loop and not find any of the primes they were > hoping for. > By default, the warning is only shown once in said loop. If the

Re: [sage-devel] Re: How much do we support the casual user

2018-03-30 Thread John Cremona
On 30 March 2018 at 09:22, Simon King wrote: > On 2018-03-30, Volker Braun wrote: > > The obvious answer: Show a warning if you test field elements for > primality > > * easy to implement using standard Python machinery > > * does not introduce

[sage-devel] Re: How much do we support the casual user

2018-03-30 Thread mmarco
What about creating a `is_prime_integer` function? Explicit is better than implicit, and in that case we leave no ambiguity in the mathematical sense, but also cover the use case of the casual user. What i definitely don't want is `.is_prime()` return `True` when it is applied to an element

[sage-devel] Re: How much do we support the casual user

2018-03-30 Thread Simon King
On 2018-03-30, Volker Braun wrote: > The obvious answer: Show a warning if you test field elements for primality > * easy to implement using standard Python machinery > * does not introduce backward-incompatibile changes > * is mathematically correct > * informative to

[sage-devel] Re: How much do we support the casual user

2018-03-29 Thread saad khalid
I'm not entirely sure how to implement this though, if we don't want it to be the global behavior. I was considering just implementing it for the rank() function, but I'm assuming it processes the input into the function before it starts running the actual function, right? So it isn't just

[sage-devel] Re: How much do we support the casual user

2018-03-29 Thread Volker Braun
The obvious answer: Show a warning if you test field elements for primality * easy to implement using standard Python machinery * does not introduce backward-incompatibile changes * is mathematically correct * informative to casual users * unlikely to give spurious warnings in existing code --

Re: [sage-devel] Re: How much do we support the casual user

2018-03-29 Thread Nils Bruin
On Thursday, March 29, 2018 at 11:57:32 AM UTC-7, William wrote: > > > Thanks -- I should have added that the above was a quick "proof of > concept". > > In fact, letting 1.3e5 still be parsed as a float literal would make this modified behaviour just extremely annoying rather than completely

Re: [sage-devel] Re: How much do we support the casual user

2018-03-29 Thread William Stein
On Thu, Mar 29, 2018 at 11:56 AM, Nils Bruin wrote: > On Thursday, March 29, 2018 at 10:37:03 AM UTC-7, William wrote: >> >> >> It's surprisingly easy to implement this, due to how Robert Bradshaw >> rewrote this part of the Sage preparser.If you define this >> function in a

Re: [sage-devel] Re: How much do we support the casual user

2018-03-29 Thread Nils Bruin
On Thursday, March 29, 2018 at 10:37:03 AM UTC-7, William wrote: > > > It's surprisingly easy to implement this, due to how Robert Bradshaw > rewrote this part of the Sage preparser.If you define this > function in a notebook or command line sage session: > > def RealNumber(s): > if

Re: [sage-devel] Re: How much do we support the casual user

2018-03-29 Thread William Stein
On Wed, Mar 28, 2018 at 11:01 PM, saad khalid wrote: > On Wednesday, March 28, 2018 at 1:52:17 AM UTC-5, Simon King wrote: >> >> Hi Andrey and Saad, >> >> On 2018-03-28, Andrey Novoseltsev wrote: >> > On Tuesday, 27 March 2018 18:03:48 UTC-6, saad khalid

[sage-devel] Re: How much do we support the casual user

2018-03-29 Thread saad khalid
On Wednesday, March 28, 2018 at 1:52:17 AM UTC-5, Simon King wrote: > > Hi Andrey and Saad, > > On 2018-03-28, Andrey Novoseltsev > wrote: > > On Tuesday, 27 March 2018 18:03:48 UTC-6, saad khalid wrote: > >> > >> Why not assume by default that when someone enters a

[sage-devel] Re: How much do we support the casual user

2018-03-28 Thread Simon King
On 2018-03-28, Vincent Delecroix <20100.delecr...@gmail.com> wrote: > > > On 28/03/2018 08:44, Simon King wrote: >> Hi Vincent, >> >> On 2018-03-28, Vincent Delecroix <20100.delecr...@gmail.com> wrote: >>> Anyway the rank of a floating point matrix is a bad notion. See also my >>> answer here for

Re: [sage-devel] Re: How much do we support the casual user

2018-03-28 Thread rjf
There is a history of CAS providing strong mathematical typing as part of the user interface, as in Sage. Those systems have been unpopular. Axiom, FriCAS. Users tend to be mathematicians. There is a history of pasting on formal mathematical typing on other systems. Maple, and (I think)

Re: [sage-devel] Re: How much do we support the casual user

2018-03-28 Thread Vincent Delecroix
On 28/03/2018 08:44, Simon King wrote: Hi Vincent, On 2018-03-28, Vincent Delecroix <20100.delecr...@gmail.com> wrote: Anyway the rank of a floating point matrix is a bad notion. See also my answer here for the computation of the "kernel" It isn't necessarily a bad notion if you define it

[sage-devel] Re: How much do we support the casual user

2018-03-28 Thread kcrisman
> > > I thought I'd try Sage for a casual computation. I was interested in which > numbers of the form (2^n - (-1)^n)/3 are prime. I first tried out n=23: > > sage: (2^23+1)/3 > 2796203 > sage: _.is_prime() > False > sage: factor(2796203) > 2796203 > > It turns out that Rational.is_prime does

Re: [sage-devel] Re: How much do we support the casual user

2018-03-28 Thread Dima Pasechnik
I think that we just need a beginner mode, with all such restricted defauls... -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: [sage-devel] Re: How much do we support the casual user

2018-03-28 Thread 'Martin R' via sage-devel
I also think that this (restricting the global function is_prime to input that look like integers) is a very elegant solution. I would actually guess that novice users tend to try global functions first, and I am often surprised how long it takes some people to discover tab-completion. Martin

Re: [sage-devel] Re: How much do we support the casual user

2018-03-28 Thread mforets
One question: if 3/1 is not prime but ZZ(3/1) is, shouldn't 3/1 == ZZ(3/1) return False? (I don't know how does sage evaluate == , is it documented? I searched for "==" in the docs and got nothing, and "equivalence" gives a super long list.) El miércoles, 28 de marzo de 2018, 9:02:41 (UTC-3),

Re: [sage-devel] Re: How much do we support the casual user

2018-03-28 Thread John Cremona
I agree with both Marc's last 2 suggestions. If the global function is_prime() is called on an integer (even of type Rational) it should do the natural thing. Anything else raises an error with a helpful message that x.is_prime() might be what is wanted. On Wed, 28 Mar 2018, 12:19 Marc

[sage-devel] Re: How much do we support the casual user

2018-03-28 Thread Marc Mezzarobba
Dima Pasechnik wrote: > is_prime() should be restricted to rings in which one can have > non-trivial prime elements Well, that's what I'm doubting. If the goal is that the global is_prime() function doesn't do anything surprising for people who would have integers in mind, then it may be better

[sage-devel] Re: How much do we support the casual user

2018-03-28 Thread Dima Pasechnik
On Wednesday, March 28, 2018 at 10:07:17 AM UTC+1, Marc Mezzarobba wrote: > > Simon King wrote: > > That makes sense to me. > > Thus I now think, z.is_prime() should roughly work like this: > > def is_prime(self): > > ... > > What about keeping the is_prime() *method* unchanged (except

[sage-devel] Re: How much do we support the casual user

2018-03-28 Thread Dima Pasechnik
On Wednesday, March 28, 2018 at 9:25:07 AM UTC+1, Simon King wrote: > > Hi Ralf, > > On 2018-03-28, Ralf Stephan wrote: > > Ask yourself, are these arguments you give for current is_prime(x) > > behaviour not just the inertia of your thinking. > > No. It is a sign of

Re: [sage-devel] Re: How much do we support the casual user

2018-03-28 Thread Erik Bray
On Tue, Mar 27, 2018 at 9:37 PM, Eric Gourgoulhon wrote: > Hi Simon, hi Erik, > > > Le mardi 27 mars 2018 21:09:08 UTC+2, Simon King a écrit : >> >> Hi Erik, >> >> On 2018-03-27, Erik Bray wrote: >> > What about adding an optional argument to the

[sage-devel] Re: How much do we support the casual user

2018-03-28 Thread Simon King
Hi TB, On 2018-03-28, TB wrote: > A bit of future bike-shedding: I would not mind if QQ(3) be printed on > the command line as 3/1 or stay 3, but the LaTeX version is probably a > harder decision. For example, > > sage: latex([bernoulli(i) for i in range(10)]) > \left[1,

[sage-devel] Re: How much do we support the casual user

2018-03-28 Thread Marc Mezzarobba
Simon King wrote: > That makes sense to me. > Thus I now think, z.is_prime() should roughly work like this: > def is_prime(self): > ... What about keeping the is_prime() *method* unchanged (except perhaps for adding an optional warning in the default implementation for field elements), and

Re: [sage-devel] Re: How much do we support the casual user

2018-03-28 Thread John Cremona
On 28 March 2018 at 09:34, TB wrote: > On 28/03/18 10:33, Ralf Stephan wrote: > >> Ask yourself, are these arguments you give for current is_prime(x) >> behaviour not just the inertia of your thinking. >> >> Wolfram tells me plainly "1/3 (2^23 + 1) is a prime number"---no >>

Re: [sage-devel] Re: How much do we support the casual user

2018-03-28 Thread TB
On 28/03/18 11:22, Simon King wrote: As I said in an earlier post, I'd be in favour of changing printed output of basic number types in Sage, so that pasting output will result in a copy of the object. A bit of future bike-shedding: I would not mind if QQ(3) be printed on the command line as

Re: [sage-devel] Re: How much do we support the casual user

2018-03-28 Thread TB
On 28/03/18 10:33, Ralf Stephan wrote: Ask yourself, are these arguments you give for current is_prime(x) behaviour not just the inertia of your thinking. Wolfram tells me plainly "1/3 (2^23 + 1) is a prime number"---no ambiguity, no attempt to show a glimpse of algebraic truth. Pari gives

[sage-devel] Re: How much do we support the casual user

2018-03-28 Thread Dima Pasechnik
On Tuesday, March 27, 2018 at 8:07:41 AM UTC+1, Ralf Stephan wrote: > > Hello, > I thought I'd try Sage for a casual computation. I was interested in which > numbers of the form (2^n - (-1)^n)/3 are prime. I first tried out n=23: > > sage: (2^23+1)/3 > 2796203 > sage: _.is_prime() > False >

[sage-devel] Re: How much do we support the casual user

2018-03-28 Thread Simon King
Hi Ralf, On 2018-03-28, Ralf Stephan wrote: > Ask yourself, are these arguments you give for current is_prime(x) > behaviour not just the inertia of your thinking. No. It is a sign of appreciation of mathematical notions. Sorry to start with politics here, but I am against

[sage-devel] Re: How much do we support the casual user

2018-03-28 Thread Ralf Stephan
Ask yourself, are these arguments you give for current is_prime(x) behaviour not just the inertia of your thinking. Wolfram tells me plainly "1/3 (2^23 + 1) is a prime number"---no ambiguity, no attempt to show a glimpse of algebraic truth. Pari gives ? isprime((2^23+1)/3) %1 = 1 Giac: >>

[sage-devel] Re: How much do we support the casual user

2018-03-28 Thread Simon King
Hi Andrey and Saad, On 2018-03-28, Andrey Novoseltsev wrote: > On Tuesday, 27 March 2018 18:03:48 UTC-6, saad khalid wrote: >> >> Why not assume by default that when someone enters a floating point >> number, they intend it as a member of QQ, at least in this case. >> > >

[sage-devel] Re: How much do we support the casual user

2018-03-28 Thread Simon King
Hi Vincent, On 2018-03-28, Vincent Delecroix <20100.delecr...@gmail.com> wrote: > Anyway the rank of a floating point matrix is a bad notion. See also my > answer here for the computation of the "kernel" It isn't necessarily a bad notion if you define it in terms of singular value decomposition.

[sage-devel] Re: How much do we support the casual user

2018-03-28 Thread Simon King
On 2018-03-28, Andrey Novoseltsev wrote: > On Tuesday, 27 March 2018 13:57:12 UTC-6, Michael Orlitzky wrote: >> >> But will MATLAB tell you that two equal matrices have different ranks? I >> know sage will do it. >> > > A few years back it could give you completely different

[sage-devel] Re: How much do we support the casual user

2018-03-28 Thread Simon King
On 2018-03-28, saad khalid wrote: > So, in this case, > it Should assume that 3/1 is referring to the integer 3, use is_prime on > the integer, and then also give a warning stating that 3/1 was interpreted > as the integer 3. Then, we should have a function like

[sage-devel] Re: How much do we support the casual user

2018-03-27 Thread Eric Gourgoulhon
Hi Simon, hi Erik, Le mardi 27 mars 2018 21:09:08 UTC+2, Simon King a écrit : > > Hi Erik, > > On 2018-03-27, Erik Bray wrote: > > What about adding an optional argument to the is_prime() > > method--something like a.is_prime(as_element_of=ZZ). It's kind of a > > wordy

[sage-devel] Re: How much do we support the casual user

2018-03-27 Thread Simon King
Hi Erik, On 2018-03-27, Erik Bray wrote: > What about adding an optional argument to the is_prime() > method--something like a.is_prime(as_element_of=ZZ). It's kind of a > wordy (though I'm sure there's a more succinct spelling) way to write > ZZ(a).is_prime() but at

Re: [sage-devel] Re: How much do we support the casual user

2018-03-27 Thread David Roe
I've made https://trac.sagemath.org/ticket/25046. David On Tue, Mar 27, 2018 at 2:12 PM, William Stein wrote: > On Tue, Mar 27, 2018 at 11:06 AM, Nils Bruin wrote: > > On Tuesday, March 27, 2018 at 10:48:34 AM UTC-7, Ralf Stephan wrote: > >> > >> Nils, > >> >

Re: [sage-devel] Re: How much do we support the casual user

2018-03-27 Thread William Stein
On Tue, Mar 27, 2018 at 11:06 AM, Nils Bruin wrote: > On Tuesday, March 27, 2018 at 10:48:34 AM UTC-7, Ralf Stephan wrote: >> >> Nils, >> >> See https://trac.sagemath.org/ticket/21067 >> >> for a rational factor_list(). > > > I don't think that helps casual user's API at all. If I

[sage-devel] Re: How much do we support the casual user

2018-03-27 Thread Nils Bruin
On Tuesday, March 27, 2018 at 10:48:34 AM UTC-7, Ralf Stephan wrote: > > Nils, > > See https://trac.sagemath.org/ticket/21067 > > for a rational factor_list(). > I don't think that helps casual user's API at all. If I have to write SR(12/4).factor_list(), I'd rather write ZZ(12/4).factor(). In

[sage-devel] Re: How much do we support the casual user

2018-03-27 Thread Ralf Stephan
Nils, See https://trac.sagemath.org/ticket/21067 for a rational factor_list(). -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: [sage-devel] Re: How much do we support the casual user

2018-03-27 Thread William Stein
On Tue, Mar 27, 2018 at 9:59 AM, John Cremona wrote: > > > On 27 March 2018 at 17:43, Nils Bruin wrote: >> >> On Tuesday, March 27, 2018 at 9:35:34 AM UTC-7, William wrote: >>> >>> Just curious -- does that have the *potential* to break Magma library >>>

Re: [sage-devel] Re: How much do we support the casual user

2018-03-27 Thread John Cremona
On 27 March 2018 at 17:43, Nils Bruin wrote: > On Tuesday, March 27, 2018 at 9:35:34 AM UTC-7, William wrote: >> >> Just curious -- does that have the *potential* to break Magma library >> code? E.g., maybe deep in some package code I wrote 20 years ago >> for Magma, I use

Re: [sage-devel] Re: How much do we support the casual user

2018-03-27 Thread Nils Bruin
On Tuesday, March 27, 2018 at 9:35:34 AM UTC-7, William wrote: > > Just curious -- does that have the *potential* to break Magma library > code? E.g., maybe deep in some package code I wrote 20 years ago > for Magma, I use Factorization on a reational, and assume that the > output is

Re: [sage-devel] Re: How much do we support the casual user

2018-03-27 Thread William Stein
On Tue, Mar 27, 2018 at 9:23 AM, Nils Bruin wrote: > On Tuesday, March 27, 2018 at 12:07:41 AM UTC-7, Ralf Stephan wrote: >> >> Hello, >> I thought I'd try Sage for a casual computation. I was interested in which >> numbers of the form (2^n - (-1)^n)/3 are prime. I first tried out

[sage-devel] Re: How much do we support the casual user

2018-03-27 Thread Nils Bruin
On Tuesday, March 27, 2018 at 12:07:41 AM UTC-7, Ralf Stephan wrote: > > Hello, > I thought I'd try Sage for a casual computation. I was interested in which > numbers of the form (2^n - (-1)^n)/3 are prime. I first tried out n=23: > > sage: (2^23+1)/3 > 2796203 > sage: _.is_prime() > False >

Re: [sage-devel] Re: How much do we support the casual user

2018-03-27 Thread John Cremona
On 27 March 2018 at 09:26, Vincent Delecroix <20100.delecr...@gmail.com> wrote: > > > On 27/03/2018 10:05, Simon King wrote: > >> Hi Ralf, >> >> On 2018-03-27, Ralf Stephan wrote: >> >>> sage: (2^23+1)/3 >>> 2796203 >>> sage: _.is_prime() >>> False >>> sage: factor(2796203)

[sage-devel] Re: How much do we support the casual user

2018-03-27 Thread Ralf Stephan
On Tuesday, March 27, 2018 at 10:08:18 AM UTC+2, Simon King wrote: > > ...since your code is (implicitly!) asking for prime numbers in QQ. > > However, I agree that it is (for most users) unintended behaviour, and > as a corollary to "explicit is better than implicit", we have "implicit > is

Re: [sage-devel] Re: How much do we support the casual user

2018-03-27 Thread Vincent Delecroix
On 27/03/2018 10:05, Simon King wrote: Hi Ralf, On 2018-03-27, Ralf Stephan wrote: sage: (2^23+1)/3 2796203 sage: _.is_prime() False sage: factor(2796203) 2796203 It turns out that Rational.is_prime does not exist and the fallback gives false answers. My first

Re: [sage-devel] Re: How much do we support the casual user

2018-03-27 Thread John Cremona
Ralf, if you use // instead of / then it will do integer division and return integers. sage: for n in prime_range(100): : p = (2^n-(-1)^n)//3 : if p.is_prime(): : print p : 3 11 43 683 2731 43691 174763 2796203 715827883 2932031007403 768614336404564651

[sage-devel] Re: How much do we support the casual user

2018-03-27 Thread Simon King
On 2018-03-27, Simon King wrote: > I know that it is hardly possible to achieve that pasting of printed > output will ALWAYS create a copy of the printed object. However, in > cases where it is easily possible (the real number 1 should print as > 1.0, the rational number 1

[sage-devel] Re: How much do we support the casual user

2018-03-27 Thread Simon King
Hi Ralf, On 2018-03-27, Ralf Stephan wrote: > sage: (2^23+1)/3 > 2796203 > sage: _.is_prime() > False > sage: factor(2796203) > 2796203 > > It turns out that Rational.is_prime does not exist and the fallback gives > false answers. My first association: We should change the