[sage-devel] Re: Factorial syntax

2009-09-02 Thread Dr. David Kirkby

Tom Boothby wrote:
 On Mon, Aug 31, 2009 at 10:38 AM, Robert
 Bradshawrober...@math.washington.edu wrote:

 As for  the question at hand, I'm personally not convinced this is useful
 enough to merit another departure from pure Python. It also risks turning
 the valid Python expression x!=120 into an invalid one (unless the rule
 
 bah.  That's easy to get around.
 
 is something like ! becomes factorial unless it's followed by one, but
 not two, equals signs...) And then people might expect x!! to be the
 double factorial instead of (x!)!.
 
 Agreed.  If we were to implement this, we'd best look at other CAS's
 and see how they treat these issues.
 
 - Robert

Em, I thought I'd try this in Mathematica

In[1]:= 5!

Out[1]= 120

In[2]:= 5!!

Out[2]= 15

In[3]:= 5!!!

Out[3]= 1307674368000

In[4]:= 5

Out[4]= 2027025

In[5]:= 5!
spends a long time doing whatever it is trying to compute. 


Anyone like to guess what it's doing?



--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-09-02 Thread Dr. David Kirkby

Dr. David Kirkby wrote:

 Em, I thought I'd try this in Mathematica
 
 In[1]:= 5!
 
 Out[1]= 120
 
 In[2]:= 5!!
 
 Out[2]= 15
 
 In[3]:= 5!!!
 
 Out[3]= 1307674368000
 
 In[4]:= 5
 
 Out[4]= 2027025
 
 In[5]:= 5!
 spends a long time doing whatever it is trying to compute. 
 
 
 Anyone like to guess what it's doing?

Trying this in Wolfram Alpha

http://www.wolframalpha.com/input/?i=5%21%21

reveals what Mathematica is doing. Apparently n!! is the double factorial

http://reference.wolfram.com/mathematica/ref/Factorial2.html

n!! = nx(n-2)x(n-2)x...


As a non-mathematician I'd never herd of such a thing myself.

--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-09-02 Thread Dr. David Kirkby

Dr. David Kirkby wrote:
 Dr. David Kirkby wrote:
 
 Em, I thought I'd try this in Mathematica

 In[1]:= 5!

 Out[1]= 120

 In[2]:= 5!!

 Out[2]= 15

 In[3]:= 5!!!

 Out[3]= 1307674368000

 In[4]:= 5

 Out[4]= 2027025

 In[5]:= 5!
 spends a long time doing whatever it is trying to compute. 


 Anyone like to guess what it's doing?
 
 Trying this in Wolfram Alpha
 
 http://www.wolframalpha.com/input/?i=5%21%21
 
 reveals what Mathematica is doing. Apparently n!! is the double factorial
 
 http://reference.wolfram.com/mathematica/ref/Factorial2.html
 
 n!! = nx(n-2)x(n-2)x...
 
 
 As a non-mathematician I'd never herd of such a thing myself.
Also relevant to the discussion is

In[1]:= ?TrueQ
TrueQ[expr] yields True if expr is True, and yields False otherwise.

In[2]:= TrueQ[1==2]

Out[2]= False

In[3]:= TrueQ[5!=2]

Out[3]= True

In[4]:= TrueQ[5!=120]

Out[4]= True

In[5]:= TrueQ[5!=5]

Out[5]= False

And to work out the order of precedence on factorial and double-factorial.

In[6]:= (5!)!!

Out[6]= 
959344498183598695489193994766932218518248994260838989636409419529429\

 5395488811817369600

In[7]:= 5!!!

Out[7]= 1307674368000

In[8]:= (5!!)!

Out[8]= 1307674368000

In[9]:= 5

Out[9]= 2027025

In[10]:= (5!!)!!

Out[10]= 2027025




--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-09-02 Thread Jason Grout

