[sage-support] Re: How to detect memory leaks?

2008-10-24 Thread Simon King

Dear Robert,

On 24 Okt., 06:46, Robert Bradshaw [EMAIL PROTECTED]
wrote:
 Well, memory leaks are always possible, but this should be safe (i.e.  
 if there's a bug, it's in Cython). Can you post what your class  
 definition is?

It is the Toy-F5 that I implemented at Sage Days 10. See
http://sage.math.washington.edu/home/SimonKing/f5/f5.pyx

 Are you running this from the command line?

Yes. The example is:
sage: attach f5.pyx
Compiling /home/SimonKing/f5/f5.pyx...
sage: from sage.rings.ideal import Cyclic
sage: R=PolynomialRing(QQ,'x',5)
sage: I=Cyclic(R)
sage: F=F5()
sage: time G1=F(I)
# removing some protocol output
CPU times: user 0.30 s, sys: 0.02 s, total: 0.32 s
Wall time: 0.32 s
sage: G1==I.groebner_basis()
True
sage: del F
sage: get_memory_usage()
423.21484375
sage: for i in range(100):
F=F5()
G1=F(I)
del F
# removing protocol output
sage: get_memory_usage()
681.00390625
sage: (_-423.21484375)/100
2.5778906250

 try doing the whole operation in a function body  
 and see if the results are the same.

sage: def f(n):
for i in range(n):
F=F5()
G1=F(I)
sage: f(100)
# removing protocol
sage: get_memory_usage()
938.33984375
sage: (_-681.00390625)/100
2.5733593750

So, that's about the same.

I wonder one thing: Could the ~2.58 MB come from the protocol that my
function prints?

Cheers
  Simon

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: accessing a notebook on a remote machine

2008-10-24 Thread Stan Schymanski

Dear William and Jason,

I got the network socket fixed by our support, went to 
http://www.whatismyip.com/
to find out my IP address, then followed William's instructions and
typed:

sage: notebook(address=ipaddress,port=8100,secure=True)

where ipaddress was replaced by the IP address of my computer. Then, I
was able to connect to the running notebook from another computer on
the network just by typing
 https://ipaddress:8100 (again with ipaddress replaced by the IP
address of the computer running the notebook).

When I try to connect to this notebook in the same way from a computer
that is not on the same network, I get a network timeout, which
reassures me that the notebook is not going to be a gateway for
hackers around the world to create havoc on my computer. I will now
play around with adding users etc. as described in William's post
above.

Too easy! Thanks for your help!

All the best,
Stan

On Oct 23, 5:09 pm, William Stein [EMAIL PROTECTED] wrote:
 On Thu, Oct 23, 2008 at 8:02 AM, Stan Schymanski [EMAIL PROTECTED] wrote:

  Hi Jason,

  Thanks for the quick reply. Sorry I didn't provide any information.
  I'm running sage 3.1.4 directly on a MacBook Pro under OS X 10.4.11,
  and I do have a computer name that should be accessible from other
  computers. I did activate the Remote Login in the System preferences,
  but if I do ssh [EMAIL PROTECTED] or ssh [EMAIL PROTECTED]
  from another computer, the operation times out. Would this work if a
  notebook server was running on the machine, or do I have to sort out
  the right way to connect first?

 Have you tried something like the following.  Startup sage on your
 macbook pro and type

   sage: notebook(address=ipaddress,port=8100,secure=True)

 then from another computer on your network try to visit the web page

https://ipaddress:8100

 That's pretty much it, except for making accounts. To create accounts
 you could temporarily do

   sage: notebook(address=ipaddress,port=8100,secure=True, accounts=True)

 let people make accounts, then do

   sage: notebook(address=ipaddress,port=8100,secure=True,accounts=False)

 so no new accounts can be created.

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



[sage-support] Re: code generation

2008-10-24 Thread Tim Lahey

On Oct 24, 2008, at 5:28 AM, peter wrote:



OK, sorry, I explain a little bit more in detail:
- I work on thermal building simulation. We use for example one
environment (TRNSYS) where you can connect models (for example
building model to heating system model etc.). The models are mainly
written in Fortran or C++ and compiled in DLL's that are then called
by the equation solver.
Our goal is to write the models not in C+++ or fortran anymore, but
either in Matlab (and or Simulink), Scilab or Sage.
So in clear, I want to profit of one of these mathematical
environments, write models there and use them later in our simulation
program.


One thing you can do is prototype in Sage and python, make use of  
profiling tools and then re-write the computation intensive portions  
using Cython or Pysco. At the moment, there really aren't tools to  
generate C++ or Fortran code from the Sage code. However, the latter  
tools are close to Python in syntax and can work with Sage.


