[sage-support] Simplifying expression, 'x' vs. 'y'

2012-12-11 Thread Jori Mantysalo

# Define
var('y'); var('x')
f(x,y)= -(x*y)*exp(-(x^2 + y^2))
fdx(x,y) = derivative(f(x,y), x)
fdy(x,y) = derivative(f(x,y), y)

# Check
print f(x,y)-f(y,x)

# Compare these
print derivative(f(x,y), x).simplify_full()
print derivative(f(x,y), y).simplify_full()

This will print

0
(2*x^2 - 1)*y*e^(-x^2 - y^2)
(2*x*y^2 - x)*e^(-x^2 - y^2)

Why is this? I can add .collect('x') at end of second expression, but I 
don't understand why it is not needed in first expression.


This is version 5.4.

--
Jori Mäntysalo

--
You received this message because you are subscribed to the Google Groups 
sage-support group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




[sage-support] Re: Turning off readline

2012-12-11 Thread Dima Pasechnik
On 2012-12-09, Jim Hefferon jim.heffe...@gmail.com wrote:
 --=_Part_14_17388356.1355069188311
 Content-Type: text/plain; charset=ISO-8859-1

 I am trying to turn off the command line readline action.*  If that were 
 possible, it would be a big help to me.  Does anyone know?

 I am running Sage on a recent Ubuntu, using a recent install.  I believe 
 the readline behavior arises from pyreadline that comes in as part of 
 ipython.  I can find no documentation in ipython on how to stop readline 
 while the repl is running (which would be ideal for me) and I tried putting 
 in a configuration file pyreadlineconfig.ini and uncommenting its second 
 line, but that had no effect that I could see.

 $ head -n2 $HOME/pyreadlineconfig.ini
 #Bind keys for exit (keys only work on empty lines
 disable_readline(True)#Disable pyreadline completely.

 I also had a look in the source but came away unenlightened.  Thanks for 
 any help.
is pyreadline really used by Sage?
It seems to be only needed on Windows, where Sage does not run.


-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




[sage-support] Re: Installation problem

2012-12-11 Thread Dima Pasechnik
On 2012-12-10, Emmanuel emm.ro...@gmail.com wrote:
 --=_Part_20_25716954.1355143287028
 Content-Type: text/plain; charset=ISO-8859-1

 Good afternoon,

 Havin installed sage 5.4 on my Ubuntu distribution 12.10, I have no problem 
 to run sage in a terminal. However, I can no more run it on my browser , 
 apparently due to exceptions.OSError: [Errno 39] Directory not empty (see 
 below). If I delet the .sage directory in mu user directory, then 
 everything works fine but I have no more access to my old worksheets. Can 
 someone suggest an idea of what is happening?

 Executing twistd  --pidfile=sage_notebook.sagenb/sagenb.pid -ny 
 sage_notebook.sagenb/twistedconf.tac
 2012-12-10 13:30:52+0100 [-] Log opened.
 2012-12-10 13:30:52+0100 [-] twistd 12.1.0 
 (/opt/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/local/bin/python 
 2.7.3) starting up.
 2012-12-10 13:30:52+0100 [-] reactor class: 
 twisted.internet.epollreactor.EPollReactor.
 2012-12-10 13:30:52+0100 [-] QuietSite starting on 8081
 2012-12-10 13:30:52+0100 [-] Starting factory __builtin__.QuietSite 
 instance at 0xad4636c
 2012-12-10 13:30:53+0100 [-] WSGI application error
 Traceback (most recent call last):
   File 
 /opt/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/local/lib/python2.7/site-packages/Twisted-12.1.0-py2.7-linux-i686.egg/twisted/python/threadpool.py,
  