Dr. David Kirkby wrote:
 Dr. David Kirkby wrote:
 
 Em, I thought I'd try this in Mathematica

 In[1]:= 5!

 Out[1]= 120

 In[2]:= 5!!

 Out[2]= 15

 In[3]:= 5!!!

 Out[3]= 1307674368000

 In[4]:= 5

 Out[4]= 2027025

 In[5]:= 5!
 spends a long time doing whatever it is trying to compute. 


 Anyone like to guess what it's doing?
 
 Trying this in Wolfram Alpha
 
 http://www.wolframalpha.com/input/?i=5%21%21
 
 reveals what Mathematica is doing. Apparently n!! is the double factorial
 
 http://reference.wolfram.com/mathematica/ref/Factorial2.html
 
 n!! = nx(n-2)x(n-2)x...
 
 
 As a non-mathematician I'd never herd of such a thing myself.
 

Wow, that seems totally ambiguous.  Is 5!!! equal to (5!!)! or (5!)!! or 
((5!)!)!  The notation is pretty bad in this case.

However note that:

In[1]:= 5! !

Out[1]= 
668950291344912705758811805409037258675274633313802981029567135230163\

  
355724496298936687416527198498130815763789321409055253440858940812185989\

 848111438965000596496052125696

(note the space between the exclamation points)

Jason


-- 
Jason Grout


--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-09-02 Thread Robert Bradshaw

On Sep 1, 2009, at 11:34 PM, Dr. David Kirkby wrote:


 Dr. David Kirkby wrote:
 Dr. David Kirkby wrote:

 Em, I thought I'd try this in Mathematica

 In[1]:= 5!

 Out[1]= 120

 In[2]:= 5!!

 Out[2]= 15

 In[3]:= 5!!!

 Out[3]= 1307674368000

 In[4]:= 5

 Out[4]= 2027025

 In[5]:= 5!
 spends a long time doing whatever it is trying to compute. 


 Anyone like to guess what it's doing?

 Trying this in Wolfram Alpha

 http://www.wolframalpha.com/input/?i=5%21%21

 reveals what Mathematica is doing. Apparently n!! is the double  
 factorial

 http://reference.wolfram.com/mathematica/ref/Factorial2.html

 n!! = nx(n-2)x(n-2)x...


 As a non-mathematician I'd never herd of such a thing myself.
 Also relevant to the discussion is

 In[1]:= ?TrueQ
 TrueQ[expr] yields True if expr is True, and yields False otherwise.

 In[2]:= TrueQ[1==2]

 Out[2]= False

 In[3]:= TrueQ[5!=2]

 Out[3]= True

 In[4]:= TrueQ[5!=120]

 Out[4]= True

 In[5]:= TrueQ[5!=5]

 Out[5]= False

 And to work out the order of precedence on factorial and double- 
 factorial.

 In[6]:= (5!)!!

 Out[6]=
 959344498183598695489193994766932218518248994260838989636409419529429\

5395488811817369600

 In[7]:= 5!!!

 Out[7]= 1307674368000

 In[8]:= (5!!)!

 Out[8]= 1307674368000

 In[9]:= 5

 Out[9]= 2027025

 In[10]:= (5!!)!!

 Out[10]= 2027025

If we support the ! notation, we should either have x!! == (x!)! or,  
preferably, x!!..! be the multi factorial (not limiting ourselves to  
single and double).

- Robert



--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-09-02 Thread Simon King

Hi!

On Sep 2, 7:40 am, Jason Grout jason-s...@creativetrax.com wrote:
 Wow, that seems totally ambiguous.  Is 5!!! equal to (5!!)! or (5!)!! or
 ((5!)!)!  The notation is pretty bad in this case.
[...]

Yes, and this is why the very common notation 5! is bad syntax that
should be avoided in a CAS, IMHO.

Of course, one could say that 5! should mean factorial of 5 unless
the following character is = as in 5!=3 or ! as in 5!!. But I
wouldn't paint a bike shed in that way. Just imagine how much fun it
is to find a bug like 5! ! (which probably is factorial(factorial
(5))) versus 5!! (which probably is double_factorial(5)).