That said, I'm fairly certain that it wouldn't be very difficult to  
write a code generator for Sage. If one can get the underlying  
structure of each of the expressions, it shouldn't be very difficult  
to convert that to C++ or Fortran as long as the expressions can be  
represented in the language without additional code. This is the  
approach that most the code generators I've seen use. Maxima has  
GENTRAN if someone is interested in seeing how one works and I know  
there is(are) paper(s) that discuss it. The main problem is that  
someone doing this would need to be fairly familiar with Sage internals.


Cheers,

Tim.

---
Tim Lahey
PhD Candidate, Systems Design Engineering
University of Waterloo

smime.p7s
Description: S/MIME cryptographic signature


[sage-support] Re: code generation

2008-10-24 Thread peter

OK, sorry, I explain a little bit more in detail:
- I work on thermal building simulation. We use for example one
environment (TRNSYS) where you can connect models (for example
building model to heating system model etc.). The models are mainly
written in Fortran or C++ and compiled in DLL's that are then called
by the equation solver.
Our goal is to write the models not in C+++ or fortran anymore, but
either in Matlab (and or Simulink), Scilab or Sage.
So in clear, I want to profit of one of these mathematical
environments, write models there and use them later in our simulation
program.

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: code generation

2008-10-24 Thread Jurgis Pralgauskis

pypy has some power in this direction

http://www.strakt.com/~jacob/Pypy_for_the_rest_of_us.pdf
http://morepypy.blogspot.com/

On Fri, Oct 24, 2008 at 12:38 PM, Tim Lahey [EMAIL PROTECTED] wrote:
 On Oct 24, 2008, at 5:28 AM, peter wrote:


 OK, sorry, I explain a little bit more in detail:
 - I work on thermal building simulation. We use for example one
 environment (TRNSYS) where you can connect models (for example
 building model to heating system model etc.). The models are mainly
 written in Fortran or C++ and compiled in DLL's that are then called
 by the equation solver.
 Our goal is to write the models not in C+++ or fortran anymore, but
 either in Matlab (and or Simulink), Scilab or Sage.
 So in clear, I want to profit of one of these mathematical
 environments, write models there and use them later in our simulation
 program.

 One thing you can do is prototype in Sage and python, make use of profiling
 tools and then re-write the computation intensive portions using Cython or
 Pysco. At the moment, there really aren't tools to generate C++ or Fortran
 code from the Sage code. However, the latter tools are close to Python in
 syntax and can work with Sage.

 That said, I'm fairly certain that it wouldn't be very difficult to write a
 code generator for Sage. If one can get the underlying structure of each of
 the expressions, it shouldn't be very difficult to convert that to C++ or
 Fortran as long as the expressions can be represented in the language
 without additional code. This is the approach that most the code generators
 I've seen use. Maxima has GENTRAN if someone is interested in seeing how one
 works and I know there is(are) paper(s) that discuss it. The main problem is
 that someone doing this would need to be fairly familiar with Sage
 internals.

 Cheers,

 Tim.

 ---
 Tim Lahey
 PhD Candidate, Systems Design Engineering
 University of Waterloo



-- 
Jurgis Pralgauskis
tel: 8-616 77613;
jabber: [EMAIL PROTECTED]; skype: dz0rdzas;
Don't worry, be happy and make things better ;)

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Problems with .show() and integration

2008-10-24 Thread LRN

Here's the code:

sigma = 0.2

gauss(x) = exp(-(x)2/(2*sigma2))

gauss1 = gauss(x).derivative

gauss2 = gauss1(x).derivative

ngauss2(x) = -1*gauss2(x)

sngauss2(x,y) = ngauss2(sqrt(x2 + y2))

a1 = var('a1'); a2 = var('a2'); b1 = var('b1'); b2 = var('b2')
chunkx = integral(sngauss2, x, a1, b1)
chunky = integral(chunkx, y, a2, b2)
chunky.show()

When evaluated it says It looks like jsMath failed to set up properly
(error code -7).  I will try to keep going, but it could get ugly.

Calling print chunky prints something weird.

All i want to do is to get symbolic formula for an integral of part of
a surface, described by sngauss2, so i can use it outside of Sage.


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: code generation

2008-10-24 Thread Burcin Erocal

On Friday 24 October 2008 11:28:05 peter wrote:
 OK, sorry, I explain a little bit more in detail:
 - I work on thermal building simulation. We use for example one
 environment (TRNSYS) where you can connect models (for example
 building model to heating system model etc.). The models are mainly
 written in Fortran or C++ and compiled in DLL's that are then called
 by the equation solver.
 Our goal is to write the models not in C+++ or fortran anymore, but
 either in Matlab (and or Simulink), Scilab or Sage.
 So in clear, I want to profit of one of these mathematical
 environments, write models there and use them later in our simulation
 program.