you are runnig a Sage Ubunty 12.04 installation on Ubuntu 12.10.
It's asking for trouble, IMHO.



 line 167, in _worker
 result = context.call(ctx, function, *args, **kwargs)
   File 
 /opt/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/local/lib/python2.7/site-packages/Twisted-12.1.0-py2.7-linux-i686.egg/twisted/python/context.py,
  
 line 118, in callWithContext
 return self.currentContext().callWithContext(ctx, func, *args, **kw)
   File 
 /opt/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/local/lib/python2.7/site-packages/Twisted-12.1.0-py2.7-linux-i686.egg/twisted/python/context.py,
  
 line 81, in callWithContext
 return func(*args,**kw)
   File 
 /opt/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/local/lib/python2.7/site-packages/Twisted-12.1.0-py2.7-linux-i686.egg/twisted/web/wsgi.py,
  
 line 332, in run
 self.reactor.callFromThread(wsgiError, self.started, *exc_info())
 --- exception caught here ---
   File 
 /opt/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/local/lib/python2.7/site-packages/Twisted-12.1.0-py2.7-linux-i686.egg/twisted/web/wsgi.py,
  
 line 315, in run
 appIterator = self.application(self.environ, self.startResponse)
   File 
 /opt/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/local/lib/python2.7/site-packages/Flask-0.9-py2.7.egg/flask/app.py,
  
 line 1701, in __call__
 return self.wsgi_app(environ, start_response)
   File 
 /opt/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/local/lib/python2.7/site-packages/Flask-0.9-py2.7.egg/flask/app.py,
  
 line 1689, in wsgi_app
 response = self.make_response(self.handle_exception(e))
   File 
 /opt/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/local/lib/python2.7/site-packages/Flask-0.9-py2.7.egg/flask/app.py,
  
 line 1687, in wsgi_app
 response = self.full_dispatch_request()
   File 
 /opt/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/local/lib/python2.7/site-packages/Flask-0.9-py2.7.egg/flask/app.py,
  
 line 1360, in full_dispatch_request
 rv = self.handle_user_exception(e)
   File 
 /opt/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/local/lib/python2.7/site-packages/Flask-0.9-py2.7.egg/flask/app.py,
  
 line 1358, in full_dispatch_request
 rv = self.dispatch_request()
   File 
 /opt/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/local/lib/python2.7/site-packages/Flask-0.9-py2.7.egg/flask/app.py,
  
 line 1344, in dispatch_request
 return self.view_functions[rule.endpoint](**req.view_args)
   File 
 /opt/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/devel/sagenb/flask_version/decorators.py,
  
 line 22, in wrapper
 return f(*args, **kwds)
   File 
 /opt/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/devel/sagenb/flask_version/worksheet_listing.py,
  
 line 68, in home
 return render_worksheet_list(request.args, pub=False, username=username)
   File 
 /opt/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/devel/sagenb/flask_version/worksheet_listing.py,
  
 line 43, in render_worksheet_list
 search=search, reverse=reverse)
   File 
 /opt/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/devel/sagenb/sagenb/notebook/notebook.py,
  
 line 1282, in worksheet_list_for_user
 X = self.get_worksheets_with_viewer(user)
   File 
 /opt/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/devel/sagenb/sagenb/notebook/notebook.py,
  
 line 1460, in get_worksheets_with_viewer
 if self._user_manager.user_is_admin(username): return 
 self.get_all_worksheets()
   File 
 /opt/sage-5.4-linux-32bit-ubuntu_12.04.1_lts-i686-Linux/devel/sagenb/sagenb/notebook/notebook.py,
  
 line 1455, in 

[sage-support] Re: Simplifying expression, 'x' vs. 'y'

2012-12-11 Thread kcrisman


On Tuesday, December 11, 2012 3:15:31 AM UTC-5, jori.ma...@uta.fi wrote:

 # Define 
 var('y'); var('x') 
 f(x,y)= -(x*y)*exp(-(x^2 + y^2)) 
 fdx(x,y) = derivative(f(x,y), x) 
 fdy(x,y) = derivative(f(x,y), y) 

 # Check 
 print f(x,y)-f(y,x) 

 # Compare these 
 print derivative(f(x,y), x).simplify_full() 
 print derivative(f(x,y), y).simplify_full() 

 This will print 

 0 
 (2*x^2 - 1)*y*e^(-x^2 - y^2) 
 (2*x*y^2 - x)*e^(-x^2 - y^2) 


Partly educated guess; the Pynac print order we use

sage: fdx
(x, y) |-- 2*x^2*y*e^(-x^2 - y^2) - y*e^(-x^2 - y^2)
sage: fdy
(x, y) |-- 2*x*y^2*e^(-x^2 - y^2) - x*e^(-x^2 - y^2)


makes it easy for Maxima to guess that y*e^(-x^2-y^2) factors out of the 
first expression but not the second, since the x is hidden.  But this is 
done in Maxima, in particular with fullratsimp

sage: fdx.simplify_rational()
(x, y) |-- (2*x^2 - 1)*y*e^(-x^2 - y^2)
sage: fdy.simplify_rational()
(x, y) |-- (2*x*y^2 - x)*e^(-x^2 - y^2)