If one starts like that, why not continue with [5] (quantum deformed
integers) and [5]! (quantum factorial)?
Or another very common notation: Should Sage really support d^2f(x,y)/
(dx*dy) to construct partial derivatives?

I think that a CAS without a strong programming language is nothing
but a simple pocket calculator. Therefore, if a mathematical notation
interferes too much with the requirements of the underlying
programming language, then the mathematical notation should be
dropped.

Compare this with the example given by Kwankyu: Rx=ZZ[] resembles a
chain of inequalities,
  sage: 56=3
  True
and R[x] is not compatible with Python's syntax (if R is to be
defined). Therefore, I think it is a very reasonable compromise to
have the additional dot in R.x

Cheers
Simon

--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-09-02 Thread Dan Drake
On Tue, 01 Sep 2009 at 11:42PM -0700, Robert Bradshaw wrote:
 If we support the ! notation, we should either have x!! == (x!)! or,
 preferably, x!!..! be the multi factorial (not limiting ourselves to
 single and double).

I study combinatorics, and I'm fine with *not* supporting ! notation.
Writing factorial(x) is obvious and unambiguous. If you want something
shorter, you can do f = factorial. Then the mysterious and ambiguous
examples above turn into something obvious: f(f(5)) or whatever. We
already have multifactorial support: (5).multifactorial(2) equals 5 *
3 * 1, and so on.

I don't see anyone strongly demanding ! notation, so I say we drop the
idea. We have factorial() and .multifactorial(), they work perfectly
well, and the syntax for using them is the same as in the rest of Sage.

Dan

-- 
---  Dan Drake
-  http://mathsci.kaist.ac.kr/~drake
---


signature.asc
Description: Digital signature


[sage-devel] Re: Factorial syntax

2009-09-02 Thread David Kirkby

2009/9/2 Dan Drake dr...@kaist.edu:
 On Tue, 01 Sep 2009 at 11:42PM -0700, Robert Bradshaw wrote:
 If we support the ! notation, we should either have x!! == (x!)! or,
 preferably, x!!..! be the multi factorial (not limiting ourselves to
 single and double).

 I study combinatorics, and I'm fine with *not* supporting ! notation.
 Writing factorial(x) is obvious and unambiguous. If you want something
 shorter, you can do f = factorial. Then the mysterious and ambiguous
 examples above turn into something obvious: f(f(5)) or whatever. We
 already have multifactorial support: (5).multifactorial(2) equals 5 *
 3 * 1, and so on.

 I don't see anyone strongly demanding ! notation, so I say we drop the
 idea. We have factorial() and .multifactorial(), they work perfectly
 well, and the syntax for using them is the same as in the rest of Sage.

 Dan

To me at least writing 'factorial(n)' is a bit clumbersome, compared
to what I would expect. Mathematica supports

Plus[2,3]
= 5

and Factorial[5]
= 120

but I doubt I'd ever want to write 'Plus' or 'Factorial' out in full,
which there are such commonly used symbols for this.

But clearly Mathemaitca shows there is some ambiguity about how
multiple exclamation marks are used.


Dave

--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-09-02 Thread kcrisman



 But clearly Mathemaitca shows there is some ambiguity about how
 multiple exclamation marks are used.

Yes, unfortunately math is filled with such contextual ambiguity and/
or conflicting conventions (for instance, is i an indexing integer or
a root of -1?).  I'm usually all for multiple modes, but this is one
place where even I would draw the line.

- kcrisman
--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-09-02 Thread David Kirkby

2009/9/2 kcrisman kcris...@gmail.com:



 But clearly Mathemaitca shows there is some ambiguity about how
 multiple exclamation marks are used.

 Yes, unfortunately math is filled with such contextual ambiguity and/
 or conflicting conventions (for instance, is i an indexing integer or
 a root of -1?).  I'm usually all for multiple modes, but this is one
 place where even I would draw the line.

 - kcrisman

'i' is current. 'j' is the square root of -1 (to us electrical
engineers anyway!)

Dave

--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-09-02 Thread Tom Boothby