It is possible to call any python code from c/c++ as described here:

http://docs.python.org/extending/index.html

but cython makes this much easier.

You can write cython functions which convert the C data types passed to them 
to the appropriate sage types, and call your implementation in Sage. Then you 
can call these cython functions by defining them to be public:

http://docs.cython.org/docs/external_C_code.html#public-declarations


Cheers,

Burcin

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Problems with .show() and integration

2008-10-24 Thread Jason Grout

LRN wrote:
 Here's the code:
 
 sigma = 0.2
 
 gauss(x) = exp(-(x)2/(2*sigma2))
 
 gauss1 = gauss(x).derivative
 
 gauss2 = gauss1(x).derivative
 
 ngauss2(x) = -1*gauss2(x)
 
 sngauss2(x,y) = ngauss2(sqrt(x2 + y2))
 
 a1 = var('a1'); a2 = var('a2'); b1 = var('b1'); b2 = var('b2')
 chunkx = integral(sngauss2, x, a1, b1)
 chunky = integral(chunkx, y, a2, b2)
 chunky.show()
 
 When evaluated it says It looks like jsMath failed to set up properly
 (error code -7).  I will try to keep going, but it could get ugly.


This is a problem with fonts, not with any math.  To get the nice TeX 
display with jsMath, please download a set of fonts from here:

http://www.math.union.edu/~dpvc/jsMath/download/jsMath-fonts.html

If you are on Unix, ignore the instructions on the page and just unzip 
the fonts into your ~/.fonts directory.

Please let us know if that solves the problem.

We *really* ought to fix this to behave nicer (i.e., instead of just 
giving an error, just offer to give the fonts to the user and give them 
instructions for installing them).  Of course, I've said this before, 
but not done anything about it!

Thanks,

Jason


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: accessing a notebook on a remote machine

2008-10-24 Thread Jason Grout

Stan Schymanski wrote:
 Dear William and Jason,
 
 I got the network socket fixed by our support, went to 
 http://www.whatismyip.com/
 to find out my IP address, then followed William's instructions and
 typed:
 
 sage: notebook(address=ipaddress,port=8100,secure=True)
 
 where ipaddress was replaced by the IP address of my computer. Then, I
 was able to connect to the running notebook from another computer on
 the network just by typing
  https://ipaddress:8100 (again with ipaddress replaced by the IP
 address of the computer running the notebook).
 
 When I try to connect to this notebook in the same way from a computer
 that is not on the same network, I get a network timeout, which
 reassures me that the notebook is not going to be a gateway for
 hackers around the world to create havoc on my computer. I will now
 play around with adding users etc. as described in William's post
 above.
 
 Too easy! Thanks for your help!


You should also be able to do:

notebook(address=computername, port=8100, secure=True)

to be able to address it as just https://computername:8100.

That might work anyway even with address='ipaddress' too.

Jason


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Problems with .show() and integration

2008-10-24 Thread Marshall Hampton

Is gauss(x) = exp(-(x)2/(2*sigma2)) a typo?  Because that raises a
syntax error for me.

-M. Hampton

On Oct 24, 6:12 am, Jason Grout [EMAIL PROTECTED] wrote:
 LRN wrote:
  Here's the code:

  sigma = 0.2

  gauss(x) = exp(-(x)2/(2*sigma2))

  gauss1 = gauss(x).derivative

  gauss2 = gauss1(x).derivative

  ngauss2(x) = -1*gauss2(x)

  sngauss2(x,y) = ngauss2(sqrt(x2 + y2))

  a1 = var('a1'); a2 = var('a2'); b1 = var('b1'); b2 = var('b2')
  chunkx = integral(sngauss2, x, a1, b1)
  chunky = integral(chunkx, y, a2, b2)
  chunky.show()

  When evaluated it says It looks like jsMath failed to set up properly
  (error code -7).  I will try to keep going, but it could get ugly.

 This is a problem with fonts, not with any math.  To get the nice TeX
 display with jsMath, please download a set of fonts from here:

 http://www.math.union.edu/~dpvc/jsMath/download/jsMath-fonts.html

 If you are on Unix, ignore the instructions on the page and just unzip
 the fonts into your ~/.fonts directory.

 Please let us know if that solves the problem.

 We *really* ought to fix this to behave nicer (i.e., instead of just
 giving an error, just offer to give the fonts to the user and give them
 instructions for installing them).  Of course, I've said this before,
 but not done anything about it!

 Thanks,

 Jason
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: accessing a notebook on a remote machine