I wouldn't worry about it, since in general there is no way to define 
simpler expression that is fully useful at all times, and for more 
complicated expressions more detail work would be needed anyway.

- kcrisman

-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




[sage-support] Re: Turning off readline

2012-12-11 Thread Jim Hefferon


On Tuesday, December 11, 2012 7:45:10 AM UTC-5, Dima Pasechnik wrote:

 is pyreadline really used by Sage? 
 It seems to be only needed on Windows, where Sage does not run. 

 Thanks for your comment.  Probably I have it wrong.  I based my opinion on 
this from the Sage FAQ: 
  
http://wiki.sagemath.org/faq#Why_is_Sage.27s_command_history_different_than_Magma.27s
buttressed by the fact that if you type garbage into the repl then Sage 
gives an error message that refers to the ipython console.  But evidence 
that I am wrong is that I also see readline-6.2.p3.spkg in my 
/usr/local/sage/spkg/standard directory, so I could be convinced either 
way.  

Assuming that Sage uses GNU readline, I spelunked the readline manual 
looking for a way to disable either dynamically or at startup and did not 
see anything.  I also have spent some time trying to influence the behavior 
of readline via INPUTRC, as here
  bash$ INPUTRC=./inputrc sage
but I observed no effect (in ./inputrc I tried setting 
horizontal-scroll-mode=off).  Could easily be my cluelessness that caused 
it to not work, though.

Obviously I'm thrashing here, so I'm glad for any insight.

-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




[sage-support] Re: Turning off readline

2012-12-11 Thread Jason Grout

On 12/11/12 8:07 AM, Jim Hefferon wrote:



On Tuesday, December 11, 2012 7:45:10 AM UTC-5, Dima Pasechnik wrote:

is pyreadline really used by Sage?
It seems to be only needed on Windows, where Sage does not run.

Thanks for your comment.  Probably I have it wrong.  I based my opinion
on this from the Sage FAQ:

http://wiki.sagemath.org/faq#Why_is_Sage.27s_command_history_different_than_Magma.27s
buttressed by the fact that if you type garbage into the repl then Sage
gives an error message that refers to the ipython console.  But
evidence that I am wrong is that I also see readline-6.2.p3.spkg in my
/usr/local/sage/spkg/standard directory, so I could be convinced either
way.

Assuming that Sage uses GNU readline, I spelunked the readline manual
looking for a way to disable either dynamically or at startup and did
not see anything.  I also have spent some time trying to influence the
behavior of readline via INPUTRC, as here
   bash$ INPUTRC=./inputrc sage
but I observed no effect (in ./inputrc I tried setting
horizontal-scroll-mode=off).  Could easily be my cluelessness that
caused it to not work, though.

Obviously I'm thrashing here, so I'm glad for any insight.



Sage has an expect interface for Sage: 
http://hg.sagemath.org/sage-main/file/33242a07d2ab/sage/interfaces/sage0.py


There's another expect interface used in the notebook: 
https://github.com/sagemath/sagenb/blob/master/sagenb/interfaces/expect.py#L204


I'm not sure the exact answer to your original question about disabling 
readline, but I hope the above helps.


Thanks,

Jason


--
You received this message because you are subscribed to the Google Groups 
sage-support group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




[sage-support] Re: Turning off readline

2012-12-11 Thread Jim Hefferon


On Tuesday, December 11, 2012 9:15:20 AM UTC-5, Jason Grout wrote:


 Sage has an expect interface for Sage: 
 http://hg.sagemath.org/sage-main/file/33242a07d2ab/sage/interfaces/sage0.py 


Thanks, Jason.  I did not know that.  I'll have a look.  (As you know, I'm 
trying to pick up the sage: prompt, the ... sub prompts, etc., that a 
student would see if they typed it in letter for letter.)

Regards,
Jim 

-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




[sage-support] Re: Turning off readline

2012-12-11 Thread Dima Pasechnik
On 2012-12-11, Jim Hefferon jim.heffe...@gmail.com wrote:
 --=_Part_251_9537975.1355234826734
 Content-Type: text/plain; charset=ISO-8859-1



 On Tuesday, December 11, 2012 7:45:10 AM UTC-5, Dima Pasechnik wrote:

 is pyreadline really used by Sage? 
 It seems to be only needed on Windows, where Sage does not run. 

 Thanks for your comment.  Probably I have it wrong.  I based my opinion on 
 this from the Sage FAQ: 
   
 http://wiki.sagemath.org/faq#Why_is_Sage.27s_command_history_different_than_Magma.27s
 buttressed by the fact that if you type garbage into the repl then Sage 
 gives an error message that refers to the ipython console.  But evidence 
 that I am wrong is that I also see readline-6.2.p3.spkg in my 
 /usr/local/sage/spkg/standard directory, so I could be convinced either 
 way.  