On Tue, Sep 1, 2009 at 11:34 PM, Dr. David
Kirkbydavid.kir...@onetel.net wrote:

 In[7]:= 5!!!

 Out[7]= 1307674368000

 In[8]:= (5!!)!

 Out[8]= 1307674368000

 In[9]:= 5

 Out[9]= 2027025

 In[10]:= (5!!)!!

 Out[10]= 2027025


Yuck.  -1 to compatibility with this.  All or nothing -- if you're
going to support double factorial, you should support any
multifactorial.  Reasonably, we can't expect to support arbitrary math
input.  We don't support |A| where len(A) does the job, and we don't
accept half-open interval notation, either.  I've made up my mind, I
don't support the factorial notation.

-1.

--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-09-02 Thread Kwankyu


 I think that a CAS without a strong programming language is nothing
 but a simple pocket calculator. Therefore, if a mathematical notation
 interferes too much with the requirements of the underlying
 programming language, then the mathematical notation should be
 dropped.

I vote +1 for this argument


 Compare this with the example given by Kwankyu: Rx=ZZ[] resembles a
 chain of inequalities,
   sage: 56=3
   True
 and R[x] is not compatible with Python's syntax (if R is to be
 defined). Therefore, I think it is a very reasonable compromise to
 have the additional dot in R.x


This explanation makes sense. Thank you.

Kwankyu
--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-09-01 Thread Tom Boothby