2008-10-24 Thread Stan Schymanski

Yes, confirmed. I now just use the computer name because it is a lot 
easier to remember. :)

Is there an easy way to prevent someone from accidentally deleting data 
on the computer? Just login from a restricted account before opening the 
notebook, or do I have to set up a chroot jail?

Thanks!

Jason Grout wrote:
 You should also be able to do:

 notebook(address=computername, port=8100, secure=True)

 to be able to address it as just https://computername:8100.

 That might work anyway even with address='ipaddress' too.

 Jason


 
   


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Problems with .show() and integration

2008-10-24 Thread Jason Grout

Marshall Hampton wrote:
 Is gauss(x) = exp(-(x)2/(2*sigma2)) a typo?  Because that raises a
 syntax error for me.

Should that be:


gauss(x) = exp(-(x)^2/(2*sigma^2))

sometimes my copy and paste strip the ^ signs; is that what happened?

Jason


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] bug in simplify_radical()?

2008-10-24 Thread Stan Schymanski

Dear all,

I just noted some strange behaviour with simplify_radical():

--
| SAGE Version 3.1.2, Release Date: 2008-09-19   |
| Type notebook() for the GUI, and license() for information.|
--

sage: sage: var('a b c')
(a, b, c)
sage:  ((a*b - 0.5*a*(b - c))/a).simplify_radical()
0
sage: ((b - 0.5*(b - c))).simplify_radical()
0.500*c + 0.500*b

Clearly, the second result should be the same as the first one, as 'a'
cancels out. Does anyone know how to avoid such mistakes and whether
it is advisable to use simplify_radical at all?

Cheers
Stan
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: bug in simplify_radical()?

2008-10-24 Thread John Cremona

A variation on your first try is:

sage: ((a*b - (1/2)*a*(b - c))/a).simplify_radical()
(c + b)/2

which works fine.  Maybe it's a bug in maxima.  I don't see why you
would need simplify_radical() at all here, since your expression
contains no radicals.

John Cremona

2008/10/24 Stan Schymanski [EMAIL PROTECTED]:

 Dear all,

 I just noted some strange behaviour with simplify_radical():

 --
 | SAGE Version 3.1.2, Release Date: 2008-09-19   |
 | Type notebook() for the GUI, and license() for information.|
 --

 sage: sage: var('a b c')
 (a, b, c)
 sage:  ((a*b - 0.5*a*(b - c))/a).simplify_radical()
 0
 sage: ((b - 0.5*(b - c))).simplify_radical()
 0.500*c + 0.500*b

 Clearly, the second result should be the same as the first one, as 'a'
 cancels out. Does anyone know how to avoid such mistakes and whether
 it is advisable to use simplify_radical at all?

 Cheers
 Stan
 


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: bug in simplify_radical()?

2008-10-24 Thread Stan Schymanski

That's interesting. It seems that the bug lies in the use of floating
point numbers? By the way, simplify_trig and simplify_rational create
the same mistake. I agree that the use of simplify_radical() is not
very useful here, but if it makes such an obvious mistake, how
confident can we be that it doesn't make mistakes in more complicated
cases where we don't actually notice the mistake straight away? I
thought about using something like simplify_full() on any equation to
see if it can be simplified before I carry on with calculations.
Perhaps this is the wrong strategy, anyway. Any comments?
How could I actually get Sage to cancel out the 'a' in the equation?
None of the methods I tried do the job. I don't like doing things by
hand, because then I have to redo everything if I change an equation
somewhere at the top of the notebook.

Thanks a lot for thinking about it!

Stan

On Oct 24, 3:04 pm, John Cremona [EMAIL PROTECTED] wrote:
 A variation on your first try is:

 sage: ((a*b - (1/2)*a*(b - c))/a).simplify_radical()
 (c + b)/2

 which works fine.  Maybe it's a bug in maxima.  I don't see why you
 would need simplify_radical() at all here, since your expression
 contains no radicals.

 John Cremona

 2008/10/24 Stan Schymanski [EMAIL PROTECTED]:



  Dear all,

  I just noted some strange behaviour with simplify_radical():

  --
  | SAGE Version 3.1.2, Release Date: 2008-09-19                       |
  | Type notebook() for the GUI, and license() for information.        |
  --

  sage: sage: var('a b c')
  (a, b, c)
  sage:  ((a*b - 0.5*a*(b - c))/a).simplify_radical()
  0
  sage: ((b - 0.5*(b - c))).simplify_radical()
  0.500*c + 0.500*b

  Clearly, the second result should be the same as the first one, as 'a'
  cancels out. Does anyone know how to avoid such mistakes and whether
  it is advisable to use simplify_radical at all?

  Cheers
  Stan


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: bug in simplify_radical()?