if you look at sage/misc/readline_extra_commands.pyx

you'll see that it is basically an interface to GNU readline.
Looking into it, one gathers that changing the line

readline 1

to 

readline 0

in the file $HOME/.sage/ipython/ipythonrc 
(a.k.a. $DOTSAGE/ipython/ipythonrc)
disables readline. 
I tried this for me, it worked. YMMV.

HTH,
Dmitrii
 

 Assuming that Sage uses GNU readline, I spelunked the readline manual 
 looking for a way to disable either dynamically or at startup and did not 
 see anything.  I also have spent some time trying to influence the behavior 
 of readline via INPUTRC, as here
   bash$ INPUTRC=./inputrc sage
 but I observed no effect (in ./inputrc I tried setting 
 horizontal-scroll-mode=off).  Could easily be my cluelessness that caused 
 it to not work, though.

 Obviously I'm thrashing here, so I'm glad for any insight.


-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




[sage-support] RuntimeError when computing Heilbronn Matries

2012-12-11 Thread Peng
The following error comes out when I try to compute Heilbronn-Merel matries 
with n=5 in sage:

-
sage: H=HeilbronnMerel(5)
-
RuntimeError  Traceback (most recent call last)

/home/guests/sage-5.4.1/ipython console in module()

/home/guests/sage-5.4.1/local/lib/python2.7/site-packages/sage/modular/modsym/heilbronn.so
 
in sage.modular.modsym.heilbronn.HeilbronnMerel.__init__ 
(sage/modular/modsym/heilbronn.c:5185)()

/home/guests/sage-5.4.1/local/lib/python2.7/site-packages/sage/modular/modsym/heilbronn.so
 
in sage.modular.modsym.heilbronn.HeilbronnMerel._initialize_list 
(sage/modular/modsym/heilbronn.c:5343)()

RuntimeError: Floating point exception
--

I have no idea why this happens or how to fix it. Is it possible to solve 
this problem in sage?

-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




[sage-support] Re: Simplifying expression, 'x' vs. 'y'

2012-12-11 Thread JamesHDavenport


On Tuesday, 11 December 2012 13:15:09 UTC, kcrisman wrote:

 I wouldn't worry about it, since in general there is no way to define 
 simpler expression that is fully useful at all times, and for more 
 complicated expressions more detail work would be needed anyway.

Pedantic Note. Jacques Carette's paper: Understanding Expression 
Simplification.
Proc. ISSAC 2004 (ed. J. Gutierrez), ACM Press, New York, 2004, pp. 72-79.
http://www.cas.mcmaster.ca/~carette/publications/simplification.pdf.
defines it in a useful way, just not in a computable way (that I can see in 
practice).

-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




[sage-support] Re: Simplifying expression, 'x' vs. 'y'

2012-12-11 Thread kcrisman


On Tuesday, December 11, 2012 6:52:53 PM UTC-5, JamesHDavenport wrote:



 On Tuesday, 11 December 2012 13:15:09 UTC, kcrisman wrote:

 I wouldn't worry about it, since in general there is no way to define 
 simpler expression that is fully useful at all times, and for more 
 complicated expressions more detail work would be needed anyway.

 Pedantic Note. Jacques Carette's paper: Understanding Expression 
 Simplification.
 Proc. ISSAC 2004 (ed. J. Gutierrez), ACM Press, New York, 2004, pp. 72-79.
 http://www.cas.mcmaster.ca/~carette/publications/simplification.pdf.
 defines it in a useful way, just not in a computable way (that I can see 
 in practice).


Very interesting paper.  I guess I was referring to the sense that 

(1+x)(1-x)

and

1-x^2

might each be considered simpler depending on the context, which is the 
way a lot of people who don't know about decidability would perceive this 
question (or so my experience has been interacting with a lot of people who 
ask about why Sage doesn't simplify this or that).  I suppose the answer 
to my example would depend on what you pick for your axiomoids?  RJF always 
seems to have a useful comment about these things as well.

-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.