On Mon, Aug 31, 2009 at 10:38 AM, Robert
Bradshawrober...@math.washington.edu wrote:

 On Mon, 31 Aug 2009, William Stein wrote:

 On Mon, Aug 31, 2009 at 8:23 AM, rjf fate...@gmail.com wrote:


 You can either
 (a) adhere to Python syntax.
 (b) adhere to Python except for a few changes that are so subtle that
 no one would even notice.
 (c) adhere to Python except for a few more changes that you tell
 everyone about and hope that the discrepancy between Sage and Python
 (and Cython) will not be noticed by critics, and so you can continue
 to claim Sage is just Python and everyone knows and loves Python.
 (d) use Python as a base, and add whatever you want, because you now
 have your own preparser and can add, say, postfix !.  And now you
 probably should tell your users that the Sage language is python
 inspired.
 (e) use your own parser for your own made up language that looks like
 some mathematical notation.

 Maxima/Macsyma is in category (d) or (e):  it uses its own parser for
 Algol 60 as a base and added things to it, but also has a syntax-
 extension feature so that the parser can be changed by the user.  e.g.
 commands to add new post-fix operators etc.  (At run-time).

 One of the premises and alleged great advantages of Sage was, I
 thought, that it is just Python, and you seem to be casually tossing
 that idea into the trash.
 (The idea that the user-language and the implementation-language for a
 computer algebra system has been a topic for discussion at least since
 the early 1970s, so the idea that all those clever people just missed
 the boat -- the solution is Python; Python does it all; seemed a bit
 simplistic.  So I'm not surprised at the slippage, to a pre-parser
 and Cython and now , oh, let's add a postfix !.)


 Wow, you are truly the master of flamebait!

 I don't consider this flamebait, I think it's a rather accurate (though
 blunt) assessment of the uneasieness some people have regarding the
 preparser.

I agree... though I'd describe it as overly dramatic, not blunt.
I'm frequently annoyed by the preprocessor and certain symbolic
constructs.  I prefer to use Sage as a library about 90% of the time.
OTOH, what rjf seems to be missing is that we aren't breaking
compatibility with Python -- I generally support features that (a)
would be syntax errors anyway (b) don't slow the preprocessor down,
and (c) are wildly useful.

(a) and (b) are satisfied by this feature request... but I'm not sure about (c).

 I'd say Sage is between (c) and (d)--just the fact that we're having this
 discussion means we're not willing to just go and add stuff to the
 preparser left and right.

 As for  the question at hand, I'm personally not convinced this is useful
 enough to merit another departure from pure Python. It also risks turning
 the valid Python expression x!=120 into an invalid one (unless the rule

bah.  That's easy to get around.

 is something like ! becomes factorial unless it's followed by one, but
 not two, equals signs...) And then people might expect x!! to be the
 double factorial instead of (x!)!.

Agreed.  If we were to implement this, we'd best look at other CAS's
and see how they treat these issues.


 - Robert


 


--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-09-01 Thread Kwankyu

Hi,

Out of curiosity, I want to ask why Sage has the syntax R.x = QQ[]
rather than Rx = QQ[]?  It seems to me that the dot is redundant.
Is it something the preparser cann't do?


Kwankyu
--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-08-31 Thread rjf

You can either
(a) adhere to Python syntax.
(b) adhere to Python except for a few changes that are so subtle that
no one would even notice.
(c) adhere to Python except for a few more changes that you tell
everyone about and hope that the discrepancy between Sage and Python
(and Cython) will not be noticed by critics, and so you can continue
to claim Sage is just Python and everyone knows and loves Python.
(d) use Python as a base, and add whatever you want, because you now
have your own preparser and can add, say, postfix !.  And now you
probably should tell your users that the Sage language is python
inspired.
(e) use your own parser for your own made up language that looks like
some mathematical notation.

Maxima/Macsyma is in category (d) or (e):  it uses its own parser for
Algol 60 as a base and added things to it, but also has a syntax-
extension feature so that the parser can be changed by the user.  e.g.
commands to add new post-fix operators etc.  (At run-time).

One of the premises and alleged great advantages of Sage was, I
thought, that it is just Python, and you seem to be casually tossing
that idea into the trash.
(The idea that the user-language and the implementation-language for a
computer algebra system has been a topic for discussion at least since
the early 1970s, so the idea that all those clever people just missed
the boat -- the solution is Python; Python does it all; seemed a bit
simplistic.  So I'm not surprised at the slippage, to a pre-parser
and Cython and now , oh, let's add a postfix !.)

But what I think is appropriate here is an explicit formulation about
what you are doing, either (a)(e)  or something else, and the
consequences.

RJF





On Aug 29, 10:13 am, William Stein wst...@gmail.com wrote:
 On Sat, Aug 29, 2009 at 10:10 AM, Jason Grout
 jason-s...@creativetrax.comwrote:





  Fredrik Johansson wrote:
   Hi,

   How about supporting n! as a shortcut for factorial(n)? This syntax is
   very convenient and makes a huge difference for combinatorial
   expressions with many factorials. MM (Maple  Mathematica) allow this
   notation, as do many scientific calculators.

   Although Python doesn't have any other postfix operators, I don't
   think there's any ambiguity as ! is unused in Python except for the !=
   operator. The worst I can come up with is x!=y, but given that =
   denotes assignment and not equality, this still only has one possible
   meaning.

  In an attempt to find places that ! could be used, I found the
  following interesting thing.

  sage: var('x!')
  x!
  sage: _^2
  x!^2
  sage: x!
  
     File ipython console, line 1
       x!
        ^
  SyntaxError: invalid syntax

  Maybe Sage symbolic variables should be restricted to identifiers that
  are legal in python...

 Yes, definitely +1 to that.  I think this used to be the case at some point.

 William
--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-08-31 Thread William Stein
On Mon, Aug 31, 2009 at 8:23 AM, rjf fate...@gmail.com wrote:


 You can either
 (a) adhere to Python syntax.
 (b) adhere to Python except for a few changes that are so subtle that
 no one would even notice.
 (c) adhere to Python except for a few more changes that you tell
 everyone about and hope that the discrepancy between Sage and Python
 (and Cython) will not be noticed by critics, and so you can continue
 to claim Sage is just Python and everyone knows and loves Python.
 (d) use Python as a base, and add whatever you want, because you now
 have your own preparser and can add, say, postfix !.  And now you
 probably should tell your users that the Sage language is python
 inspired.
 (e) use your own parser for your own made up language that looks like
 some mathematical notation.

 Maxima/Macsyma is in category (d) or (e):  it uses its own parser for
 Algol 60 as a base and added things to it, but also has a syntax-
 extension feature so that the parser can be changed by the user.  e.g.
 commands to add new post-fix operators etc.  (At run-time).

 One of the premises and alleged great advantages of Sage was, I
 thought, that it is just Python, and you seem to be casually tossing
 that idea into the trash.
 (The idea that the user-language and the implementation-language for a
 computer algebra system has been a topic for discussion at least since
 the early 1970s, so the idea that all those clever people just missed
 the boat -- the solution is Python; Python does it all; seemed a bit
 simplistic.  So I'm not surprised at the slippage, to a pre-parser
 and Cython and now , oh, let's add a postfix !.)


Wow, you are truly the master of flamebait!

 -- William

--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-08-31 Thread John Cremona

We have not actually had any +1 votes for a new postfix ! operator, so
it's bit premature to criticise that decision be fore it hasn't been
made.  (William's +1 was for a different suggestion, that Sage's
symbolic variables should not be allowed to be wider than python's.
Again, keeping to python conventions if at all possible.

John
(a veteran Algol 68 programmer, though not Algol 60!)

2009/8/31 rjf fate...@gmail.com:

 You can either
 (a) adhere to Python syntax.
 (b) adhere to Python except for a few changes that are so subtle that
 no one would even notice.
 (c) adhere to Python except for a few more changes that you tell
 everyone about and hope that the discrepancy between Sage and Python
 (and Cython) will not be noticed by critics, and so you can continue
 to claim Sage is just Python and everyone knows and loves Python.
 (d) use Python as a base, and add whatever you want, because you now
 have your own preparser and can add, say, postfix !.  And now you
 probably should tell your users that the Sage language is python
 inspired.
 (e) use your own parser for your own made up language that looks like
 some mathematical notation.

 Maxima/Macsyma is in category (d) or (e):  it uses its own parser for
 Algol 60 as a base and added things to it, but also has a syntax-
 extension feature so that the parser can be changed by the user.  e.g.
 commands to add new post-fix operators etc.  (At run-time).

 One of the premises and alleged great advantages of Sage was, I
 thought, that it is just Python, and you seem to be casually tossing
 that idea into the trash.
 (The idea that the user-language and the implementation-language for a
 computer algebra system has been a topic for discussion at least since
 the early 1970s, so the idea that all those clever people just missed
 the boat -- the solution is Python; Python does it all; seemed a bit
 simplistic.  So I'm not surprised at the slippage, to a pre-parser
 and Cython and now , oh, let's add a postfix !.)

 But what I think is appropriate here is an explicit formulation about
 what you are doing, either (a)(e)  or something else, and the
 consequences.

 RJF





 On Aug 29, 10:13 am, William Stein wst...@gmail.com wrote:
 On Sat, Aug 29, 2009 at 10:10 AM, Jason Grout
 jason-s...@creativetrax.comwrote:





  Fredrik Johansson wrote:
   Hi,

   How about supporting n! as a shortcut for factorial(n)? This syntax is
   very convenient and makes a huge difference for combinatorial
   expressions with many factorials. MM (Maple  Mathematica) allow this
   notation, as do many scientific calculators.

   Although Python doesn't have any other postfix operators, I don't
   think there's any ambiguity as ! is unused in Python except for the !=
   operator. The worst I can come up with is x!=y, but given that =
   denotes assignment and not equality, this still only has one possible
   meaning.

  In an attempt to find places that ! could be used, I found the
  following interesting thing.

  sage: var('x!')
  x!
  sage: _^2
  x!^2
  sage: x!
  
     File ipython console, line 1
       x!
        ^
  SyntaxError: invalid syntax

  Maybe Sage symbolic variables should be restricted to identifiers that
  are legal in python...

 Yes, definitely +1 to that.  I think this used to be the case at some point.

 William
 


--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-08-31 Thread Robert Bradshaw

On Mon, 31 Aug 2009, William Stein wrote:

 On Mon, Aug 31, 2009 at 8:23 AM, rjf fate...@gmail.com wrote:


 You can either
 (a) adhere to Python syntax.
 (b) adhere to Python except for a few changes that are so subtle that
 no one would even notice.
 (c) adhere to Python except for a few more changes that you tell
 everyone about and hope that the discrepancy between Sage and Python
 (and Cython) will not be noticed by critics, and so you can continue
 to claim Sage is just Python and everyone knows and loves Python.
 (d) use Python as a base, and add whatever you want, because you now
 have your own preparser and can add, say, postfix !.  And now you
 probably should tell your users that the Sage language is python
 inspired.
 (e) use your own parser for your own made up language that looks like
 some mathematical notation.

 Maxima/Macsyma is in category (d) or (e):  it uses its own parser for
 Algol 60 as a base and added things to it, but also has a syntax-
 extension feature so that the parser can be changed by the user.  e.g.
 commands to add new post-fix operators etc.  (At run-time).

 One of the premises and alleged great advantages of Sage was, I
 thought, that it is just Python, and you seem to be casually tossing
 that idea into the trash.
 (The idea that the user-language and the implementation-language for a
 computer algebra system has been a topic for discussion at least since
 the early 1970s, so the idea that all those clever people just missed
 the boat -- the solution is Python; Python does it all; seemed a bit
 simplistic.  So I'm not surprised at the slippage, to a pre-parser
 and Cython and now , oh, let's add a postfix !.)


 Wow, you are truly the master of flamebait!

I don't consider this flamebait, I think it's a rather accurate (though 
blunt) assessment of the uneasieness some people have regarding the 
preparser.

I'd say Sage is between (c) and (d)--just the fact that we're having this 
discussion means we're not willing to just go and add stuff to the 
preparser left and right.

As for  the question at hand, I'm personally not convinced this is useful 
enough to merit another departure from pure Python. It also risks turning 
the valid Python expression x!=120 into an invalid one (unless the rule 
is something like ! becomes factorial unless it's followed by one, but 
not two, equals signs...) And then people might expect x!! to be the 
double factorial instead of (x!)!.

- Robert


--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-08-31 Thread TimDaly

I also don't consider Fateman's comments flamebait.

This kind of syntactic-philosopy discussion comes up frequently on CA
mailing lists.

I've had an offline discussion about supporting the quantum mechanical
ket
operator with the syntax of |state. One possible implementation is
to
consider the vert and less-than symbols to be syntactic sugar for (
and )
However, supporting |state would involve Axiom parser changes.

There appear to be three target audiences, the programmers, the
mathematicians,
and the computational mathematicians. Sage has clearly been singing to
the
programmers. A postfix ! would appeal more to the mathematicians.

Fateman, being in the computational mathematician category has a clear
understanding of the range of tradeoffs. I suspect his blunt tone is
due to
the fact that, as he says,  this has been debated since the 1970s.
However,
he's being quite clear about the range of possible philosophical
responses.

-Tim

On Aug 31, 1:38 pm, Robert Bradshaw rober...@math.washington.edu
wrote:
 On Mon, 31 Aug 2009, William Stein wrote:
  On Mon, Aug 31, 2009 at 8:23 AM, rjf fate...@gmail.com wrote:

  You can either
  (a) adhere to Python syntax.
  (b) adhere to Python except for a few changes that are so subtle that
  no one would even notice.
  (c) adhere to Python except for a few more changes that you tell
  everyone about and hope that the discrepancy between Sage and Python
  (and Cython) will not be noticed by critics, and so you can continue
  to claim Sage is just Python and everyone knows and loves Python.
  (d) use Python as a base, and add whatever you want, because you now
  have your own preparser and can add, say, postfix !.  And now you
  probably should tell your users that the Sage language is python
  inspired.
  (e) use your own parser for your own made up language that looks like
  some mathematical notation.

  Maxima/Macsyma is in category (d) or (e):  it uses its own parser for
  Algol 60 as a base and added things to it, but also has a syntax-
  extension feature so that the parser can be changed by the user.  e.g.
  commands to add new post-fix operators etc.  (At run-time).

  One of the premises and alleged great advantages of Sage was, I
  thought, that it is just Python, and you seem to be casually tossing
  that idea into the trash.
  (The idea that the user-language and the implementation-language for a
  computer algebra system has been a topic for discussion at least since
  the early 1970s, so the idea that all those clever people just missed
  the boat -- the solution is Python; Python does it all; seemed a bit
  simplistic.  So I'm not surprised at the slippage, to a pre-parser
  and Cython and now , oh, let's add a postfix !.)

  Wow, you are truly the master of flamebait!

 I don't consider this flamebait, I think it's a rather accurate (though
 blunt) assessment of the uneasieness some people have regarding the
 preparser.

 I'd say Sage is between (c) and (d)--just the fact that we're having this
 discussion means we're not willing to just go and add stuff to the
 preparser left and right.

 As for  the question at hand, I'm personally not convinced this is useful
 enough to merit another departure from pure Python. It also risks turning
 the valid Python expression x!=120 into an invalid one (unless the rule
 is something like ! becomes factorial unless it's followed by one, but
 not two, equals signs...) And then people might expect x!! to be the
 double factorial instead of (x!)!.

 - Robert
--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-08-29 Thread John Cremona

2009/8/29 Fredrik Johansson fredrik.johans...@gmail.com:

 Hi,

 How about supporting n! as a shortcut for factorial(n)? This syntax is
 very convenient and makes a huge difference for combinatorial
 expressions with many factorials. MM (Maple  Mathematica) allow this
 notation, as do many scientific calculators.

 Although Python doesn't have any other postfix operators, I don't
 think there's any ambiguity as ! is unused in Python except for the !=
 operator. The worst I can come up with is x!=y, but given that =
 denotes assignment and not equality, this still only has one possible
 meaning.

I seem to remember this coming up before, and the consensus being that
we want to avoid adding stuff to the preparser unless it is really
crucial.  I could not find that discussion though, so I may be
forgetting the arguments.

John

--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-08-29 Thread Jason Grout

Fredrik Johansson wrote:
 Hi,
 
 How about supporting n! as a shortcut for factorial(n)? This syntax is
 very convenient and makes a huge difference for combinatorial
 expressions with many factorials. MM (Maple  Mathematica) allow this
 notation, as do many scientific calculators.
 
 Although Python doesn't have any other postfix operators, I don't
 think there's any ambiguity as ! is unused in Python except for the !=
 operator. The worst I can come up with is x!=y, but given that =
 denotes assignment and not equality, this still only has one possible
 meaning.
 


In an attempt to find places that ! could be used, I found the 
following interesting thing.

sage: var('x!')
x!
sage: _^2
x!^2
sage: x!

File ipython console, line 1
  x!
   ^
SyntaxError: invalid syntax


Maybe Sage symbolic variables should be restricted to identifiers that 
are legal in python...

Jason

--
Jason Grout


--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-devel] Re: Factorial syntax

2009-08-29 Thread William Stein
On Sat, Aug 29, 2009 at 10:10 AM, Jason Grout
jason-s...@creativetrax.comwrote:


 Fredrik Johansson wrote:
  Hi,
 
  How about supporting n! as a shortcut for factorial(n)? This syntax is
  very convenient and makes a huge difference for combinatorial
  expressions with many factorials. MM (Maple  Mathematica) allow this
  notation, as do many scientific calculators.
 
  Although Python doesn't have any other postfix operators, I don't
  think there's any ambiguity as ! is unused in Python except for the !=
  operator. The worst I can come up with is x!=y, but given that =
  denotes assignment and not equality, this still only has one possible
  meaning.
 


 In an attempt to find places that ! could be used, I found the
 following interesting thing.

 sage: var('x!')
 x!
 sage: _^2
 x!^2
 sage: x!
 
File ipython console, line 1
  x!
   ^
 SyntaxError: invalid syntax


 Maybe Sage symbolic variables should be restricted to identifiers that
 are legal in python...


Yes, definitely +1 to that.  I think this used to be the case at some point.

William

--~--~-~--~~~---~--~~
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---