2008-10-24 Thread Burcin Erocal

On Friday 24 October 2008 15:17:57 Stan Schymanski wrote:
 That's interesting. It seems that the bug lies in the use of floating
 point numbers? By the way, simplify_trig and simplify_rational create
 the same mistake. I agree that the use of simplify_radical() is not
 very useful here, but if it makes such an obvious mistake, how
 confident can we be that it doesn't make mistakes in more complicated
 cases where we don't actually notice the mistake straight away? I
 thought about using something like simplify_full() on any equation to
 see if it can be simplified before I carry on with calculations.
 Perhaps this is the wrong strategy, anyway. Any comments?
 How could I actually get Sage to cancel out the 'a' in the equation?
 None of the methods I tried do the job. I don't like doing things by
 hand, because then I have to redo everything if I change an equation
 somewhere at the top of the notebook.

In this case, expand seems to do what you want. I don't know if it will help 
you with more complex expressions.

sage: var(a,b,c)
(a, b, c)
sage: e = ((a*b - (1/2)*a*(b - c))/a); e
(a*b - a*(b - c)/2)/a
sage: e.expand()
c/2 + b/2

or with float coefficients:

sage: e = ((a*b - (.5)*a*(b - c))/a); e
(a*b - 0.500*a*(b - c))/a
sage: e.expand()
0.500*c + 0.500*b


 On Oct 24, 3:04 pm, John Cremona [EMAIL PROTECTED] wrote:
  A variation on your first try is:
 
  sage: ((a*b - (1/2)*a*(b - c))/a).simplify_radical()
  (c + b)/2
 
  which works fine.  Maybe it's a bug in maxima.  I don't see why you
  would need simplify_radical() at all here, since your expression
  contains no radicals.
 
  John Cremona
 
  2008/10/24 Stan Schymanski [EMAIL PROTECTED]:
   Dear all,
  
   I just noted some strange behaviour with simplify_radical():
  
   --
  
   | SAGE Version 3.1.2, Release Date: 2008-09-19                       |
   | Type notebook() for the GUI, and license() for information.        |
  
   --
  
   sage: sage: var('a b c')
   (a, b, c)
   sage:  ((a*b - 0.5*a*(b - c))/a).simplify_radical()
   0
   sage: ((b - 0.5*(b - c))).simplify_radical()
   0.500*c + 0.500*b
  
   Clearly, the second result should be the same as the first one, as 'a'
   cancels out. Does anyone know how to avoid such mistakes and whether
   it is advisable to use simplify_radical at all?
  
   Cheers
   Stan

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: bug in simplify_radical()?

2008-10-24 Thread John Cremona

2008/10/24 Stan Schymanski [EMAIL PROTECTED]:

 That's interesting. It seems that the bug lies in the use of floating
 point numbers? By the way, simplify_trig and simplify_rational create
 the same mistake. I agree that the use of simplify_radical() is not
 very useful here, but if it makes such an obvious mistake, how
 confident can we be that it doesn't make mistakes in more complicated
 cases where we don't actually notice the mistake straight away? I
 thought about using something like simplify_full() on any equation to
 see if it can be simplified before I carry on with calculations.
 Perhaps this is the wrong strategy, anyway. Any comments?
 How could I actually get Sage to cancel out the 'a' in the equation?
 None of the methods I tried do the job. I don't like doing things by
 hand, because then I have to redo everything if I change an equation
 somewhere at the top of the notebook.


Here's an approach which does not use maxima at all, but rather more
pure algebra:

sage: R.a,b,c = QQ[]
sage: (a*b - (1/2)*a*(b - c))//a
1/2*b + 1/2*c

Here, R is the set of all polynomials in a,b,c with rational
coefficients, and // does an exact division.  (If you use / instead
the answer looks the same but lies in a different place:

sage: parent((a*b - (1/2)*a*(b - c))/a)
Fraction Field of Multivariate Polynomial Ring in a, b, c over Rational Field
sage: parent((a*b - (1/2)*a*(b - c))//a)
Multivariate Polynomial Ring in a, b, c over Rational Field

Now, whether or not you like this solution seems to depend on whether
or not you are a pure mathematician who is used to rings and fields,
as opposed so someone who just deals with symbolic expressions.  The
former are much faster (and, as in this case, more accurate!) but are
conceptually harder -- and do not allow things like radicals and
exponentials.

John Cremona

 Thanks a lot for thinking about it!

 Stan

 On Oct 24, 3:04 pm, John Cremona [EMAIL PROTECTED] wrote:
 A variation on your first try is:

 sage: ((a*b - (1/2)*a*(b - c))/a).simplify_radical()
 (c + b)/2

 which works fine.  Maybe it's a bug in maxima.  I don't see why you
 would need simplify_radical() at all here, since your expression
 contains no radicals.

 John Cremona

 2008/10/24 Stan Schymanski [EMAIL PROTECTED]:



  Dear all,

  I just noted some strange behaviour with simplify_radical():

  --
  | SAGE Version 3.1.2, Release Date: 2008-09-19   |
  | Type notebook() for the GUI, and license() for information.|
  --

  sage: sage: var('a b c')
  (a, b, c)
  sage:  ((a*b - 0.5*a*(b - c))/a).simplify_radical()
  0
  sage: ((b - 0.5*(b - c))).simplify_radical()
  0.500*c + 0.500*b

  Clearly, the second result should be the same as the first one, as 'a'
  cancels out. Does anyone know how to avoid such mistakes and whether
  it is advisable to use simplify_radical at all?

  Cheers
  Stan


 


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: bug in simplify_radical()?

2008-10-24 Thread Jason Grout

Burcin Erocal wrote:
 On Friday 24 October 2008 15:17:57 Stan Schymanski wrote:
 That's interesting. It seems that the bug lies in the use of floating
 point numbers? By the way, simplify_trig and simplify_rational create
 the same mistake. I agree that the use of simplify_radical() is not
 very useful here, but if it makes such an obvious mistake, how
 confident can we be that it doesn't make mistakes in more complicated
 cases where we don't actually notice the mistake straight away? I
 thought about using something like simplify_full() on any equation to
 see if it can be simplified before I carry on with calculations.
 Perhaps this is the wrong strategy, anyway. Any comments?
 How could I actually get Sage to cancel out the 'a' in the equation?
 None of the methods I tried do the job. I don't like doing things by
 hand, because then I have to redo everything if I change an equation
 somewhere at the top of the notebook.
 
 In this case, expand seems to do what you want. I don't know if it will help 
 you with more complex expressions.
 
 sage: var(a,b,c)
 (a, b, c)
 sage: e = ((a*b - (1/2)*a*(b - c))/a); e
 (a*b - a*(b - c)/2)/a
 sage: e.expand()
 c/2 + b/2
 
 or with float coefficients:
 
 sage: e = ((a*b - (.5)*a*(b - c))/a); e
 (a*b - 0.500*a*(b - c))/a
 sage: e.expand()
 0.500*c + 0.500*b
 


In general, I find that expand will end up simplifying things a lot more 
than the simplify functions will.

I suppose it's like our secondary school math: when in doubt, multiply 
everything out and then see what cancels.

Jason


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: bug in simplify_radical()?

2008-10-24 Thread Stan Schymanski

Thanks for the advice! It seems like a combination of expand() and
simplify() would go a long way. Unfortunately, I am not a
Mathematician and hence struggle to understand rings and fields.

I am still a bit hesitant about simplify, though. Should a bug report
be filed to Maxima? By the way, is pynac going to replace the maxima
simplify algorithms? It seems that there is some potential for
improvement there.

Regards,
Stan


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: bug in simplify_radical()?

2008-10-24 Thread Burcin Erocal

On Friday 24 October 2008 16:20:24 Stan Schymanski wrote:
 Thanks for the advice! It seems like a combination of expand() and
 simplify() would go a long way. Unfortunately, I am not a
 Mathematician and hence struggle to understand rings and fields.

 I am still a bit hesitant about simplify, though. Should a bug report
 be filed to Maxima? By the way, is pynac going to replace the maxima
 simplify algorithms? It seems that there is some potential for
 improvement there.

Eventually, yes.

To be able to extend / improve / customize such maxima functions is one of the 
main reasons behind the pynac backed symbolics effort. 

Cheers,

Burcin


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: How to detect memory leaks?

2008-10-24 Thread Simon King

Dear Carlo and all others,

On Oct 23, 5:11 pm, Carlo Hamalainen [EMAIL PROTECTED]
wrote:
 Valgrind is the thing to try:http://wiki.sagemath.org/ValgrindingSage

Sorry, when I read the first lines of that page I thought I had to re-
build Sage from scratch. But later it says that there is an optional
valgrind package for Sage. I installed it and tried sage -valgrind.

Then I did
sage: attach f5.pyx
Compiling /home/king/Projekte/f5/f5.pyx...
sage: from sage.rings.ideal import Cyclic
sage: R=PolynomialRing(QQ,'x',5)
sage: I=Cyclic(R).homogenize()
sage: get_memory_usage()
1013.09765625
sage: F=F5()
sage: G1=F(I)
sage: del F
sage: del G1
sage: get_memory_usage()
1035.59765625
sage: F=F5()
sage: G1=F(I)
sage: del F
sage: del G1
sage: get_memory_usage()
1053.04296875
sage: quit

However, it didn't help much.

The valgrind output available at 
http://sage.math.washington.edu/home/SimonKing/f5/sage-memcheck.18590
says in the summary that ~386kB are possibly lost and nothing is
definitely lost.

I think this doesn't fit to the output of get_memory_usage() above.
Running F=F5()G=F(I) in a loop is soon eating all memory.

Moreover, most of the valgrind output does not refer to my code, as
much as I understand. Hence, there is only  a handful of references to
_home_king_Projekte_f5_f5_pyx_0.c

Can you help me with interpreting the valgrind findings?

Thank you very much
  Simon

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: How to detect memory leaks?

2008-10-24 Thread mabshoff



On Oct 24, 8:52 am, Simon King [EMAIL PROTECTED] wrote:
 Dear Carlo and all others,

 On Oct 23, 5:11 pm, Carlo Hamalainen [EMAIL PROTECTED]
 wrote:

  Valgrind is the thing to try:http://wiki.sagemath.org/ValgrindingSage

 Sorry, when I read the first lines of that page I thought I had to re-
 build Sage from scratch. But later it says that there is an optional
 valgrind package for Sage. I installed it and tried sage -valgrind.

You need to rebuild Python after exporting SAGE_VALGRIND=yes -
otherwise pymalloc is used and as is the valgrind log is useless in
some regards.

 Then I did
 sage: attach f5.pyx
 Compiling /home/king/Projekte/f5/f5.pyx...
 sage: from sage.rings.ideal import Cyclic
 sage: R=PolynomialRing(QQ,'x',5)
 sage: I=Cyclic(R).homogenize()
 sage: get_memory_usage()
 1013.09765625
 sage: F=F5()
 sage: G1=F(I)
 sage: del F
 sage: del G1
 sage: get_memory_usage()
 1035.59765625
 sage: F=F5()
 sage: G1=F(I)
 sage: del F
 sage: del G1
 sage: get_memory_usage()
 1053.04296875
 sage: quit

 However, it didn't help much.

 The valgrind output available 
 athttp://sage.math.washington.edu/home/SimonKing/f5/sage-memcheck.18590
 says in the summary that ~386kB are possibly lost and nothing is
 definitely lost.

 I think this doesn't fit to the output of get_memory_usage() above.
 Running F=F5()    G=F(I) in a loop is soon eating all memory.

 Moreover, most of the valgrind output does not refer to my code, as
 much as I understand. Hence, there is only  a handful of references to
 _home_king_Projekte_f5_f5_pyx_0.c

 Can you help me with interpreting the valgrind findings?

The key thing here is that the still reachable amount of memory is
growing which indicates a problem with objects from the python heap
not getting properly deallocated, i.e. a potential reference count
issue when using Cython for example. Debugging these is hard and
valgrind will not help much in that case. Much more useful could be
Guppy.

 Thank you very much
       Simon

Cheers,

Michael
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Problems with .show() and integration

2008-10-24 Thread LRN

On 24.10.2008 15:48, Jason Grout wrote:
 Marshall Hampton wrote:

 Is gauss(x) = exp(-(x)2/(2*sigma2)) a typo?  Because that raises a
 syntax error for me.
  

 Should that be:


 gauss(x) = exp(-(x)^2/(2*sigma^2))

 sometimes my copy and paste strip the ^ signs; is that what happened?

Yes, it's ^.

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Is interact partly broken in 3.1.4 (or before)?

2008-10-24 Thread kcrisman

  The automatic evaluation of interact cells bothers me; I think it
  would be better if this was changed.  Is it not enough to use #auto? -
  William's comments suggest things are more complicated, but if not
  #auto already provides the same mechanism.

 +1 to interact cells not auto-evaluating, since we can already do this
 with #auto.

This is now http://trac.sagemath.org/sage_trac/ticket/4363

Weirdly, I cannot now reproduce the disappearing slider issue, even
though it was consistent a few days ago with 3.1.4+.  If it crops up
again I will report back.

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



[sage-support] Re: Problems with .show() and integration

2008-10-24 Thread LRN

On 24.10.2008 15:12, Jason Grout wrote:

 Please let us know if that solves the problem.


It does.

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Quantlib (SWIG) and Sage - Experimental package

2008-10-24 Thread tomanizer

Hi All,

I have successfully compiled the new
quantlib_swig-0.9.6
quantlib-0.9.6
packages from Sage 3.0.1.

A  number of functions work fine form the Sage notebook.
Unfortunately the important quantlib Date() function is causing
problems.

I am trying to run

from QuantLib import *
calendar = TARGET()
todaysDate = Date(6,October,2001)

and I get the error:

Traceback (most recent call last):
  File stdin, line 1, in module
  File /root/.sage/sage_notebook/worksheets/tomanizer/18/code/3.py,
line 7, in module
todaysDate = Date(Integer(6),October,Integer(2001))
  File /filesrv/Sage/sage-3.0.2-debian32-intelx86-i686-Linux/local/
lib/python2.5/site-packages/sympy/plotting/, line 1, in module

  File /filesrv/Sage/sage-3.0.2-debian32-intelx86-i686-Linux/local/
lib/python2.5/site-packages/QuantLib/QuantLib.py, line 203, in
__init__
this = _QuantLib.new_Date(*args)
NotImplementedError: Wrong number of arguments for overloaded function
'new_Date'.
  Possible C/C++ prototypes are:
Date()
Date(Day,Month,Year)
Date(BigInteger)
Date(std::string const ,std::string const )

which is an error thrown by SWIG if the wrong parameters are passed to
the functions.
However, this example is from the Quantlib SWIG help file. So I assume
it should work from quantlib SWIG.

My suspicion is that the error is related to the Sage's handling of
unicode.

Does anone wlse have this problem?
Is there a workaround?

Kind regards
Thomas
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: Maple 11 in Sage

2008-10-24 Thread Jacob

I just wanted to second this problem.  When I run a Maple command in
the Sage Notebook (Sage 3.1.2 on OSX 10.4), I have to execute the cell
three times to see the output.  The first time I execute, I get no
output at all.  The second time, I get an output that's something like

read
/Users/jacobml/.sage//temp/dhcp224198.local/53206//interface//tmp532

and the third time I actually get the expected output--plus some
garbage.  For example, if I execute

Weierstrassform(x^3+y^3+1,x,y,x0,y0)

(after loading the algcurves package) I get output

read
/Users/jacobml/.sage//temp/dhcp224198.local/53206//interface//
tmp53206\
;
read
/Users/jacobml/.sage//temp/dhcp224198.local/53206//interface//
tmp53206\
;
read
/Users/jacobml/.sage//temp/dhcp224198.local/53206//interface//
tmp53206\
;
[x0^3+27/4+y0^2, -3*y^2+3*y*x-3*x^2, 9*y^2*x-9*y*x^2+9*x^3+9/2,
1/6*(9-2*y0)/
x0, 1/6*(9+2*y0)/x0]

-Jacob

On Oct 12, 12:50 am, William Stein [EMAIL PROTECTED] wrote:
 Andrey,

 I'm sending this to sage-support.



 On Sun, Oct 12, 2008 at 12:53 AM, Andrey Novoseltsev [EMAIL PROTECTED] 
 wrote:
  Dear William,

  I have problems usingMaple11 from Sage - it does something, but something is
  broken in the interface. Is it easy to fix and if yes, how? Below is a 
  sample
  session.

  Thank you,
  Andrey

  [EMAIL PROTECTED]:~$ ./sage-3.1.2/sage
  --
  | SAGE Version 3.1.2, Release Date: 2008-09-19                       |
  | Type notebook() for the GUI, and license() for information.        |
  --

  sage:maple.eval(1+1)
  'read /home/novoseltsev/.sage//temp/numbers.math.ualberta.ca/18866//interf'
  sage:maple.eval(1+1)
  ''
  sage:maple.eval(1+1)
  '2'
  sage:maple.eval(1+1)
  'read /home/novoseltsev/.sage//temp/numbers.math.ualberta.ca/18866//interf'
  sage:maple.eval(1+1)
  ''
  sage:maple.eval(1+1)
  '2'
  sage:maple.eval(1+1)
  'read /home/novoseltsev/.sage//temp/numbers.math.ualberta.ca/18866//interf'
  sage:maple.eval()
  ''
  sage:maple.eval()
  ''
  sage:maple.eval()
  ''
  sage:maple.eval()
  ''
  sage:maple.eval()
  ''
  sage: exit
  Exiting SAGE (CPU time 0m0.05s, Wall time 16m59.57s).
  Exiting spawnedMapleprocess.
  [EMAIL PROTECTED]:~$maple
     |\^/|    Maple11 (X86 64 LINUX)
  ._|\|   |/|_. Copyright (c) Maplesoft, a division of WaterlooMapleInc. 2007
   \  MAPLE /  All rights reserved.Mapleis a trademark of
      WaterlooMapleInc.
       |       Type ? for help.

 --
 William Stein
 Associate Professor of Mathematics
 University of Washingtonhttp://wstein.org

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---