Re: [sage-support] Re: [sage-devel] simplify_full on matrices.

2011-01-20 Thread Robert Bradshaw
On Wed, Jan 19, 2011 at 10:16 AM, kcrisman kcris...@gmail.com wrote:


 On Jan 19, 8:24 am, ancienthart joalheag...@gmail.com wrote:
 Attempting to use this on my matrix, I end up with the following results (D
 is my matrix):


 I personally wish that sage simplify functions worked as follows:

 simplify_rational and simplify_trig work as currently implemented.
 simplify was renamed simplify_basic
 Simplify was replaced with a new method/function that try/excepted the
 algorithms in simplify_full, simplify_trig, simplify_rational then
 simplify_basic, returning the first that succeeded.
 I understand the need to provide functions that control the level of detail
 used when simplifying complex problems.
 However I'd assume that most basic/mid-level users just want the
 expression/equation/object simplified with as little fiddly-ness as
 possible. Currently I tend to call simplify_full on most problems - I.e.
 simplify_full is my practical default rather than simplify.

 I feel like there is a ticket out there to refactor a lot of this kind
 of stuff (simplify, expand, factor, etc.).  Since there is a lot of
 disagreement on what exactly is the best course of action, we have
 thus far continued our current scheme.  I think that this is not the
 worst of the proposals I've heard.

 More important is the option to apply a lot of things to a matrix.
 Simon's got the right idea (lambda functions) for what you want to
 do.  But we should make this easier.  My guess is that even the
 'magic' decorator for turning methods into functions wouldn't help
 here, and that is too bad.  Maybe matrices need some way for that to
 happen - but I have no idea how one would implement something general
 like that, esp. if one couldn't tell ahead of time whether all the
 elements would have the method.

sage: A = random_matrix(SR, 3) - x; A
[-x -2 -2]
[ 2 -x - 1 -2]
[-1 -2 -x + 1]
sage: A.apply_map(type(x).simplify_full)
[-x -2 -2]
[ 2 -x - 1 -2]
[-1 -2 -x + 1]

sage: A = matrix(3, 3, [(1+x)^k for k in range(9)]); A
[1 x + 1 (x + 1)^2]
[(x + 1)^3 (x + 1)^4 (x + 1)^5]
[(x + 1)^6 (x + 1)^7 (x + 1)^8]
sage: type(x)
type 'sage.symbolic.expression.Expression'
sage: A.apply_map(Expression.expand)
[ 1
  x + 1
  x^2 + 2*x + 1]
[ x^3 + 3*x^2 + 3*x + 1
  x^4 + 4*x^3 + 6*x^2 + 4*x + 1
x^5 + 5*x^4 + 10*x^3 + 10*x^2 + 5*x + 1]
[  x^6 + 6*x^5 + 15*x^4 + 20*x^3 + 15*x^2 + 6*x + 1
  x^7 + 7*x^6 + 21*x^5 + 35*x^4 + 35*x^3 + 21*x^2 + 7*x + 1 x^8 +
8*x^7 + 28*x^6 + 56*x^5 + 70*x^4 + 56*x^3 + 28*x^2 + 8*x + 1]


Also, +1 to renaming apply_map to map. The top-level map is a Python
function, perhaps we could re-purpose it if the first argument has a
map method?

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] plot problem

2011-01-18 Thread Robert Bradshaw
On Tue, Jan 18, 2011 at 2:35 PM, Daniel Harris
mail.dhar...@googlemail.com wrote:
 Hello everybody

 I am just looking at sketching graphs and I came across a problem that
 has me stumped.  The graph I am trying to sketch is

 (x-3) / ( (x+1) * (x-2) )

 now I have plotted the graph in sage on my TI-83 and at wolfram and
 they all different.  Now I am thinking is sage right and the others
 wrong? or have I made an error inputting the equation?

 I would certainly welcome some help on the issue

What range are you plotting over? -1  x  1? -5  x  5? This could
make a big difference on what the graph looks like. Likewise, what is
the scale of the y-axis? I don't think Sage yet tries to remove the
asymptotes at -1 and 2 from the plot.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] solving equation question --- rounding error ?

2011-01-18 Thread Robert Bradshaw
 On Tuesday, January 18, 2011 10:19:58 AM UTC-7, einek wrote:

 Hi tvn,

 Am Montag, den 17.01.2011, 14:22 -0800 schrieb tvn:
  I try to solve for 3 variables x y z with 3 equations as below  ,
  I am expecting something like  z = r1, x = -r1, y = -2*r1  but instead
  get x = y = z = 0 (which trivially valid though not expected).   Is
  this because the numbers used too complex (equation 2)  and have some
  rounding errors ?   if not what's the cause and how to get around it ?
  Thanks
 
 
 
 
  sage version 4.6.1
 
 
  solve([x + 0.106*y + 1.212*z == 0, 3.8759765625*x + 0.04801171875*y +
  3.972*z == 0, 3.0625*x + 0.09325*y + 3.249*z == 0],[x,y,z])
  [[x == 0, y == 0, z == 0]]   #not expected
 sage: A = matrix([[1, 0.106, 1.212], [3.8759765625, 0.04801171875,
 3.972], [3.0625, 0.09325, 3.249]])
 sage: A.rank()
 3

 Thus (0,0,0) is the unique solution of your system.

The problem is rounding error. Over the rationals:

sage: A = matrix(3, 3, [QQ(a) for a in [1, 0.106, 1.212, 3.8759765625,
0.04801171875, 3.972, 3.0625, 0.09325, 3.249]])
sage: A
[   1   53/500  303/250]
[   3969/1024 12291/256000  993/250]
[   49/16 373/40003249/1000]

sage: A.rank()
 2

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Sage compatibility in Leopard Mac OS

2010-12-29 Thread Robert Bradshaw
In fact, many sage developers use OS X as their primary system.
On Dec 29, 2010 9:58 PM, Michael Welsh yom...@yomcat.geek.nz wrote:
 Sage runs just fine in OS X.
 On 30/12/2010, at 5:36 PM, DigDug_the_2nd wrote:

 I am trying to choose whether to use Sage a Ubuntu machine or a Mac
 running Leopard on a 64 bit Duo 2 Core processor. As I understand it,
 Sage started in the Linux world and still can't run well under Windows
 with out using virtualization. I am new to Macs but I thought the Mac
 OS was more similar to Linux than Windows is and comes loaded with
 python. Does this mean that Sage can run all of its features in
 Leopard without virtualization, or are their some limitations?
 Thanks in advance for putting up with a newbie
 Doug

 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to
sage-support+unsubscr...@googlegroups.comsage-support%2bunsubscr...@googlegroups.com
 For more options, visit this group at
http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org

 --
 http://yomcat.geek.nz

 --
 To post to this group, send email to sage-support@googlegroups.com
 To unsubscribe from this group, send email to
sage-support+unsubscr...@googlegroups.comsage-support%2bunsubscr...@googlegroups.com
 For more options, visit this group at
http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: PY_TYPE_CHECK or isinstance?

2010-12-21 Thread Robert Bradshaw
On Tue, Dec 21, 2010 at 4:16 AM, Volker Braun vbraun.n...@gmail.com wrote:
 No, it's because your loop is over 1 rather than 1000.

 Sharp eyes! :)
 So, to summarize, with the improved Cython one should always use isinstance
 as it will be optimized to be at least as fast.

Yes, as long as the rhs is known by the compiler to be a type
(extension or built-in).

 I guess we should remove the
 PY_TYPE_CHECK macro from Sage altogether and replace every occurrence with
 isinstance?

Exactly. However, I just found a compiler crash with isinstance(x,
typet), so we should wait for the next Cython to go in before doing
this. There's a lot of cruft from when Cython just wasn't as good as
it is now that's still being used.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: PY_TYPE_CHECK or isinstance?

2010-12-21 Thread Robert Bradshaw
On Tue, Dec 21, 2010 at 10:29 AM, Jason Grout
jason-s...@creativetrax.com wrote:
 On 12/21/10 11:36 AM, Robert Bradshaw wrote:

 On Tue, Dec 21, 2010 at 4:16 AM, Volker Braunvbraun.n...@gmail.com
  wrote:

 No, it's because your loop is over 1 rather than 1000.

 Sharp eyes! :)
 So, to summarize, with the improved Cython one should always use
 isinstance
 as it will be optimized to be at least as fast.

 Yes, as long as the rhs is known by the compiler to be a type
 (extension or built-in).

 I guess we should remove the
 PY_TYPE_CHECK macro from Sage altogether and replace every occurrence
 with
 isinstance?

 Exactly. However, I just found a compiler crash with isinstance(x,
 typet), so we should wait for the next Cython to go in before doing
 this. There's a lot of cruft from when Cython just wasn't as good as
 it is now that's still being used.


 Do you mean wait until Cython 0.14 goes into Sage, or wait until Cython 0.15
 is released and goes into Sage?

0.14.1, which I'm thinking will be out in January (in time for 4.6.2,
and I think the 4.6.1 window is almost closed anyway).

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: factor() behaving badly

2010-12-21 Thread Robert Bradshaw
On Sun, Dec 19, 2010 at 9:39 PM, John H Palmieri jhpalmier...@gmail.com wrote:
 On Dec 19, 7:01 pm, Alex Raichev tortoise.s...@gmail.com wrote:
 Hi all:

 I get differently formatted answers using factor() multiple times on
 the same polynomial.  I wouldn't call it a bug, but it sure is
 annoying when doctesting.

 Alex

 --
 | Sage Version 4.6, Release Date: 2010-10-30                         |
 | Type notebook() for the GUI, and license() for information.        |
 --
 sage: R.x,y= PolynomialRing(QQ)
 sage: H= x^2*y^4 +y^6 +2*x^3*y^2 +2*x*y^4 -7*x^4 +7*x^2*y^2 +14*y^4
 +6*x^3 +6*x*y^2 +47*x^2 +47*y^2
 sage: for k in range(20):
 :     print H.factor()
 :
 (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47)
 (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47)
 (x^2 + y^2) * (y^4 + 2*x*y^2 - 7*x^2 + 14*y^2 + 6*x + 47)
 (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47)
 (x^2 + y^2) * (y^4 + 2*x*y^2 - 7*x^2 + 14*y^2 + 6*x + 47)
 (x^2 + y^2) * (y^4 + 2*x*y^2 - 7*x^2 + 14*y^2 + 6*x + 47)
 (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47)
 (x^2 + y^2) * (y^4 + 2*x*y^2 - 7*x^2 + 14*y^2 + 6*x + 47)
 (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47)
 (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47)
 (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47)
 (x^2 + y^2) * (y^4 + 2*x*y^2 - 7*x^2 + 14*y^2 + 6*x + 47)
 (x^2 + y^2) * (y^4 + 2*x*y^2 - 7*x^2 + 14*y^2 + 6*x + 47)
 (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47)
 (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47)
 (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47)
 (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47)
 (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47)
 (-x^2 - y^2) * (-y^4 - 2*x*y^2 + 7*x^2 - 14*y^2 - 6*x - 47)
 (x^2 + y^2) * (y^4 + 2*x*y^2 - 7*x^2 + 14*y^2 + 6*x + 47)

 Well, you could do

 sage: all([H==H.factor().prod() for k in range(20)])
 True

 to doctest it.  (I'm assuming that the prod method just does basic
 multiplication, and so its implementation has nothing to do with that
 of factor, so H==H.factor().prod() actually tests something
 meaningful.)

+1

Probably worth noting the number of factors as well, e.g.

sage: factorization = H.factor()
sage: len(factorization)
2
sage: prod(factorization) == H
True

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: PY_TYPE_CHECK or isinstance?

2010-12-20 Thread Robert Bradshaw
The PY_TYPE_CHECK macro exists primarily because Cython didn't used to
optimize isinstance.

On Mon, Dec 20, 2010 at 12:34 PM, Volker Braun vbraun.n...@gmail.com wrote:
 PY_TYPE_CHECK is just a wrapper macro around PyObject_TypeCheck which
 dereferences and compares the object type fields. So that part should be
 insanely fast.

If A is a cdef'd type (which is the precondition for using
PY_TYPE_CHECK), then isinstance(x, A) produces exactly the same code
as PY_TYPE_CHECK(x, A) (a single inline call to PyObject_TypeCheck).
Thus I'd say it's better to use the Pythonic isinstance. For some
builtins it can use even more specialized code.

 sage: cython('cpdef t(x):\n  for i in range(0,1000):\n
  PY_TYPE_CHECK(x,int)'); timeit(t(5000), repeat=100)
 625 loops, best of 100: 14.1 µs per loop
 sage: cython('cpdef t(x):\n  for i in range(0,1000):\n
  PY_TYPE_CHECK(x,float)'); timeit(t(5000), repeat=100)
 625 loops, best of 100: 14.1 µs per loop
 sage: cython('cpdef t(x):\n  for i in range(0,1000):\n
  isinstance(x,int)'); timeit(t(5000), repeat=100)
 625 loops, best of 100: 182 ns per loop
 sage: cython('cpdef t(x):\n  for i in range(0,1000):\n
  isinstance(x,float)'); timeit(t(5000), repeat=100)
 625 loops, best of 100: 14.1 µs per loop
 It seems like isinstance and PY_TYPE_CHECK are equally fast, except that
 isinstance caches the result if it was positive.
 But if you really write Cython code then you probably want to type the
 argument so that the compiler knows what x is. Then I get
 sage: cython('cpdef t(int x):\n  for i in range(0,1000):\n
  PY_TYPE_CHECK(x,int)'); timeit(t(5000), repeat=100)
 625 loops, best of 100: 7.72 µs per loop
 sage: cython('cpdef t(int x):\n  for i in range(0,1000):\n
  PY_TYPE_CHECK(x,float)'); timeit(t(5000), repeat=100)
 625 loops, best of 100: 12 µs per loop
 sage: cython('cpdef t(int x):\n  for i in range(0,1):\n
  isinstance(x,int)'); timeit(t(5000), repeat=100)
 625 loops, best of 100: 111 µs per loop
 sage: cython('cpdef t(int x):\n  for i in range(0,1):\n
  isinstance(x,float)'); timeit(t(5000), repeat=100)
 625 loops, best of 100: 118 µs per loop
 Now isinstance is a lot slower, while PY_TYPE_CHECK got moderately faster. I
 guess isinstance calls from C into Python while the PY_TYPE_CHECK stays in
 C?

No, it's because your loop is over 1 rather than 1000.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: PY_TYPE_CHECK or isinstance?

2010-12-20 Thread Robert Bradshaw
On Mon, Dec 20, 2010 at 12:27 PM, Jason Grout
jason-s...@creativetrax.com wrote:
 On 12/20/10 1:42 PM, Simon King wrote:

 Dear sage-support,

 at #10496, David Roe gave me the advice to use PY_TYPE_CHECK rather
 than isinstance in Cython files. I did so.

 But actually I didn't know PY_TYPE_CHECK at all, and so I have a two
 questions:

 1) Apparently there are  several PY_... functions. Where can I read
 about them?


 I see them imported in devel/sage/sage/ext/stdsage.pxi:

 ---
 cdef extern from stdsage.h:
    ctypedef void PyObject

    # Global tuple -- useful optimization
    void init_global_empty_tuple()
    object PY_NEW(object t)
    object PY_NEW_SAME_TYPE(object t)

    void* PY_TYPE(object o)
    bint PY_TYPE_CHECK(object o, object t)
    bint PY_TYPE_CHECK_EXACT(object o, object t)

    object IS_INSTANCE(object o, object t)
    void PY_SET_TP_NEW(object t1, object t2)
    bint HAS_DICTIONARY(object o)
    bint PY_IS_NUMERIC(object o)
 ---


 The stdsage.h file is in devel/sage/c_lib/include/stdsage.h, where we find:

 ---
 /** Tests whether zzz_obj is of type zzz_type. The zzz_type must be a
  * built-in or extension type. This is just a C++-compatible wrapper
  * for PyObject_TypeCheck.
  */
 #define PY_TYPE_CHECK(zzz_obj, zzz_type) \
    (PyObject_TypeCheck((PyObject*)(zzz_obj), (PyTypeObject*)(zzz_type)))
 ---

 in fact, we find later on:

 ---

 /** This is exactly the same as isinstance (and does return a Python
  *  bool), but the second argument must be a C-extension type -- so it
  *  can't be a Python class or a list.  If you just want an int return
  *  value, i.e., aren't going to pass this back to Python, just use
  *  PY_TYPE_CHECK.
  */
 #define IS_INSTANCE(zzz_obj, zzz_type) \
    PyBool_FromLong(PY_TYPE_CHECK(zzz_obj, zzz_type))
 ---


 ...interpret how you will




 2) Is PY_TYPE_CHECK really quicker than isinstance?

 It doesn't seem so, actually.

 In testtype.pyx, I wrote
 cpdef t1(x):
     return PY_TYPE_CHECK(x,int)
 cpdef t2(x):
     return isinstance(x,int)


 Then, I got the following timings:
 {{{
 sage: attach typecheck.pyx
 Compiling typecheck.pyx...
 sage: t1(5)
 False
 sage: t1(int(5))
 True
 sage: t2(5)
 False
 sage: t2(int(5))
 True
 sage: timeit(a=t1(5))
 625 loops, best of 3: 218 ns per loop
 sage: timeit(a=t2(5))
 625 loops, best of 3: 205 ns per loop
 sage: timeit(a=t1(int(5)))
 625 loops, best of 3: 416 ns per loop
 sage: timeit(a=t2(int(5)))
 625 loops, best of 3: 401 ns per loop
 }}}

 So, actually isinstance is slightly quicker than PY_TYPE_CHECK. Or do
 I misunderstand  something?



 I notice in the generated C code, Cython is smart and makes isinstance
 actually call PyInt_Check, which presumably is faster than PY_TYPE_CHECK.

 If instead, you are checking for the Integer type, I get faster numbers for
 PY_TYPE_CHECK than isinstance.  I also tried to lessen the effects of python
 call overhead by running the call in a loop in Cython:
 http://demo.sagenb.org/home/pub/65/

if you do from sage.rings.integer cimport Integer the speed
difference should go away.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] bool(arcsin(x) == 2*arctan(x/(1+sqrt(1-x^2)))) returns false !!!

2010-11-12 Thread Robert Bradshaw
On Fri, Nov 12, 2010 at 3:44 PM, Derrick we.sana...@gmail.com wrote:
 Any clue why bool(arcsin(x) == 2*arctan(x/(1+sqrt(1-x^2 returns
 false where the expressions are mathematically equivalent.

Because an expression being equal to zero is, in general, and
undecideable question. If it can't tell, it'd rather error on the side
of caution (not being equal) than claim they're equal.

 I found that arcsin(x) - 2*arctan(x/(1+sqrt(1-x^2))) is not exactly 0
 for all x in [-1,1].

True. You can't even represent arcsin(x) exactly as a floating point
number for most values of x. There's rounding error and all when you
combine operations as well.

 In sage, is there any way to compare expressions
 with some numerical precision?

sage: expr.subs(x=1/3).n()
0.000
sage: expr.subs(x=1/3).n(100)
3.9443045261050590270586428264e-31
sage: expr.subs(x=1/3).n(1000)
0.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Display all XXXX possibilities? Problem

2010-11-08 Thread Robert Bradshaw
Sounds like you have a tab in there somewhere, it typically shouldn't
be doing this.

On Mon, Nov 8, 2010 at 7:27 AM, JJBWebb johnjackw...@gmail.com wrote:
 I'm trying to build a power series, and when I call the function to
 build it, sage responds Display all  possiblities? (y or n).

 I hit n, then the same command pops up and then computes the power
 series correctly.

 Is there some way to get it so I don't have to hit n (i.e. avoid the
 Display all ... completely) so I can automate this process?

 Thanks,
 -John

 --
 | Sage Version 4.2, Release Date: 2009-10-24                         |
 | Type notebook() for the GUI, and license() for information.        |
 --
 sage: P = 79
 sage: m = 2
 sage: upbound= integer_floor(P^m*(P-1)/10)+10
 sage: R.q = PowerSeriesRing(IntegerModRing(P^m),upbound)
 sage: def EEbuild(bound):
 :           EE = 1 - q -q2 +O(q^upbound)
 :   for i in range(2,bound+1):
 : EE=EE+(-1)^i*(q^((1/2)*i*(3*i+1))+q^((1/2)*i*(3*i-1)))
 :   return EE
 :
 sage: lil = integer_floor(sqrt(upbound*4/3)) + 10
 sage:
 sage: ee = EEbuild(lil)+O(q^upbound)
 Display all 1859 possibilities? (y or n)
 sage: ee = EEbuild(lil)+O(q^upbound)
 sage:

 --
 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
 For more options, visit this group at 
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org


-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Creating large matrix hangs

2010-10-23 Thread Robert Bradshaw
On Fri, Oct 22, 2010 at 9:34 PM, Cary Cherng cche...@gmail.com wrote:
 I have a sage script that ultimately creates a python list called MMv
 of length 35354. Each element is a list of length 55. This is in
 effect a 35354 by 55 matrix. Print statements show that when I run my
 script with load two.sage it gets stuck at taking this list and
 creating a matrix. I am using the following to try to create the
 matrix.
 MM = matrix(ZZ, MMv)

 Is there a way I can debug or understand why the matrix creation isn't
 returning?

Can you run top() and see (1) how much CPU it's using and (2) how much
memory it's using (compared to your free memory).

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Python or Sage behavior? - List - tuple and iterator

2010-10-23 Thread Robert Bradshaw
On Sat, Oct 23, 2010 at 8:07 PM, Jason Grout
jason-s...@creativetrax.com wrote:
 A correction to my corrections inline below!

 On 10/23/10 9:56 PM, Jason Grout wrote:

 A few little corrections or explanations inline below...

 On 10/23/10 8:34 AM, Francois Maltey wrote:

 Rolandb wrote :

 test=((k2,k1) for k1 in xrange(2,4) for k2 in xrange(1,k1) if
 gcd(k1,k2)==1)
 print [t for t in test]
 print [t for t in test]
 [(1, 2), (1, 3), (2, 3)]
 []

 I begun to confuse lists L with [...] we can free change :
 one change one term by L[1]=123, and change the length by
 L[3:4]=[7,6,8], or del, or L.pop(), ...
 And tuple with (...) as T=(12,13,14,15) it's impossible to change.

 A void tuple or a void list are [] and ()

 Actually, the empty tuple is (,)---you mention why in this next sentence:


 You were right and I was wrong!

 sage: type(())
 type 'tuple'
 sage: (,)
 
   File ipython console, line 1
     (,)
      ^
 SyntaxError: invalid syntax

In most cases, it's really the comma (not the parentheses) that
creates the tuple.

sage: a = 123,
sage: a
(123,)

The parentheses are often needed for grouping purposes though.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] What's easiest way to get Sage running on Windows for non-techie students?

2010-10-11 Thread Robert Bradshaw
On Sat, Oct 9, 2010 at 7:53 AM, Chris Seberino cseber...@gmail.com wrote:
 What's easiest way to get Sage running on Windows for non-techie
 students?

 They'll be lost if the instructions are complicated.

 Possible to wrap a VMWare + Ubuntu + Sage blob into one big Windows
 exe file that requires no set up?

Depending on how technical you are, the easiest way by far is to set
up a Sage server for them yourself, and then all they need on their
windows boxes is a web browser and a password.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] What's easiest way to get Sage running on Windows for non-techie students?

2010-10-11 Thread Robert Bradshaw
On Mon, Oct 11, 2010 at 5:30 AM, A. Jorge Garcia calcp...@aol.com wrote:
 Depending on how technical you are, the easiest way by far is to set
 up a Sage server for them yourself, and then all they need on their
 windows boxes is a web browser and a password.

 I tried this, and I'm pretty techie, but found it was a huge hassle compared
 with just letting my students make an account on one of the SAGE servers
 online.  I have a lot of other hardware/software/firmware/networking issues
 to deal with, this way I have one less headache!

I've found pointing people to the public notebooks gives a less than
ideal experience, given how overloaded those things often are.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] Re: a sage simple server question

2010-10-05 Thread Robert Bradshaw
On Tue, Oct 5, 2010 at 7:57 AM, Francisco Botana fbot...@uvigo.es wrote:

 My question was (and is): is it possible to simultaneously send multiple
 commands to the simple server? That is, instead of setting, for instance, a
 to 2 and b to 3 with two distinct http requests, is it possible to send
 a=2;b=3 through the same request?

Yes, it should be. (Been a long time since I've looked at that code.)

 A similar question: sending a request as if True: a=5, 5 is assigned to a.
 But I get nothing with if False: a=5; else: b=3 and get

 NameError: name 'b' is not defined

 when asking about b.

 My goal is using Sage as a remote mathematical service for adding symbolic
 abilities to dynamic geometry environments such as GeoGebra.

 Any idea?

 Thanks in advance

Try inserting some newlines (and indentation). Newlines can be
inserted into a url with if True:%0a  a=5%0aelse:%0a   b=3 (though
typically you'd use a library call to do this).

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Global variables called in a function

2010-09-30 Thread Robert Bradshaw
On Thu, Sep 30, 2010 at 3:07 AM, Walker ebwal...@gmail.com wrote:
 sage: x = this is x
 sage: y = this is y
 sage: z = this is z
 sage: def f():
 :     print x
 :     y = new value
 :     print y
 :     global z
 :     z = new value
 :     print z
 :

 sage: f()
 this is x
 new value
 new value

 sage: x, y, z
 ('this is x', 'this is y', 'new value')

 Yes it's true, that's the behavior I was referring to. My problem was
 actually that I couldn't print a global variable inside a function
 before I made an assignment to it; the error was something like
 Cannot istantiate a local variable before assigning it. and I didn't
 understand why I had to assign locally a global variable which had
 already been assigned globally. Anyway the keyword global solved my
 problem.

Yep, a variable is either local or global throughout the entire function.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Global variables called in a function

2010-09-29 Thread Robert Bradshaw
On Wed, Sep 29, 2010 at 8:18 AM, Simon King simon.k...@nuigalway.ie wrote:
 Hi Walker!

 On 29 Sep., 16:42, Walker ebwal...@gmail.com wrote:
 ... My question is: is there a way to make Sage not
 creating a global variable but assigning directly the global one?

 This is actually a Python question.

Yes.

 It would of course be very
 dangerous if variables defined outside a function would influence what
 happens inside a function.

No, that's the expected and useful behavior. Otherwise you couldn't
even call other functions from your function (as they are just
variables).

 So, unless you explicitly declare *inside
 the function* that a variable is global, it won't be visible inside
 the function.

 So, you could do:
 sage: def f():
 :     global x
 :     print x
 :
 sage: x=3
 sage: f()
 3
 sage: x=5
 sage: f()
 5

Your f will have the same behavior even if x is not declared global.
It works just as it does in Python. Global variables are by default
readable but not writeable from the local scope, so if you do an
assignment and don't declare a variable to be global, then a local
shadow will be created. (Function arguments are considered assignments
as well.) In other words, variable declaration in Python is done by
assignment (as opposed to other languages where it is explicit). An
example is worth a thousand words:


sage: x = this is x
sage: y = this is y
sage: z = this is z
sage: def f():
: print x
: y = new value
: print y
: global z
: z = new value
: print z
:

sage: f()
this is x
new value
new value

sage: x, y, z
('this is x', 'this is y', 'new value')

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Question about polynomial rings and their fraction fields

2010-09-25 Thread Robert Bradshaw
On Fri, Sep 24, 2010 at 6:56 PM, kcrisman kcris...@gmail.com wrote:
 If I make a polynomial ring using

 sage: b = PolynomialRing(ZZ, 'x')

 I get some odd behavior.  Namely,

 sage: bool(b(x)==x)
 True
 sage: b(x)
 x
 sage: type(b(x))
 something about element of the ring
 sage: type(x)
 symbolic expression

 This isn't really that odd, but still I don't know whether it is good
 that one can still use x as a symbolic variable.  Probably this was a
 design decision.

There is the distinction between x the Python variable and x the
symbol (aka symbolic variable). For example, in the code below x and y
both store the symbol x.

sage: y = x
sage: y
x

x just happens to start out as a symbolic variable with the same name
as the Python variable. In general, we try to avoid overwriting the
namespace, so when you do

sage: x = 3
sage: PolynomialRing(ZZ, 'x')
Univariate Polynomial Ring in x over Integer Ring
sage: x
3

you don't have any surprises. You can change this with inject_on()

sage: inject_on()
Redefining: FiniteField Frac FractionField FreeMonoid GF
LaurentSeriesRing NumberField PolynomialRing quo quotient
sage: PolynomialRing(ZZ, 'x')
Defining x
Univariate Polynomial Ring in x over Integer Ring
sage: x
x
sage: type(x)
type 
'sage.rings.polynomial.polynomial_integer_dense_flint.Polynomial_integer_dense_flint'


(And whatever used to be in x is now gone.) Of course most people just write

sage: R.x = ZZ[]

which defines the ring and assigns the generator in one step.

 Anyway, what I really don't like is when you make

 sage: a = FractionField(PolynomialRing(ZZ, 'x'))
 sage: a(1/x)
 weird error that seems to imply it has not coerced x to the
 polynomial ring

We should certainly raise a better error here (or accept it).
Automatic coercion is always a compromise between convenience and
surprise. For example, if we didn't have any coercions there than

sage: a = ZZ['x'].gen()
sage: a = ZZ['x'](2)
sage: b = SR(2)
sage: a
2
sage: b
2
sage: bool(a == b)
False# hypothetically

would be especially confusing, especially if the context weren't so
clear (e.g. trying to debug something when a and b were generated by
completely different functions at completely different times.) Even if
one made an exception for constants

sage: a
x
sage: b
x
sage: bool(a == b)
False# hypothetically

I think would still cause more confusion than the current behavior.

 Did I do something wrong, or is this a bug?  Because of the initial
 behavior, maybe I shouldn't expect to be able to do this.

 Thanks,
 - kcrisman

 --
 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
 For more options, visit this group at 
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org


-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Question about polynomial rings and their fraction fields

2010-09-25 Thread Robert Bradshaw
On Sat, Sep 25, 2010 at 10:51 AM, kcrisman kcris...@gmail.com wrote:

 This is the only possibility, because the var('x') command executed
 by default at startup did the assignment

 x = SR('x')

 and you haven't bound x to any other object. Once you execute

 x = b.0

 [ or one of its implicit forms like b.x=PolynomialRing(ZZ,'x')] then
 x is no longer referencing the symbolic expression x, but the
 univariate polynomial x instead.

 Okay, I knew that this would work, but it seems odd that
 PolynomialRing(ZZ, 'x') doesn't actually change x, though it's
 consistent.  So it just represents things with x until I ask for the
 Python variable x to be that x, not the var x.

I you want that, do

sage: inject_on()

 Nice to see the positive review for 
 http://trac.sagemath.org/sage_trac/ticket/7741
 :)  Thanks

Thanks from me too, that's been waiting a long time.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Wrapping C++

2010-09-23 Thread Robert Bradshaw
On Thu, Sep 23, 2010 at 6:57 AM, Bruce brucewestb...@gmail.com wrote:
 I have a C++ function I want to call from sage. I have attempted to
 follow the example in
 http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html

 This was unsuccessful. The C++ class is not recognised. The problem
 seems to be that this is Cython v0.13 whereas sage 4.5.2 (which I am
 using) and sage 4.5.3 uses Cython v0.12.

 If this is correct the options seem to be to use cython v0.12 (in
 which case I don't have documentation) or to upgrade to cython v0.13
 (which I don't know how to do).

 Here is how I tried to read in my C++ header file:

 cdef extern from /home/masdbn/planargraph/Graph.hpp namespace
 PlanarGraph:
    cdef cppclass Graph:
        pass

 Where do I go from here? Thanks

You have to wrap it the old style way:

http://wiki.cython.org/WrappingCPlusPlus?action=recallrev=24

Or get someone to review
http://trac.sagemath.org/sage_trac/ticket/9828 so we can get 0.13 into
Sage.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Is this a bug?

2010-09-18 Thread Robert Bradshaw
http://trac.sagemath.org/sage_trac/ticket/9945 needs review.

On Fri, Sep 17, 2010 at 8:28 PM, Robert Bradshaw
rober...@math.washington.edu wrote:
 Oops. I'll post a fix.

 On Fri, Sep 17, 2010 at 12:42 PM, kcrisman kcris...@gmail.com wrote:


 On Sep 17, 2:30 pm, Alex Lara lrodr...@gmail.com wrote:
 Hi everyone

 In Sage 4.5.2 and Sage 4.5.3, I get the following error using
 partial_fraction_decomposition()

 sage: R.x = GF(3)[]
 sage: q = (x+1)/(x^3+x+1)

 If you try

 sage: q.part[tab]

 you'll see that this isn't a method for this object.

 You are also right that this *was* a method, even as recently as Sage
 4.4.4.

 Old:
 sage: type(q)
 type 'sage.rings.fraction_field_element.FractionFieldElement'

 New:
 sage: type(q)
 type 'sage.rings.fraction_field_FpT.FpTElement'

 Sounds like a small API change to me, though probably unintentional.

 Looks like ticket #9051, which added this file, was due to Robert
 Bradshaw.  I'm sure he or someone else will have additional info for
 you.  I would log this as a new Trac ticket, but I'm not sure whether
 this is related to http://trac.sagemath.org/sage_trac/ticket/8499

 Thanks for the report!

 - kcrisman



 The same error I get using primes different from 2. But if I use 3^2
 instead of 3, or a power of some prime, I get a right answer.

 I did not have the problem using Sage 4.4.1.

 Thanks in advance.

 Alex

 --
 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
 For more options, visit this group at 
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org



-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Is this a bug?

2010-09-17 Thread Robert Bradshaw
Oops. I'll post a fix.

On Fri, Sep 17, 2010 at 12:42 PM, kcrisman kcris...@gmail.com wrote:


 On Sep 17, 2:30 pm, Alex Lara lrodr...@gmail.com wrote:
 Hi everyone

 In Sage 4.5.2 and Sage 4.5.3, I get the following error using
 partial_fraction_decomposition()

 sage: R.x = GF(3)[]
 sage: q = (x+1)/(x^3+x+1)

 If you try

 sage: q.part[tab]

 you'll see that this isn't a method for this object.

 You are also right that this *was* a method, even as recently as Sage
 4.4.4.

 Old:
 sage: type(q)
 type 'sage.rings.fraction_field_element.FractionFieldElement'

 New:
 sage: type(q)
 type 'sage.rings.fraction_field_FpT.FpTElement'

 Sounds like a small API change to me, though probably unintentional.

 Looks like ticket #9051, which added this file, was due to Robert
 Bradshaw.  I'm sure he or someone else will have additional info for
 you.  I would log this as a new Trac ticket, but I'm not sure whether
 this is related to http://trac.sagemath.org/sage_trac/ticket/8499

 Thanks for the report!

 - kcrisman



 The same error I get using primes different from 2. But if I use 3^2
 instead of 3, or a power of some prime, I get a right answer.

 I did not have the problem using Sage 4.4.1.

 Thanks in advance.

 Alex

 --
 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
 For more options, visit this group at 
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org


-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: continued_fraction returns nothing

2010-09-15 Thread Robert Bradshaw
On Wed, Sep 15, 2010 at 3:47 AM, Håkan Granath
hakan.gran...@googlemail.com wrote:
 On Sep 15, 3:44 am, Robert Bradshaw rober...@math.washington.edu
 wrote:
 On Tue, Sep 14, 2010 at 10:44 AM, Håkan Granath

 hakan.gran...@googlemail.com wrote:
  On Sep 14, 12:16 am, Robert Bradshaw rober...@math.washington.edu
  wrote:

  Alastair correctly deduced the issue that it can't tell if the number
  is less than or greater than 2, what should it do here?

  I do not know what it should do, but what I would have expected
  in this case is that continued_fraction would first compute the
  53 bit approximation of the input, and then return the continued
  fraction of that approximation.

 If this is what you want, the way to get that is to give it something
 that has 53 bits of precision.

 I completely agree :-) In fact, that is what I tried to do but
 got unexpected results. Some background information:

 I compute some quantity a, which is a product of the result of
 some high precision (say 1000 bits) numerical computation and an
 exact algebraic factor. The number a is expected to be rational,
 so to identify it I do something like

  b = a.n(1000)
  v = continued_fraction(b)

 However this did not always work, because in some cases b was not
 a floating point number as expected but a symbolic expression (a
 bug in my opinion, see below). This, I found, can make the
 continued fraction computation fail in 2 ways:

  1. Sometimes, since b is symbolic it is computed with the
  default 53 bit precision which is inadequate for my purposes.

  2. Sometimes v would be the empty list.

 Of course I can work around this by doing something like

  b = a.n(1000).n(1000)

 but, although it works for my code, it is somewhat of a
 cludge. Hence I reported the two issues: the topic of this thread
 and the issue I found with the n() function:

 http://groups.google.com/group/sage-support/browse_thread/thread/b36c90f1490eac19

 I hope this makes sense.

Yes, that issue with n() is certainly the root of the problem.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: continued_fraction returns nothing

2010-09-14 Thread Robert Bradshaw
On Tue, Sep 14, 2010 at 10:44 AM, Håkan Granath
hakan.gran...@googlemail.com wrote:
 On Sep 14, 12:16 am, Robert Bradshaw rober...@math.washington.edu
 wrote:

 Alastair correctly deduced the issue that it can't tell if the number
 is less than or greater than 2, what should it do here?

 I do not know what it should do, but what I would have expected
 in this case is that continued_fraction would first compute the
 53 bit approximation of the input, and then return the continued
 fraction of that approximation.

If this is what you want, the way to get that is to give it something
that has 53 bits of precision.

 Not returning anything is quite unexpected.

Nothing != the empty list. In any case, I think it's better to only
give correct digits than have an arbitrary number of tail terms be
spurious random stuff that may or may not stabilize as the precision
goes up.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: continued_fraction returns nothing

2010-09-14 Thread Robert Bradshaw
On Tue, Sep 14, 2010 at 6:44 PM, Robert Bradshaw
rober...@math.washington.edu wrote:
 On Tue, Sep 14, 2010 at 10:44 AM, Håkan Granath
 hakan.gran...@googlemail.com wrote:
 On Sep 14, 12:16 am, Robert Bradshaw rober...@math.washington.edu
 wrote:

 Alastair correctly deduced the issue that it can't tell if the number
 is less than or greater than 2, what should it do here?

 I do not know what it should do, but what I would have expected
 in this case is that continued_fraction would first compute the
 53 bit approximation of the input, and then return the continued
 fraction of that approximation.

 If this is what you want, the way to get that is to give it something
 that has 53 bits of precision.

I should add that I think some of the confusion comes in the way
symbolics and numerical approximations interact.

sage: sqrt(2).n() * sqrt(2)
1.41421356237310*sqrt(2)

This is, in general, a hard problem, as one needs to guess what the
user actually wants...

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: continued_fraction returns nothing

2010-09-13 Thread Robert Bradshaw
On Mon, Sep 13, 2010 at 1:30 PM, Marshall Hampton hampto...@gmail.com wrote:
 I am guessing this is an indirect effect from this patch:

 http://trac.sagemath.org/sage_trac/ticket/8017

 but I am not sure.  If you do continued_fraction(N(a)) you get the
 same answer as before, but I would say this is a bug that shouldn't
 need a workaround.

Alastair correctly deduced the issue that it can't tell if the number
is less than or greater than 2, what should it do here?

 On Sep 13, 11:31 am, Håkan Granath hakan.gran...@googlemail.com
 wrote:
 In certain cases I get nothing from the continued_fraction function
 in the latest Sage version:

 --
 | Sage Version 4.5.3, Release Date: 2010-09-04                       |
 | Type notebook() for the GUI, and license() for information.        |
 --
 sage: a=sqrt(2).n()*sqrt(2)
 sage: continued_fraction(a)
 []

 In version 4.5.2 the output was

 [2, 2251799813685248]

Which was wrong.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Arbitrary precision in Cython NumPy?

2010-09-09 Thread Robert Bradshaw
On Wed, Sep 8, 2010 at 6:39 PM, KvS keesvansch...@gmail.com wrote:
 Thanks all, however I am not very successful so far :(.

 I tried both options mentioned before:

 - only optimize the loops in Cython and keep using symbolic
 expressions/infinite precision, but this is unfortunately rather
 slow;

What do you mean by symbolic? Are you actually using maxima and the
various calculus modules?

 - fully optimize in Cython by turning to doubles everywhere, although
 it gets very fast here happens what I was already afraid of: the
 algorithm goes belly up after 15 steps :( (I would need a lot more
 steps). In step 14 values like 2.51885860e-34 appear and in
 combination with the numerical noise gathered this turns out to
 produce very wrong values at the next step.

 @Robert: I'm trying to implement an algorithm that computes a sequence
 of functions v_k according to the rule v_k(x) = \max \{ K-e^x, \int
 v_{k-1}(y) p(x+y) dy \}, v_0(x)=K-e^x, where p is a prob. density. The
 background is an optimal stopping problem in stochastics. So at each
 step I essentially first compute the integral and then determine where
 the integral and x - K-e^x intersect, this just by the basic
 find_root function in Sage.

 It's not difficult (however very annoying...) to write down a formula
 for the integral (given the specific density p I'm using) and work out
 formulae for all the coefficients that appear in this formula for the
 integral in terms of those appearing in v_{k-1}. The number of
 coefficients (and hence computations) involved in the formula for v_k
 increases very quickly with k, that explains why the algorithm gets
 slow in 'symbolic mode'. However 'double mode' is not good enough as
 mentioned above.

It sounds like you're trying too extreems--how about using your
double mode algorithm, but instead using elements of RealField(N)
where N  53. This should be much faster than symbolic (if I
understand you right, calling find_root and integrate) but have higher
precision than using raw doubles. This may be enough, without getting
your hands on MPFR directly yourself.

You might also consider looking at how the dickman rho function is
implemented 
http://hg.sagemath.org/sage-main/file/b5dab6864f35/sage/functions/transcendental.py#l464
which sounds similar in spirit.

 I will try your suggestion for using mpfr, thanks Robert and Greg!
 (however it looks a bit scary to me ;)). I need to store the huge
 amounts of coefficients somewhere, I guess numpy is my best guess even
 though I have to declare the dtype as object then, no?

What do you mean by huge? Would a list suffice? Or if it's a
polynomial, what about a polynomial in RR? For high precision, the
per-element overhead is constant, so I don't see an advantage to using
NumPy here just as a storage divice if the dtype is object.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Arbitrary precision in Cython NumPy?

2010-09-09 Thread Robert Bradshaw
On Thu, Sep 9, 2010 at 9:46 AM, Jason Grout jason-s...@creativetrax.com wrote:
 On 9/9/10 11:27 AM, Robert Bradshaw wrote:

 This should be much faster than symbolic (if I
 understand you right, calling find_root and integrate) but have higher
 precision than using raw doubles.

 I believe the standard find_root uses scipy, which is limited to double
 precision.

Shouldn't be too hard to follow up with Newton's method to increase
the precision if desired.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Arbitrary precision in Cython NumPy?

2010-09-09 Thread Robert Bradshaw
On Thu, Sep 9, 2010 at 11:44 AM, KvS keesvansch...@gmail.com wrote:
 On Sep 9, 5:27 pm, Robert Bradshaw rober...@math.washington.edu
 wrote:
 On Wed, Sep 8, 2010 at 6:39 PM, KvS keesvansch...@gmail.com wrote:
  Thanks all, however I am not very successful so far :(.

  I tried both options mentioned before:

  - only optimize the loops in Cython and keep using symbolic
  expressions/infinite precision, but this is unfortunately rather
  slow;

 What do you mean by symbolic? Are you actually using maxima and the
 various calculus modules?

 By symbolic/infinite precision I just mean keeping quantities like say
 log(2) as they are, rather than approximating them by some finite
 precision real number, sorry for the confusion. No, I am not using
 Maxima or anything more advanced than the elementary operations, the
 exponential function and the find_root function.




  - fully optimize in Cython by turning to doubles everywhere, although
  it gets very fast here happens what I was already afraid of: the
  algorithm goes belly up after 15 steps :( (I would need a lot more
  steps). In step 14 values like 2.51885860e-34 appear and in
  combination with the numerical noise gathered this turns out to
  produce very wrong values at the next step.

  @Robert: I'm trying to implement an algorithm that computes a sequence
  of functions v_k according to the rule v_k(x) = \max \{ K-e^x, \int
  v_{k-1}(y) p(x+y) dy \}, v_0(x)=K-e^x, where p is a prob. density. The
  background is an optimal stopping problem in stochastics. So at each
  step I essentially first compute the integral and then determine where
  the integral and x - K-e^x intersect, this just by the basic
  find_root function in Sage.

  It's not difficult (however very annoying...) to write down a formula
  for the integral (given the specific density p I'm using) and work out
  formulae for all the coefficients that appear in this formula for the
  integral in terms of those appearing in v_{k-1}. The number of
  coefficients (and hence computations) involved in the formula for v_k
  increases very quickly with k, that explains why the algorithm gets
  slow in 'symbolic mode'. However 'double mode' is not good enough as
  mentioned above.

 It sounds like you're trying too extreems--how about using your
 double mode algorithm, but instead using elements of RealField(N)
 where N  53. This should be much faster than symbolic (if I
 understand you right, calling find_root and integrate) but have higher
 precision than using raw doubles. This may be enough, without getting
 your hands on MPFR directly yourself.

 (I don't need to do any integration in the code, sorry if my previous
 post seemed to suggest that, the integral that occurs there I have
 worked out completely in terms of elementary operations.) Yes, I have
 tried your suggestion of using RealField (without Cython though) and
 this works good in the sense that the added precision in comparison
 with floats makes the algorithm produce reliable output, thanks!

 However, it is still too slow.

Just out of curiosity, how much did it help?

 If I could further speed it up by a few
 factors that would be great. I will further try if I can figure out
 how to use Cython to speed up parts of the algorithm where a lot of
 looping and computing is done.

That should be feasible--you probably don't need to change the whole
thing--profile to see what parts. Excessive coercion may also impact
things.

 You might also consider looking at how the dickman rho function is
 implementedhttp://hg.sagemath.org/sage-main/file/b5dab6864f35/sage/functions/tra...
 which sounds similar in spirit.

  I will try your suggestion for using mpfr, thanks Robert and Greg!
  (however it looks a bit scary to me ;)). I need to store the huge
  amounts of coefficients somewhere, I guess numpy is my best guess even
  though I have to declare the dtype as object then, no?

 What do you mean by huge? Would a list suffice? Or if it's a
 polynomial, what about a polynomial in RR? For high precision, the
 per-element overhead is constant, so I don't see an advantage to using
 NumPy here just as a storage divice if the dtype is object.

 The function v_k is not a polynomial but a piecewise function
 consisting of linear combinations of terms a*x^b*exp(c*x) (*) in each
 part of its domain. 'Huge' means that the number of coefficients (i.e.
 all the a, b and c's in (*)) to be computed in the k-th step of the
 algorithm roughly grows like k^2. These coefficients are currently
 organized in 4-dimensional Numpy-arrays: the k runs along one axis and
 there are three other 'counters' (one to keep track of the part of the
 domain etc.). I would prefer not to give up this way of representing
 the coefficients as my notes use this form as well. Would you say I
 could better use 4-d Python lists rather?

No, for multi-dimensional stuff, NumPy is better, even if you're using
the object dtype.

- Robert

-- 
To post to this group, send email to sage

Re: [sage-support] Re: Arbitrary precision in Cython NumPy?

2010-09-08 Thread Robert Bradshaw
On Wed, Sep 8, 2010 at 3:03 PM, Greg Marks gtma...@gmail.com wrote:
 It sounds like a C program using MPFR (http://www.mpfr.org)
 would do what you want.  As MPFR is built into SAGE, you might
 perhaps find it more convenient to invoke MPFR within SAGE.

This is what I would recommend. You can do something like

from sage.rings.real_mpfr cimport *

def square(RealNumber x):
cdef RealNumber result = x._new()
mpfr_mul(result.value, x.value, x.value, GMP_RNDN)
return result

If you really need speed, you can declare, allocate, and free mpfr_t
variables themselves (declared via cdef mpfr_t var) rather than
using the RealNumber Python objects as wrappers.

Just out of curiosity, what multi-precision root finding tools are you
using? Also, I don't think numpy supports high-precision floating
point arrays (except as arrays of generic objects).

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] sticking matricies together

2010-09-04 Thread Robert Bradshaw
On Sat, Sep 4, 2010 at 8:15 AM, andrew ewart aewartma...@googlemail.com wrote:
 How do u stick a matrix on the bottom of antoher martix, in particular
 the identity matrix
 so if had M (l,k) how do I stick Id(k) on the bottom to produce a new
 matrix
 N=M   and N is dimension (l+k,k)
    Id

Look at M.stack() and M.augment().

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Factoring denominator of a rational function

2010-09-04 Thread Robert Bradshaw
On Sat, Sep 4, 2010 at 3:25 AM, ma...@mendelu.cz ma...@mendelu.cz wrote:
 What about to use polynomial division to get polynomial q=Q/p and then
 return P/q ?

 I do not remember the command for polynomial division, but should be
 in the manual or help.

If Q and p are polynomials, polynomial division is just Q/p (or Q//p
for divide and truncate).

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Factoring denominator of a rational function

2010-09-04 Thread Robert Bradshaw
On Sat, Sep 4, 2010 at 7:00 PM, Cary Cherng cche...@gmail.com wrote:
 Ok i think I've resolved my problems by avoiding var for declaring
 variables and instead using
 R.g17,g19,g27,g29,g37,g38,g47,g48,g58,g59,g68,g69 =
 PolynomialRing(QQ)

Yes, that should be orders of magnitude faster than doing things
purely symbolically. I think we all assumed you were already doing
this, sorry.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Number of CPUs?

2010-09-03 Thread Robert Bradshaw
On Fri, Sep 3, 2010 at 10:47 AM, Simon King simon.k...@nuigalway.ie wrote:
 Hi!

 I have a list of computations (in fact, a test suite), and I'd like to
 do them in parallel. Of course, I could use @parallel, but:
  1) each computation uses 3 processes (Sage, GAP, Singular)
  2) it is probably not nice to other users if parallel computation
 uses all available CPUs.

Are the tests simultaneously using lots of CPU on all three processes,
or (more likely) is one doing the work and the other two waiting
around for most of the time. In this case, no need to divide by two or
three.

 I'd like to restrict @parallel(ncpus=...), where ... is something
 like 1/2 (or 1/3?) of the available CPUs. But how can I determine
 this number?

 Besides, a while ago I asked how one can execute the sage test script
 on a string, *without* saving that string into a file and *without*
 forking a sage -t subprocess. Do you see a way?

I don't know of any way to do that, but saving to a file isn't so bad.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Fixed Point arithmetic

2010-08-24 Thread Robert Bradshaw
On Tue, Aug 24, 2010 at 1:27 PM, William Stein wst...@gmail.com wrote:
 Did you do this once for something...

Yes, see http://trac.sagemath.org/sage_trac/ticket/9180

 -- Forwarded message --
 From: Mike Hansen mhan...@gmail.com
 Date: Tue, Aug 24, 2010 at 12:21 PM
 Subject: Re: [sage-support] Fixed Point arithmetic
 To: sage-support@googlegroups.com


 On Tue, Aug 24, 2010 at 12:14 PM, Jeroen Demeyer jdeme...@cage.ugent.be 
 wrote:
 Is there any support in Sage for fixed point arithmetic?  That is,
 computing with real numbers with a fixed number of bits after the
 decimal point?

 Fredrik Johansson has done some work in this area -- see
 http://code.google.com/p/fastfunlib/.  Note that there isn't really a
 usable library there.

 --Mike

 --
 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
 For more options, visit this group at
 http://groups.google.com/group/sage-support
 URL: http://www.sagemath.org



 --
 William Stein
 Professor of Mathematics
 University of Washington
 http://wstein.org


-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: How can I make implicit_multiplication default?

2010-08-23 Thread Robert Bradshaw
On Mon, Aug 23, 2010 at 6:54 AM, Simon King simon.k...@nuigalway.ie wrote:
 Hi Robin,

 On 23 Aug., 13:43, robin hankin hankin.ro...@gmail.com wrote:
 Re automatic_names(): why isn't this the default?

 Now I know it exists, I think I'll probably use it all the time.

 Who uses sage without this option?

 I find automatic_names horrible, to say the least! In my opinion, such
 thing should *never ever* be standard!

 1. If you write a little program on the command line and it does
 something, but simply it doesn't do the right thing or you get strange
 error messages about missing attributes -- it would be very hard to
 find out that you forgot to define some object X, so that Sage worked
 in the wrong assumption that X is a symbolic variable. I strongly
 prefer to get a clear error message, namely NameError: Name 'X' is
 not defined or so.

 2. Explicit is better than implicit is a quite common credo. I think
 it is unsafe to rely on implicit assumptions of the type of an object.

 3. I hardly ever work with symbolic variables. So, I really don't see
 the point why X should default to a symbolic variable.

 4. My impression is that for quite many people a symbolic variable is
 the first thing that comes to mind when computing in a CAS - and it
 takes them a long while until they find that for their particular
 problem a different class (like a polynomial) works much better.
 Making a symbolic variable the default, I am afraid that one would
 support the wrong belief that symbolic variables are good for
 *everything*.


 So, it is not so much that programs would break. But debugging would
 be more difficult, and it would teach the people the wrong lesson,
 IMHO. And on the other hand, I can't see how life with Sage would be
 any easier if automatic_names was the standard.

Think about someone working through a series of calculus textbook
exercises (mostly one-liners). Personally, I wouldn't every want it to
be default, but can see how some people could really find it useful
(especially as we're aiming to be a viable alternative to the Ma's.
Also, note that Python itself has implicit variable declaration (as
opposed to, say, C, etc.) which has its pros and cons (though I like
it).

This, and implicit multiplication, should be in the FAQ at least.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: How can I make implicit_multiplication default?

2010-08-23 Thread Robert Bradshaw
On Mon, Aug 23, 2010 at 9:08 AM, Robert Bradshaw
rober...@math.washington.edu wrote:
 On Mon, Aug 23, 2010 at 6:54 AM, Simon King simon.k...@nuigalway.ie wrote:
 Hi Robin,

 On 23 Aug., 13:43, robin hankin hankin.ro...@gmail.com wrote:
 Re automatic_names(): why isn't this the default?

 Now I know it exists, I think I'll probably use it all the time.

 Who uses sage without this option?

 I find automatic_names horrible, to say the least! In my opinion, such
 thing should *never ever* be standard!

 1. If you write a little program on the command line and it does
 something, but simply it doesn't do the right thing or you get strange
 error messages about missing attributes -- it would be very hard to
 find out that you forgot to define some object X, so that Sage worked
 in the wrong assumption that X is a symbolic variable. I strongly
 prefer to get a clear error message, namely NameError: Name 'X' is
 not defined or so.

 2. Explicit is better than implicit is a quite common credo. I think
 it is unsafe to rely on implicit assumptions of the type of an object.

 3. I hardly ever work with symbolic variables. So, I really don't see
 the point why X should default to a symbolic variable.

 4. My impression is that for quite many people a symbolic variable is
 the first thing that comes to mind when computing in a CAS - and it
 takes them a long while until they find that for their particular
 problem a different class (like a polynomial) works much better.
 Making a symbolic variable the default, I am afraid that one would
 support the wrong belief that symbolic variables are good for
 *everything*.


 So, it is not so much that programs would break. But debugging would
 be more difficult, and it would teach the people the wrong lesson,
 IMHO. And on the other hand, I can't see how life with Sage would be
 any easier if automatic_names was the standard.

 Think about someone working through a series of calculus textbook
 exercises (mostly one-liners). Personally, I wouldn't every want it to
 be default, but can see how some people could really find it useful
 (especially as we're aiming to be a viable alternative to the Ma's.
 Also, note that Python itself has implicit variable declaration (as
 opposed to, say, C, etc.) which has its pros and cons (though I like
 it).

 This, and implicit multiplication, should be in the FAQ at least.

One more thing--I find it really handy when I'm pasting in expressions
form elsewhere, e.g. a paper or something. However, rather than enable
the options in the preparser and changing the language, I do


sage: SR(x^2 + 2x - 5y)
x^2 + 2*x - 5*y

This string-level implicit multiplication/variable binding for
polynomial rings too:

sage: R = QQ['x']
sage: R(3x^5 - 2x)
3*x^5 - 2*x

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Boolean operators... Implication ?

2010-08-09 Thread Robert Bradshaw
On Mon, Aug 9, 2010 at 9:40 PM, Nathann Cohen nathann.co...@gmail.com wrote:
 This can of course be written (not g.is_forest() and g.has_even_cycle())

 Ok, ok, I know... Let's make it g.is_forest() or g.has_even_cycle()

Yes, one could create an infix operator, but I think the above is much
more clear than having to learn yet more notation.

Explicit is better than implicit.
Simple is better than complex.
...

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] regarding arrayobject.h

2010-08-09 Thread Robert Bradshaw
On Mon, Aug 9, 2010 at 1:59 AM, Rajeev rajs2...@gmail.com wrote:
 Hi,

 I was trying to work out the first example given in

 http://wiki.cython.org/WrappingNumpy

 in sage notebook, but got an error saying

 arrayobject.h not found. How do I get this example working?

I've fixed that page so it should work, but a better tutorial (linked
at the top of the page) is

http://wiki.cython.org/tutorials/numpy

(From the Sage notebook, you can just skip all the installation/setup stuff...)

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Cython: importing a cdef class

2010-08-04 Thread Robert Bradshaw
On Sat, Jul 31, 2010 at 1:21 AM, Simon King simon.k...@nuigalway.ie wrote:
 Hi Jeroen!

 On 31 Jul., 02:30, Robert Bradshaw rober...@math.washington.edu
 wrote:
 ...
  In file A.pyx, I have
  cdef MyClass myobj
  cdef class MyClass:
     [...]

  In file A.pxd, I have
  cdef class MyClass:
     [...]

  In file B.pyx, I would like to access myobj from A.pyx, but how?

 You can't access cdef members of Cython modules from other modules
 (yet). Here you'd probably want to make an accessors method in A.
 Either that our you could not declare it as a MyClass (but in that
 case it'd be just a normal Python object).

 Would this work?

 in A.pyx:
 myobj_py = MyClass(...)
 cdef MyClass myobj = myobj_py
 cdef class MyClass ...

 in A.pxd
 cdef class MyClass:
    [...]

 in B.pyx:
 from A import myobj_py
 from A cimport MyClass
 cdef MyClass myobj = myobj_py

 In that way, you have the cdef object myobj in both A and B

Yep.

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Cython: importing a cdef class

2010-07-30 Thread Robert Bradshaw
On Fri, Jul 30, 2010 at 2:39 PM, Jeroen Demeyer jdeme...@cage.ugent.be wrote:
 Hello sage-support,

 I have been breaking my head all evening around the file organisation
 and import model with Cython.  If there is any tutorial explaining
 this, I will gladly read it.

 Anyway, here is a concrete question:

 In file A.pyx, I have
 cdef MyClass myobj
 cdef class MyClass:
    [...]

 In file A.pxd, I have
 cdef class MyClass:
    [...]

 In file B.pyx, I would like to access myobj from A.pyx, but how?

You can't access cdef members of Cython modules from other modules
(yet). Here you'd probably want to make an accessors method in A.
Either that our you could not declare it as a MyClass (but in that
case it'd be just a normal Python object).

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Define an action

2010-07-27 Thread Robert Bradshaw
On Tue, Jul 27, 2010 at 12:50 AM, Simon King simon.k...@nuigalway.ie wrote:
 Hi Drenwal,

 On 25 Jul., 10:52, drenwal dren...@free.fr wrote:
 But, I would prefer to use a more mathematical notation, like Y[k] or
 y...@k or whatever non already used symbol instead of Ac(y,k).

 As Johannes has pointed out, Y[k] is already used, so, this might not
 be what you want. But, if it is, overwrite __getitem__ of matrices
 (this is the method that Python expects if you do Y[...]).
 '^' is also used; if you still want to use it, overwrite __pow__.

 How is it possible to do that?

 I don't know if/how '@' can be made use of. Usually, it seems that @
 indicates that a so-called decorator is being used.

 Talking about generators: There is a decorator that allows to define a
 custom infix operator (see
 http://www.sagemath.org/doc/reference/sage/misc/misc.html#sage.misc.misc.infix_operator).
 This might be what you were looking for, because it allows to create
 new operator names.

 Example:
  sage: from sage.all import infix_operator
  sage: @infix_operator('multiply')
  : def foo(a,b):
  :     return '%s acts from the right on %s'%(b,a)
  :
  sage: 5 *foo* 2
  '2 acts from the right on 5'

 Of course, in your case, it would be
   return b.transpose()*a*b

This is exactly what I was going to suggest. This is how we handle the
backslash operator for linear system solving:

http://hg.sagemath.org/sage-main/file/426be7b253ad/sage/misc/preparser.py#l1310

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] How to deal with wrapper_descriptor / slot wrapper

2010-07-27 Thread Robert Bradshaw
On Tue, Jul 27, 2010 at 9:24 AM, Simon King simon.k...@nuigalway.ie wrote:
 Hi!

 I have a Cython class COCH that inherits from RingElement. I define a
 method __pow__ for it, and it gets some doc string (which means
 tests).

 I thought that such method would be a class_method or whatever.
 Instead, I get
 sage: COCH.__pow__
 slot wrapper '__pow__' of 'pGroupCohomology.cochain.COCH' objects
 sage: type(COCH.__pow__)
 type 'wrapper_descriptor'

 And what's worse, I seem to be unable to retrieve the documentation!
  sage: COCH.__pow__.__doc__
  'x.__pow__(y[, z]) == pow(x, y[, z])'
 is not the documentation that I provided.

 So, how can I get my docstring back?

This is actually very related to

http://groups.google.com/group/sage-devel/browse_thread/thread/c97d36d23131f4c5/bfa082a5ef5f153a

but unfortunately, there's not a good answer (yet?).

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: How to deal with wrapper_descriptor / slot wrapper

2010-07-27 Thread Robert Bradshaw
On Tue, Jul 27, 2010 at 1:25 PM, Simon King simon.k...@nuigalway.ie wrote:
 On 27 Jul., 21:30, Simon King simon.k...@nuigalway.ie wrote:
 Is there no workaround? Say, defining the method (or slot method
 wrapper envelop whatever) and explicitly assign an attribute __doc__
 to it?

 For the record:
 AttributeError: attribute '__doc__' of 'method-wrapper' objects is not
 writable

Not writeable from Python space ;) I will surely be looking into
trying to resolve this issue.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] complexity of computations in Z/n*Z

2010-07-27 Thread Robert Bradshaw
On Tue, Jul 27, 2010 at 1:58 PM, Luis Finotti luis.fino...@gmail.com wrote:
 Hi,

 I have an algorithm that has pieces that perform computations on Z/
 p^i*Z for different values of i.  I can count the operations for each
 piece, but to have an overall complexity, I need to know how the
 difference pieces compare.

 So, can anyone tell me how many bit operations are performed, in Sage,
 in a product of two elements of Z/n*Z (in terms of n and size of the
 input)?  (I am particularly interested in cases where n=p^i for
 various i's, but it would be nice to know in general for future
 reference.)  What about in Z?  (A general reference would be fine too,
 of course.)

For anything that doesn't fit inside a single word, Sage uses the mpz
functions in MPIR to do arithmetic. There are a variety of algorithms
used--from the classical O(n^2) to various Karatsuba/Toom-Cook ones to
Schönhage–Strassen for large values. The latter, if you're interested
in asymtotics, is O(n log n log log n). IIRC, The reduction (division)
has similar asymptotics.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] An argument for more direct axiom integration

2010-07-13 Thread Robert Bradshaw
On Mon, Jul 5, 2010 at 4:39 AM, Dr. David Kirkby
david.kir...@onetel.net wrote:
 On 07/ 5/10 06:18 AM, William Stein wrote:

 Great idea - you could add an algorithm=axiom option to sage's
 integrate command.

 Personally, and I am going to dare risk argue with a mathematician, I would
 not have considered Axion an algorithm, but a software package. So something
 like method=use_axiom would seem more logical to me.

The only argument for algorithm is that it's a standard idiom in
Sage (though with a greatly generalized meaning).

 Better still if Sage behaved like Mathematica, so seamlessly switched from
 one method to another, if the first one fails.

As far as I know, it usually does. I'm sure that maxima tries more
than one algorithm (or at least has some heuristic to figure out which
way to attack the problem). Switching over to a different system is a
bit different. Also, note that axiom is an optional package.

 In other words, automatically
 switch to Axiom if Maxima can't solve the integral - perhaps with a message
 like  Unable to solve with Maxima, now trying Axiom. I would still leave the
 option of someone just using Axiom though.

 One of the annoying things with Sage, is that you often need to know what
 bit of software to use to do something. With Mathematica, I can request a
 zero of a Bessel function - I don't need to know that I should be doing this
 using mpmath or whatever else can be used for finding zeros of Bessel
 functions (see recent thread on this topic)

This is certainly the goal--we're just not there yet in all areas.
For, e.g. (exact) linear algebra or most of number theory it chooses
and uses the right components under the hood.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Which python for sage?

2010-07-13 Thread Robert Bradshaw
On Sun, Jul 4, 2010 at 9:47 AM, Greg Kuperberg greg.kuperb...@gmail.com wrote:
 On Jul 3, 8:33 am, William Stein wst...@gmail.com wrote:
 Sage can't switch to Python 3 until every single Python package in
 Sage is ported to Python 3.
 This is far from done.  It's possible that for some packages, nobody
 is even working on doing a port. In such cases, our only hope is to
 either do the port ourselves or remove the package from Sage, which
 may both be incredibly difficult.    I've heard Twisted may be an
 example of such a package, but there might be others.   Even numpy
 hasn't been ported to Python 3 yet, though at least there work is
 rumored to be in progress.

 Of course, you understand these issues better than I do.  I didn't
 even
 consider that Sage has so many third-party libraries at the Python
 level.
 So yeah, I can see that it could take a long time to do such a
 conversion.

 Even so, I would suggest a more developed policy than just that you
 can't
 do it right now.  Certainly at first glance, Python 3 looks a really
 good idea.  Maybe at second glance, the conversion cost is very high
 for
 many projects and you could estimate that it will take many years for
 the world to switch.  (But note that the same was true of a really
 great
 editor called NEdit and Unicode, and the result in the long run was
 that
 it hurt NEdit a lot.)

What advantages do you see Sage getting from Python 3?

I think the Sage library is probably in better shape than many of our
dependancies (and the Cython files should just work), but it's hard to
know 'till we get to it.

 In any case the all-or-nothing answer cannot be completely true.
 After all,
 you have interface support for packages written entirely in C or
 whatever
 other language.  So how could it be that if you were in Python 3, then
 Python 2.* would be the one language that you can't support at all?
 What would you do if you wanted to support a Python 3 package?

We'd have to ship Python 3 as a distinct spkg, and probably call it
via pexpect.

- Robert

-- 
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Minus sign not being typeset?

2010-06-26 Thread Robert Bradshaw

This is a known bug. http://trac.sagemath.org/sage_trac/ticket/9314

On Jun 26, 2010, at 10:29 AM, Mike Witt wrote:


More info:

--
| Sage Version 4.3.1, Release Date: 2010-01-20   |
| Type notebook() for the GUI, and license() for information.|
--
sage: n=var('n')
sage: f = -n/(n-1) + 1
sage: f
-n/(n - 1) + 1
sage: latex(f)
-\frac{n}{{\left(n - 1\right)}} + 1
sage: quit

--
| Sage Version 4.3.5, Release Date: 2010-03-28   |
| Type notebook() for the GUI, and license() for information.|
--
sage: n=var('n')
sage: f = -n/(n-1) + 1
sage: f
-n/(n - 1) + 1
sage: latex(f)
\frac{-n}{{\left(n - 1\right)}} + 1

-Mike

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Sage showing its work

2010-06-26 Thread Robert Bradshaw

On Jun 26, 2010, at 7:24 PM, S. Robert James wrote:


I didn't receive a response on this.  If the question isn't clear,
please let me know what needs to be clarified.

I'm sure my request isn't unique: one of the major goals of Sage is to
provide a platform that allows people to _verify_ it, which is par for
the course for any mathematician.  I'd like to see the steps Sage uses
to convert the sum I give it (or what not) to the form it chooses.


For the most part, the answer to that question is if you want to see  
what went on you have to read the source. It is possible that some  
functions (maxima?) has a verbose mode, but that may not be what you  
want.


- Robert


On Jun 25, 2:44 pm, S. Robert James srobertja...@gmail.com wrote:
Hi. Checking out sage, and it's amazing.  I'm a bit overwhelmed by  
its

size, though...  I intend to use it to handle some of the messy
algebraic manipulations while I work on combinatorics.  Can anyone
help with these questions:

1)  When I enter a sum in sage:

   h = sum(h_m, m, 1, 2*n)/2*n # h_m is already defined in terms  
of m

and n

sage gives me an answer in closed algebraic form.  That's great.  But
I'd like to know how it simplified it.  Is there anyway to have Sage
show it's work?  That is, show the steps it took to rewrite my sum
into the closed form .

(As a beginner, I'm not sure if I'm using Sage right - so it's very
important for me to be able to verify what it does.)

2) Now, when I tell sage to display h, it displays it in simplified
form.  Great.  But I'd also like to be able to print out the original
definition - how can I do that?

In general, both of these questions relate to the same concern: Sage
is great; but I don't want to follow it blindly.  I'd like to be able
to query what I put in, what Sage converted it to, and how.


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Is sage 4.3.5 able to solve quadratic equations??

2010-06-23 Thread Robert Bradshaw

On Jun 21, 2010, at 10:53 PM, Matthias Meulien wrote:


I guess that the problem comes from the type of p1, not
being an Expression. So is it possible to cast this p1 to the
Expression class?


A direct conversion like the following works:

sage: p3 = 0
sage: for c in p1.coeffs():
: p3 = x*p3 + c
:
sage: p3
-3/4*pi + 7/4*pi*x
sage: type(p3)
type 'sage.symbolic.expression.Expression'
sage: p3.roots(x)
[(3/7, 1)]


You could evaluate p1 at the symbolic variable x.

sage: basering = PolynomialRing(SR, 'x')
sage: p1 = basering.lagrange_polynomial([(0,0), (1,pi), (2, pi/2)])
sage: expr = p1(var('x'))
sage: type(expr)
type 'sage.symbolic.expression.Expression'
sage: expr.roots(x)
[(7/3, 1), (0, 1)]

- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: notebook control panel

2010-06-23 Thread Robert Bradshaw

On Jun 23, 2010, at 9:04 AM, William Stein wrote:


On Wed, Jun 23, 2010 at 8:43 AM, Harald Schilly
harald.schi...@gmail.com wrote:

On Jun 23, 3:57 pm, kcrisman kcris...@gmail.com wrote:

maybe because frames
didn't work well or we wanted to avoid them...?



I don't know the conversation but no frames please - just a floating
div at a fixed position would be my wish! It would also be really  
easy


We had a floating div at a fix position for *years*.Mike Hansen
finally removed it in early 2008 (if I remember correctly), and it was
a great improvement to *not* have it.


I really liked not having to scroll all the way to the top to restart  
a worksheet...it would be nice to make this toggleable (and of course  
even better to finally have a full user preferences page).


- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Unexact computation with roots of unity.

2010-06-22 Thread Robert Bradshaw

On Jun 22, 2010, at 1:02 PM, Nils Bruin wrote:


On Jun 22, 11:13 am, cjung cjun...@gmx.de wrote:

My question is now, if this is a bug or just a mistake in my code?


I suspect that you create your roots of unity using exponents that  
are floats.


If m and n are integers, m/n shouldn't be a float.


In that case it may be a bug in Sage that it doesn't throw an error.


+1


It may be what you are triggering:

We create an approximate 6th root of unity. Of course the input data
shouldn't be interpreted as an algebraic number because 0.333 can
easily mean a non-rational number. This is where it might be safer if
sage threw an error instead of accepting the input
sage: c=QQbar(e^(I*pi*0.333))
sage: c
0.5009066253607099? + 0.865501330253019?*I

As this example shows, sage has done a best guess as to interpreting
the input as an algebraic number:

sage: c.minpoly()
x^800 - x^600 + x^400 - x^200 + 1

Indeed, its cube is close to -1, but not equal to it:

sage: c^3
-0.950652018582? + 0.003141587485879564?*I

QQbar clearly tries too hard to interpret symbolic expressions as
algebraic numbers. More blatant non-algebraic input gets recognised:

sage: QQbar(1.34)
TypeError: Illegal initializer for algebraic number
sage: QQbar(1.13+3.2*I)
TypeError: Illegal initializer for algebraic number

Since QQbar(...) is a forced coercion, perhaps this is what you should
expect. You are asking the system to try to make sense of what you're
asking if at all possible and in some sense it does ... but rather
unexpectedly.

I don't know how robust the strategies are that the system uses, but
for smallish input it seems to work rather well:

sage: u1=QQbar(1958*e^(pi*I*-2/5)+34/5*e^(pi*I*3/7))
sage: u2=(QQbar(1958*e^(pi*I*-2/5))+QQbar(34/5*e^(pi*I*3/7)))
sage: u3=1958*QQbar.zeta(10)^(-2)+34/5*QQbar.zeta(14)^3
sage: u1 == u2 and u1 == u3 and u2 == u3
True
sage: u1.minpoly() == u2.minpoly()
True
sage: u3.minpoly()(u2) == 0
True

If it uses numerical methods somewhere along the way to recognise
these symbolic expressions as algebraic numbers, I suspect you can
break it by feeding it some devious input.

The problem is probably the minpoly routine on symbolic expressions:

sage: v=e^(I*pi*0.333)
sage: v.minpoly()
x^800 - x^600 + x^400 - x^200 + 1
sage: (e^(I*pi*333/1000)).minpoly()
x^800 - x^600 + x^400 - x^200 + 1
sage: (e^(I*pi*1.0/3)).minpoly()
x^2 - x + 1

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Unexact computation with roots of unity.

2010-06-22 Thread Robert Bradshaw

On Jun 22, 2:13 pm, cjung cjun...@gmx.de wrote:

Dear all,

Here's my problem: I've written a function (the scource code below),
which should compute the scalarproduct of two classfunction of a group
G. But there is a little problem with that, the values of the
classfunction are just given as a list of values (one entry for every
conjugacy-class of G). As normal some of these values are roots of
unity, given in the form e^(2*pi*I m/n); if I try to compute the valus
of that function for irreducible characters of the group, then for
some distinct characters the values are not zero. They are near zero
but not at all zero.

Here the code:
def sage_ScalarProd(self,X,Y):
card=self.card_conjugacyClasses()
# gives us the cardinality of the conjugacy classes of G
n=len(card);
if len(X) != n :
print X is not a Classfunction on G.
return 0
if len(Y) != n:
print Y is not a Classfunction on G.
return 0
s=0
s=QQbar(s)
for i in range(0,n):
s=s+QQbar(card[i]) * QQbar(X[i] *Y[i].conjugate());
s=s/self.order()
#self.order() gives us the order of that group
return s

Now an example
C=S.irreducibleCharacters()
#a list of values of the irreducible characters; and indeed these
characters are irreducible
for i in range(0,len(C)):
print S.sage_ScalarProd(C[1],C[i])
#this gives us:
0.?e-18 + 0.?e-19*I # - should be zero
1
0.?e-18 + 0.?e-19*I # - should be zero
0.?e-18 + 0.?e-19*I # - should be zero
0.?e-18 + 0.?e-19*I # - should be zero
0
0

#we also hav
C
[[1, 1, 1, 1, 1, 1, 1], [1, e^(4/3*I*pi), e^(2/3*I*pi), 1,
e^(2/3*I*pi),
e^(4/3*I*pi), 1], [1, e^(2/3*I*pi), e^(4/3*I*pi), 1, e^(4/3*I*pi),
e^(2/3*I*pi), 1], [2, 1, 1, -2, -1, -1, 0], [2, e^(2/3*I*pi),
e^(4/3*I*pi), -2, -e^(4/3*I*pi), -e^(2/3*I*pi), 0], [2, e^(4/3*I*pi),
e^(2/3*I*pi), -2, -e^(2/3*I*pi), -e^(4/3*I*pi), 0], [3, 0, 0, 3, 0, 0,
-1]]

My question is now, if this is a bug or just a mistake in my code?


Note that 0.?e-18 does *not* mean that the result is not zero, it just  
means that it's something numerically close to zero. In generally  
QQbar avoids doing algebraic resolution until it needs to. (This is a  
feature, not a bug.)


sage: a = QQbar(sqrt(2)) * QQbar(sqrt(3)) - QQbar(sqrt(6)); a
 0.?e-18
sage: a == 0
 True

sage: a = QQbar(sqrt(-2)) * QQbar(sqrt(3)) - QQbar(sqrt(-6)); a
 0.?e-18*I
sage: a.exactify(); a
 0

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Sage/Python Startup Failing on Snow Leopard

2010-06-21 Thread Robert Bradshaw

On Jun 18, 2010, at 1:58 PM, arthur wrote:


On Jun 18, 3:25 pm, kcrisman kcris...@gmail.com wrote:

But sounds like, as with a big buffet, too much of a good thing is
just too much.


It's worth pointing out, though, that most of the optional packages
are databases, packages for some very specific research use,
additional graphics, or computer internals, in which case perhaps the
user could download his/her own copy of Sage to use them?  What sort
of context are you envisioning this for?

- kcrisman


Well, I'm a SysAdmin, not a mathematician, hence my knowledge of what
our various mathematicians might need is limited.

I'm working on standardized disk images that will be distributed on a
few dozen Macs.  I'm trying to install the broadest, most useable
version of SAGE possible, so it will be most useful for the broadest
swathe of mathematicians who use those disk images.  For individuals
I'd be happy to install specific packages if they're not already
installed, but I'd much prefer to have the needed packages already
available on their installation so they don't have to figure out what
they need, tell me, wait for me to have the time to install it, etc.
Most of our users don't have root on their desktop machines: not being
able to change system level software and configs allows me to push out
new software, updates, etc. without breaking what they're used to, but
it also means I have to give them what they need, hopefully
anticipating it before they need it.


Sounds great.


Also, we have a fair number of shared public machines, so for those I
can't really install individual packages since I never know which
individuals will be using which public systems, they all have a common
disk image.


One thing to note is that Sage ships with batteries included and has  
a most functionality in just the standard install. I'm not trying to  
discourage you from installing optional package, but just note that  
they're not necessary to have a very versatile, useful install.  
Personally, the only optional packages I've ever used are the elliptic  
curve databases, and I've been using Sage for years.



Part of why I posted was not only to get my own installation in good
shape, but to help out others in the same boat by helping to improve
the documentation, error messages, and installation procedures for  
non-

specialists (like me).

I suspect William would say I should help improve the documentation by
not only posting reports (and should any of this sort of thing be a
formal bug report?) but by fixing the source/docs... and I'd agree
with him except 1) I don't know the answers to these questions (i.e.
which databases go with which research purposes, etc) and 2) I'd have
to properly (re)learn mercurial... though the latter I really ought to
do anyway, if I only had the time.


Or, as an even lower barrier, add it to the wiki.

- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Notebook Login and registration of users : Legacy DB or LDAP

2010-06-21 Thread Robert Bradshaw

On Jun 20, 2010, at 7:21 AM, Thierry Dumont wrote:


Le 20/06/2010 16:14, Patrick ABOU BAKAR a écrit :

I know that SAGE contains its own installation of pretty much of all
the modules it depends on..

My assumption is that there is a table that holds the username and
password of the users as they sign up..

What SGBD is used for it? (SQLite, PostreSQL, MySQL)

I search but couldn't find any collaborative work on how to use a
legacy database of users (username, password) to authenticate users
when working on Notebook... Or maybe the usage of LDAP or anything of
the sort..

Any directions or answers would be appreciated.

Thanks for your help!



Hello,

I have a patch for the notebook which allow to use LDAP (Open Ldap,  
Active Directory,...). We use it in our University server ( http://sage-math.univ-lyon1.fr 
 ). If you are intersted, I can help you installing it.

Yours


Sounds like something we've wanted for a long time, is your patch up  
on trac as well?


- Robert


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Why is map using memory?

2010-06-21 Thread Robert Bradshaw

On Jun 20, 2010, at 7:50 AM, Rolandb wrote:


Hi,

I found a more simplified example:

print get_memory_usage()
for i in xrange(1): A(1,8,9)
print get_memory_usage()

Why is type(A)
'sage
.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingu 
\lar' using memory?


No idea, maybe a memory leak in __call__ (or perhaps in libsingular  
itself)?


http://trac.sagemath.org/sage_trac/ticket/9298

- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] strange behavior in matrix substitution

2010-06-13 Thread Robert Bradshaw

On Jun 12, 2010, at 17:27 , Byungchul Cha wrote:


Please tell me if this is a bug, or, I'm missing something obvious...

sage: a = 3 # Assign a value to a variable a
sage: b = a # Create a copy of a


You're not really copying a, you're just making 'b' refer to the same  
thing that 'a' does, i.e. '3'.



sage: b = 2 # Change the value of b


Now b points to a different integer (2).


sage: b
2
sage: a # The value of a remains unchanged, as expected.
3

So far, it looks good to me. But, when I do a similar thing with
matrices, it doesn't look to be the same.

sage: v = matrix(ZZ, 3, range(9))
sage: u = v


u and v point to the same thing.


sage: u[2] = [0,0,0]


The matrix stored in the variable u has not been reassigned, it' been  
mutated.



sage: u
[0 1 2]
[3 4 5]
[0 0 0]
sage: v
[0 1 2]
[3 4 5]
[0 0 0]

Shouldn't the value of v remain the same? Why does the change in u
(or, a row of u) affect v?




On Jun 12, 2010, at 8:25 PM, Justin C. Walker wrote:



On Jun 12, 2010, at 19:07 , William Stein wrote:


On Saturday, June 12, 2010, Justin C. Walker jus...@mac.com wrote:


On Jun 12, 2010, at 17:27 , Byungchul Cha wrote:

[snip]

Shouldn't the value of v remain the same? Why does the change in u
(or, a row of u) affect v?

[snip]
For, e.g., integers, u=v means that the names u,v both refer to  
their own copies of the value in question.




Are you sure???  I think you statement that u is a new copy is  
wrong.   I bet


u is v

would still return true above.


Picky picky picky.  I was hoping to avoid a trip into the twisty  
maze of passages in language definition (all of which are subtly  
different :-}).  But you are correct.  u is v does return true and  
the two actually refer to the same (physical) value.  And, if one  
variable is modified, this doesn't modify the other, or the value  
that both previously referred to.


Actually, even in the case of integers, if you were to modify one, it  
would modify the other. Most object are (basically) immutable, so this  
doesn't come up. Assignment never copies, it only creates references.


- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] How to do it in cython?

2010-06-12 Thread Robert Bradshaw


On Jun 11, 2010, at 11:23 PM, Rolandb wrote:


Hi,
I have a small (nonsense) example of a program I would like to be able
to convert to cython. But I don't know how to convert:
R.A,B,C=QQ[], .factor(), .unit() and
.factor(proof=False,limit=10^5). I could not find anything in the
documentation about for instance handling elements of R.A,B,C=QQ[],
thus
sage
.rings
.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular.


R.A,B,C=QQ[]
def test(trio,expr=(A,B,C)):
   (a,b,c)=sorted(map(lambda x: abs(x(trio)),expr))
   basis=prod(expr).factor()
   te_ontbinden=[abs(w[0](trio)) for w in basis]+[QQ(basis.unit())]
   radl=abs(prod(uniq([p for g in te_ontbinden for p,_ in
ZZ(g).factor(proof=False,limit=10^5)])))
   return radl

test((1,8,9),(A^2,C^2-A^2,C^2))
30

Any help is appreciated! Roland


Sage is preparsed. To see what comes out, do

sage: preparse(3.factor())
'Integer(3).factor()'

sage: print preparse(
R.A,B,C=QQ[]
def test(trio,expr=(A,B,C)):
   (a,b,c)=sorted(map(lambda x: abs(x(trio)),expr))
   basis=prod(expr).factor()
   te_ontbinden=[abs(w[0](trio)) for w in basis]+[QQ(basis.unit())]
   radl=abs(prod(uniq([p for g in te_ontbinden for p,_ in
ZZ(g).factor(proof=False,limit=10^5)])))
   return radl
)

R = QQ['A, B, C']; (A, B, C,) = R._first_ngens(3)
def test(trio,expr=(A,B,C)):
  (a,b,c)=sorted(map(lambda x: abs(x(trio)),expr))
  basis=prod(expr).factor()
  te_ontbinden=[abs(w[Integer(0)](trio)) for w in basis]+ 
[QQ(basis.unit())]

  radl=abs(prod(uniq([p for g in te_ontbinden for p,_ in
ZZ(g).factor(proof=False,limit=Integer(10)**Integer(5))])))
  return radl


- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Data list

2010-06-11 Thread Robert Bradshaw

On Jun 10, 2010, at 12:22 PM, Christian Stump wrote:


m=[0.6158, 0.5893, 0.5682, 0.51510, 0.4980, 0.4750, 0.5791,
0.5570,0.5461, 0.4970, 0.4920, 0.4358, 0.422, 0.420]
m.count


len(m) does the job, you should probably look into the tutorial at
http://www.sagemath.org/doc/tutorial/ for this kind of questions...

m.count is a function returning the number of times some element
appears in the list, so [1,2,3,2,2,4].count(2) returns 3


Another similar thing, i want to multiply the all the elements for
10^-6


if you want to apply a function to every element in a list, you can do
that by [ f(i) for i in your_list ].

e.g., [ 2*i for i in [1,2,3] ] returns 2,4,6


Or, you might want an actual vector.

sage: m = vector([0.6158, 0.5893, 0.5682, 0.51510, 0.4980, 0.4750,  
0.5791, 0.5570,0.5461, 0.4970, 0.4920, 0.4358, 0.422, 0.420])

sage: len(m)
14
sage: m * 10^-6
(6.158000e-7, 5.893000e-7, 5.682000e-7,  
5.151000e-7, 4.98e-7, 4.75e-7,  
5.791000e-7, 5.57e-7, 5.461000e-7,  
4.97e-7, 4.92e-7, 4.358000e-7,  
4.22e-7, 4.20e-7)


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Building from source sage 4.4.3 under Debian lenny amd64: gcc and g++ versions do not match

2010-06-11 Thread Robert Bradshaw

On Jun 11, 2010, at 2:51 PM, orca wrote:


Hi there,

I am a newbie to Sage, though I have some experience with Linux and
Python in general.

I have tried to build the latest 4.4.3 version of Sage from source,
but, after having checked that I apparently have all necessary program
dependencies satisfied, and issuing the command make under my Sage
root directory, the following error was reported:

configure: gcc (4.3.2) and g++ (4.2.4) are not the same version
configure: which they must be. Check your setting of CC and CXX
configure: error: Exiting since the C and C++ compilers have different
versions
ERROR: You do not have all of the prerequisites needed
to build Sage from source.  See the errors above.
make[1]: *** [installed/prereq-0.7] Error 1

So what do you recommend? As far as I could check, there are deb files
for both the lower version of gcc and the higher version of g++, under
Debian lenny repositories and, indeed, my machine has both 4.3.2 and
4.2.4 gcc versions installed (SIC). The point is, if I install these
other versions, how do I force the use of a given version of gcc (or  
g+

+, for that matter) when building Sage?? If that is possible, is it
advisable?


I would imagine that either would work fine--chances are if you  
install, for example, the 4.3.2 g++ package then it will get picked up  
by default over what was there previously.



Thanks in advance!!!

PS: when is it due to appear Debian lenny i386 and amd64 official
binary versions of Sage, such as there are for Ubuntu and Suse in
Sage's site??


When someone is willing to consistently build and upload them.

- Robert


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Building from source sage 4.4.3 under Debian lenny amd64: gcc and g++ versions do not match

2010-06-11 Thread Robert Bradshaw

On Jun 11, 2010, at 4:48 PM, Dr. David Kirkby wrote:


On 06/11/10 10:51 PM, orca wrote:

Hi there,

I am a newbie to Sage, though I have some experience with Linux and
Python in general.

I have tried to build the latest 4.4.3 version of Sage from source,
but, after having checked that I apparently have all necessary  
program

dependencies satisfied, and issuing the command make under my Sage
root directory, the following error was reported:

configure: gcc (4.3.2) and g++ (4.2.4) are not the same version
configure: which they must be. Check your setting of CC and CXX
configure: error: Exiting since the C and C++ compilers have  
different

versions
 ERROR: You do not have all of the prerequisites needed
 to build Sage from source.  See the errors above.
make[1]: *** [installed/prereq-0.7] Error 1

So what do you recommend? As far as I could check, there are deb  
files
for both the lower version of gcc and the higher version of g++,  
under

Debian lenny repositories and, indeed, my machine has both 4.3.2 and
4.2.4 gcc versions installed (SIC). The point is, if I install these
other versions, how do I force the use of a given version of gcc  
(or g+

+, for that matter) when building Sage?? If that is possible, is it
advisable?

Thanks in advance!!!



What do the following commands give you?

$ command -v gcc
$ command -v g++
$ command -v gfortran
$ gcc -v
$ g++ -v
$ gfortran -v
$ echo $PATH

give you?

You would certainly be advised to use the same version of gcc, g++  
and gfortran.


I don't know what command may or may not exist in any given linux  
distribution, but one can often get the commands one wants by  
suitably setting the path.


It's not possible to build g++ without building gcc, the g++ 4.2.4  
must have had a gcc 4.2.4 version at some point. Whether you only  
have g++ installed is another matter, but it must have been built  
with C support.


I'd personally be inclined to suggest you


To be clear, you're suggesting building your own gcc and g++ from  
source, and then trying to configure it to use that one instead of the  
system default, right? To me, that sounds more complicated and error  
prone than just trying to use the package manager to get the latest  
binaries (but, of course, it's nice that you can do so).



* Download the latest gmp
* Download the latest mpfr
* Download gcc 4.4.4 (not 4.5, as that is less well tested).
* Patch mpfr to get the latest updates (just read the readme)
* copy the mpfr directory under the gcc sources and rename it to  
mpfr
* copy the gmp sources under the gcc source directory and rename it  
gmp

so you get a diretory layout like this

gcc-4.4.4
gcc-4.4.4/gmp
gcc-4.4.4/mpfr


$ mkdir build
$ cd build
$ /path/to/gcc-4.4.4/configure --prefix=/somewhere/I/can/write/to -- 
enable-languages=c,c++,fortran


then go away and wait until you have a new gcc 4.4.4

(You should however read the gcc docs to see if there are some  
specific switches recommended for your distro.


Do *not* make build under the gcc-4.4.4 source tree - it should be  
outside the source tree.


Using a later gcc is probably your safest solution. If nothing else,  
Sage tends to be more tested with late compiler releases, except on  
OS X, where many people use the Apple-supplied gcc 4.0.1


Dave

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Problem finding numeric eigenvectors

2010-06-07 Thread Robert Bradshaw

On Jun 7, 2010, at 7:46 AM, Mike Witt wrote:


On 06/06/2010 10:43:38 PM, Rob Beezer wrote:

On Jun 6, 9:05 am, Mike Witt msg...@gmail.com wrote:
 This does kind of reinforce the concept, which I guess I've
 heard expressed before here, that you have to be prepared
 to update your sage build very frequently in order to keep
 up with things.
Exactly.  ;-)  But with
sage -upgrade
at a system prompt, it couldn't be much easier.
Rob


Well, getting a new version is no problem (assuming it builds on one's
system). But since there is no distinction between bug fix releases
and releases in which the interface to some function might change  
(such as

the change we were just discussing) you never know when downloading a
new version is going to cause you some work figuring out how to update
existing code.


We have a deprecation policy, so at the very least your old code  
should work for a while (with warnings) before breaking completely. Of  
course that's the theory, some people are better at following it than  
others.


Again, I may be an atypical user. I like to have a stable system. I  
only

install every *other* fedora release :-)

I have the distinct impression that most of the people here are active
developers, who spend time every day reading the mailing lists,  
looking
at the code, and keeping track of the status of bugs, etc. I'm  
actually
the guy who is trying to use Sage as a viable free open source  
alternative

to Magma, Maple, Mathematica and Matlab :-)

But, note that I'm not asking for my money back ...


In your case, what I'd do is read the release notes when it comes out,  
and decide to upgrade based on that. You don't have to upgrade unless  
it fixes bugs or adds features you need.


sage -upgrade has always worked for me (and I've been using Sage since  
1.x) but downloading a whole new tarball is also safer in the sense  
that you can try it out, and if that doesn't work just nuke it and  
wait for the next release. It is nice to be able to have any number of  
installations in parallel (assuming the necessary disk space).


- Robert


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Cython and static data

2010-06-07 Thread Robert Bradshaw

On Jun 7, 2010, at 8:04 AM, Rolandb wrote:


Hi,

Using cython, I want to make optimal use of static data. The reason is
that lookup is (often) much faster than recalulating. I now use:

cdef list nice_list_name=[3 , 3 , 3 , 3 , 3 , 3 , 4 , 4 , 4 , 4 , 4 ,
4 , 4 , 4 , 4 , 5 , 5 , 5 , et cetera]

But this didn't increase the speed. Suggestions are appriciated!


Perhaps in your case lookup isn't faster than recalculating? If it's  
about a tie, re-calculating is probably better, as it's less of a  
black box. Here you're using a Python list of ints, if you really  
want speed you'd want to use a int*. You could globally calculate this  
the first time it's used and use a lookup from then on.


- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Using LiE

2010-06-03 Thread Robert Bradshaw

On Jun 3, 2010, at 9:46 AM, William Stein wrote:

On Thu, Jun 3, 2010 at 9:44 AM, Bruce brucewestb...@googlemail.com  
wrote:

I am just starting with sage. I type a url into firefox to start the
notebook on a local machine.

I typed:  install_package('lie-2.2.2.p3')
and got along error message.

[Errno 13] Permission denied: '/usr/local/sage/sage-4.4.2/tmp/list'

I assume this is a local problem.


You are not allowed to install packages system-wide.  If you can be
admin on that computer, do

 sudo su

and try again.  If not, contact the admin.


Alternatively, you could install and use your own personal copy of  
Sage in your home directory.


- Robert


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] zeros of the Riemann zeta function

2010-06-01 Thread Robert Bradshaw

On Jun 1, 2010, at 8:13 AM, Anne Driver wrote:


Hello,

I am new to this list, and relatively new to Sage. I'm puzzled by  
the logic of one part of Sage though.


Although I don't have access to Mathematica at the minute on this  
computer, I know if I compute the first zero, I get something like


In[1] = ZetaZero[1] //N (to get a numerical value)
Out[1] = 1/2 + I*14.134...

Trying this in Sage, I get:

sage: lcalc.zeros(1)
[14.1347251]


Why does Sage not do the sensible thing like Mathematica and return  
the complex number 0.5 + I 14.1347251 ? It would seem much more  
logical.


Of course, it is not proven that the real part is 1/2, so how would  
the case be handled if a root was not found to have a real part of  
1/2 ?


I believe both algorithms assume the Riemann hypothesis in computing  
them (otherwise, for example, it would be ambiguous to talk about the  
n-th zero anyways). I would guess the reason that lcalc returns the  
imaginary part only is that otherwise the first thing one would do to  
actually do anything interesting with this data would be to take the  
imaginary part, so this just saves the effort and overhead.


- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] zeros of the Riemann zeta function

2010-06-01 Thread Robert Bradshaw

On Jun 1, 2010, at 11:05 AM, William Stein wrote:


On Tue, Jun 1, 2010 at 10:58 AM, Robert Bradshaw
rober...@math.washington.edu wrote:

On Jun 1, 2010, at 8:13 AM, Anne Driver wrote:


Hello,

I am new to this list, and relatively new to Sage. I'm puzzled by  
the

logic of one part of Sage though.

Although I don't have access to Mathematica at the minute on this
computer, I know if I compute the first zero, I get something like

In[1] = ZetaZero[1] //N (to get a numerical value)
Out[1] = 1/2 + I*14.134...

Trying this in Sage, I get:

sage: lcalc.zeros(1)
[14.1347251]


Why does Sage not do the sensible thing like Mathematica and  
return the

complex number 0.5 + I 14.1347251 ? It would seem much more logical.

Of course, it is not proven that the real part is 1/2, so how  
would the

case be handled if a root was not found to have a real part of 1/2 ?


I believe both algorithms assume the Riemann hypothesis in  
computing them
(otherwise, for example, it would be ambiguous to talk about the n- 
th zero

anyways).


Often such computations actually prove the Riemann hypothesis up to a
given height
(see, e.g., 
http://numbers.computation.free.fr/Constants/Miscellaneous/zetazeros1e13-1e24.pdf

I've cc'd Mike Rubinstein, so he can respond if he wants, since I'm
not sure lcalc is actually doing
this or not.



IIRC, the broad idea is to compute sign changes and then perform a  
contour integral to prove that you have located all the zeros. If no,  
refine the grid and try again. Of course this is a huge  
oversimplification, but if there are zeros not on the critical line  
than this would simply fail to terminate, and otherwise it would prove  
the hypothesis.


- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: MemoryError

2010-05-29 Thread Robert Bradshaw

On May 28, 2010, at 9:53 PM, Rolandb wrote:


Tnx Robert,

I rewrote the routine somewhat to use less stored values. Still I got
the following message:

error: no more memory
System -1596988k:2096917k Appl -1763860k/20285k Malloc 277k/0k Valloc
-1743852k/20285k Pages 612613/0 Regions 5045:5045

What does this tell me?


Usually this means exactly what it says, you've used up all the memory  
on your machine and can't allocate any more. What kind of machine are  
you running this on? If this is a Virtual Machine, you may be able to  
increase the amount of memory you give it, but otherwise you may need  
to rewrite your code, put more RAM in your machine, or run it on a  
bigger machine. Without more details it's hard to give advice on how  
you could rewrite your code, but 13 million real numbers should be  
easy to handle, 13 million large matrices not so much.



Roland


On 27 mei, 20:41, Robert Bradshaw rober...@math.washington.edu
wrote:

On May 27, 2010, at 11:31 AM, Rolandb wrote:


Hi,



I'm running a routine which uses a large data set (13 million
elements). After a while the output is:



MemoryError
no mem for new parser



What to do? Thanks in advance for the swift reply!
Roland


What are you doing with this data? Do you have a sample session? How
much memory do you have? How much is it using? It might actually be
out of memory.

- Robert


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] How can I get a PDF from a .show() acting on an expression, from within the notebook ?

2010-05-28 Thread Robert Bradshaw

On May 28, 2010, at 6:13 AM, Nicolas wrote:


Hi all,

I am trying to get, from within the notebook, a PDF from the show
method acting on an expression, just like sage does when used on the
command line. It works very nicely for graphics objects but I have not
figured out either how to get a graphics object from a nicely typeset
expression of just get the pdf that is produced by the command line.

Has this been thought of ? Is this possible ?


Oh, I didn't see that you were talking about an expression. Try

sage: view(expr, viewer='pdf')

- Robert


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Integer.sqrt() memory leak?

2010-05-27 Thread Robert Bradshaw

On May 27, 2010, at 9:07 AM, rickhg12hs wrote:


I noticed that doing sqrt() for large integers seems to continually
chew up memory.

For example:

sage: m = get_memory_usage()
sage: while True:
   a = ZZ(randint(2^400,2^800)).sqrt()
   print get_memory_usage(m)

This prints ever increasing memory usage values, but I'm not sure that
it should.


Looks like a memory leak to me.

- Robert


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] MemoryError

2010-05-27 Thread Robert Bradshaw

On May 27, 2010, at 11:31 AM, Rolandb wrote:


Hi,

I'm running a routine which uses a large data set (13 million
elements). After a while the output is:

MemoryError
no mem for new parser

What to do? Thanks in advance for the swift reply!
Roland


What are you doing with this data? Do you have a sample session? How  
much memory do you have? How much is it using? It might actually be  
out of memory.


- Robert


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Illegal Instruction errors when trying to run sage

2010-05-27 Thread Robert Bradshaw

On May 27, 2010, at 3:22 PM, Alex Goater wrote:


Hello,

I'm trying to use sage version 4.4.2 within Linux Mint 7 Gloria.  
I've downloaded the sage-4.4.2-linux-32bit-ubuntu_10.04_lts-i686- 
Linux.tar.gz from the webiste, unpacked it and tried to run sage and  
this came up:

--
| Sage Version 4.4.2, Release Date: 2010-05-19   |
| Type notebook() for the GUI, and license() for information.|
--

**
WARNING!  This Sage install was built on a machine that supports
instructions that are not available on this computer.  Sage will
likely fail with ILLEGAL INSTRUCTION errors! The following processor
flags were on the build machine but are not on this computer:

pni

Email http://groups.google.com/group/sage-support for help.
To remove this warning and make Sage start, just delete
 /home/alex/Desktop/sage/local/lib/sage-flags.txt
**
I thought perhaps I installed it wrong so I ran make within the sage  
directory and when I tried to run sage again the same message came  
up. Can I just ignore this warning or do I need to download a  
package perhaps for linux mint to be able to run sage?


This binary was probably built on a newer machine than you have. You  
could try to ignore this warning, but the safest thing to do is try a  
different binary or build from source.


- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Which python for sage?

2010-05-26 Thread Robert Bradshaw

On May 26, 2010, at 3:06 PM, William Stein wrote:


On Wednesday, May 26, 2010, Micha Hofri ho...@wpi.edu wrote:


Dear Mr. Stein:

I heard about Sage when looking for an alternative to Maple.  I  
find it is a good idea to know Python.  I take a text, and it tells  
me it is mostly about python 3, which is incompatible with python  
2.6.


Can I use sage with/within python 3?


No.  Sage uses python 2.6, and will for at least the next year.


On the other hand, Python 3 is over 95% the same as Python 2.6, so  
learning Python from a text based on Python 3 is not that big of a  
deal. Another good resource is http://diveintopython.org/


- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Display of i vs I

2010-05-22 Thread Robert Bradshaw

On May 22, 2010, at 8:05 AM, Mike Witt wrote:


I just thought I'd try this question one more time:

On May 20, 10:59 am, Mike Witt wrote:

Is there any way to make the square root of -1 display lower case
i rather than I (at least for latex output)?


Sage complex numbers already print out that way.

sage: latex(CDF(1,1))
1.0 + 1.0i
sage: latex(CC(1,1))
1.00 + 1.00i
sage: latex(sqrt(-1))
I

The symbolic I doesn't, however, though I think that would be an easy  
and worthwhile change. For now you could do something like


sage: latex(1 + sqrt(-1)).replace('I', 'i')
'i + 1'

(though of course this will replace any capital I).

- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Display of i vs I

2010-05-22 Thread Robert Bradshaw

On May 22, 2010, at 8:28 AM, Robert Bradshaw wrote:


On May 22, 2010, at 8:05 AM, Mike Witt wrote:


I just thought I'd try this question one more time:

On May 20, 10:59 am, Mike Witt wrote:

Is there any way to make the square root of -1 display lower case
i rather than I (at least for latex output)?


Sage complex numbers already print out that way.

sage: latex(CDF(1,1))
1.0 + 1.0i
sage: latex(CC(1,1))
1.00 + 1.00i
sage: latex(sqrt(-1))
I

The symbolic I doesn't, however, though I think that would be an  
easy and worthwhile change. For now you could do something like


sage: latex(1 + sqrt(-1)).replace('I', 'i')
'i + 1'

(though of course this will replace any capital I).


http://trac.sagemath.org/sage_trac/ticket/9017

- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: SAGE being extremely slow with multivariable poly rings - is this normal?

2010-05-22 Thread Robert Bradshaw

On May 21, 2010, at 11:35 PM, Simon King wrote:


On 22 Mai, 00:12, Robert Bradshaw rober...@math.washington.edu
wrote:

Try working a multivariate ring rather than a tower of univariate
rings, e.g. ...


... which suggests the question why Sage does not automatically
transform a tower of polynomial rings into a single ring -- for
efficiency, and in order to avoid weird constructions such as
 sage: QQ['t']['t']['t']
 Univariate Polynomial Ring in t over Univariate Polynomial Ring in t
over Univariate Polynomial Ring in t over Rational Field


There is a difference, for example list(f) and degree(f) have  
different meanings if f is a Univariate ring with a polynomial  
basering. Also, I can safely do


sage: P.x = R['x']

Of course we could possibility do this transformation under the hood,  
and then remember where things came from.


- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Display of i vs I

2010-05-22 Thread Robert Bradshaw

On May 22, 2010, at 8:49 AM, Burcin Erocal wrote:


Hi Mike,


On May 20, 10:59 am, Mike Witt wrote:

Is there any way to make the square root of -1 display lower case
i rather than I (at least for latex output)?


Not in a user friendly way. The complex I is just a number field
element and number fields don't support latex output with different
names. This problem is tracked here:

http://trac.sagemath.org/sage_trac/ticket/6405


That's the ticket I was looking for...

- Robert


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] SAGE being extremely slow with multivariable poly rings - is this normal?

2010-05-21 Thread Robert Bradshaw

On May 21, 2010, at 2:53 PM, Alex P wrote:


Hi all,
I tried the following code in SAGE and it seems that it is taking way
too long

--
| Sage Version 4.3.4, Release Date: 2010-03-19   |
| Type notebook() for the GUI, and license() for information.|
--
sage: q = 5
sage: F = FiniteField(q)
sage: P.T = PolynomialRing(F)
sage: PP.z = PolynomialRing(P)
sage: UU.X = PolynomialRing(PP)
sage: pro = X - 1/z
sage: for p in P.monics(of_degree = 1):
  ...: time pro = pro*(X - p^q/(z + z^q))
  ...:
CPU times: user 0.05 s, sys: 0.00 s, total: 0.05 s
Wall time: 0.15 s
CPU times: user 0.39 s, sys: 0.00 s, total: 0.39 s
Wall time: 0.39 s
CPU times: user 2.56 s, sys: 0.00 s, total: 2.56 s
Wall time: 2.57 s
CPU times: user 16.53 s, sys: 0.02 s, total: 16.55 s
Wall time: 16.58 s
CPU times: user 139.67 s, sys: 0.32 s, total: 139.99 s
Wall time: 141.16 s


Even worse if I try to continue the calculations in degree 2 it is
already taking over 10 min (and counting). Is this normal? And if so
is there a way to avoid this?


Try working a multivariate ring rather than a tower of univariate  
rings, e.g.


sage: q = 5
sage: F = GF(q)
sage: P.T,z,X = F[]
sage: pro = X - 1/z

sage: def monics(n):
:powers = [T^i for i in range(n)]
:for v in F^n:
:yield T^n + sum(c*Tk for c,Tk in zip(v, powers))
:


sage: for p in monics(1):
: time pro = pro*(X-p^q / (z+z^q))
:
CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
Wall time: 0.04 s
CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
Wall time: 0.00 s
CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
Wall time: 0.00 s
CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
Wall time: 0.00 s
CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
Wall time: 0.00 s

sage: pro = X - 1/z
sage: for p in monics(2):
: time pro = pro*(X-p^q / (z+z^q))
:
CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
Wall time: 0.00 s
[...]
CPU times: user 0.01 s, sys: 0.00 s, total: 0.01 s
Wall time: 0.01 s

sage: time for p in monics(2): pro = pro*(X-p^q / (z+z^q))
CPU times: user 0.05 s, sys: 0.00 s, total: 0.05 s
Wall time: 0.05 s

- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Vertical and Horizontal join of matrices

2010-05-20 Thread Robert Bradshaw

On May 20, 2010, at 3:15 PM, VictorMiller wrote:


Does the Matrix class have methods for vertical and horizontal joins
of matrices (as in Magma)?  That is

if A is an m by n matrix and B is an r by n matrix then
VerticalJoin(A,B) would by the (m+r) by n matrix with A on top and B
on the bottom.  Similarly, if A is m by n and B is m by r then
HorizontalJoin(A,B) would be an m by (n+r) matrix with A on the left
and B on the right.  I though that Numeric Python used to have
something like this with a method called concatenate, but I can't find
that in numpy.


You're probably looking for stack and augment.

sage: M = random_matrix(ZZ, 3, 3)
sage: M.stack(M)
[ -1   1  -5]
[ 72  -2   1]
[ -2   2 -20]
[ -1   1  -5]
[ 72  -2   1]
[ -2   2 -20]
sage: M.augment(M)
[ -1   1  -5  -1   1  -5]
[ 72  -2   1  72  -2   1]
[ -2   2 -20  -2   2 -20]

- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: parametric_plot with Piecewise doesn't work ?

2010-05-15 Thread Robert Bradshaw

On May 15, 2010, at 5:31 PM, kcrisman wrote:


Thanks for your email.  Unfortunately, Piecewise functions were
implemented very early in the history of Sage, and so do not support
tons of newer Sage functionality.  Although there are a number of us
interested in improving  this situation, thus far time and expertise
has not been there.  Unless a Sage Days devoted to this magically
happens :) I don't see that changing in the near future, as ideally
such Piecewise functions would come from Pynac/Ginac, but I don't
think they support this (and see http://wiki.sagemath.org/symbolics/pynac_todo
for a long-term wishlist, much of which will definitely eventually be
implemented).

I'm sorry that this is the current situation.  To do this particular
examples, you could probably do four separate parametric plots, I
think?  Please let us know if that doesn't work!


Another option is to wrap these in Python functions:

sage: parametric_plot([lambda a: f(a), lambda a: g(a)], (0, 2))
...


On May 14, 5:51 am, bourbabis bourba...@gmail.com wrote:

Hello folks !

Look at this :


var('a')
f = Piecewise([[(0, 1), a], [(1, 2), 2*a]])
g = Piecewise([[(0, 1), 3*a], [(1, 2), 4*a]])
parametric_plot((f, g), (0, 2))


I get the following error message :

 Traceback (click to the left of this block for traceback)
. ..
 AttributeError: PiecewisePolynomial instance has no attribute
 '__float__'

parametric_plot isn't implemented yet for sliced function ?

Thanks.

--
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
For more options, visit this group athttp://groups.google.com/group/sage-support
URL:http://www.sagemath.org


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Can't use os.chdir with Sage in virtualbox

2010-05-14 Thread Robert Bradshaw

On May 14, 2010, at 9:32 AM, David Grudoski wrote:

Can anyone tell me how to use os.chdir to go to my C: drive when  
running sage in virtual box? I can't get out of the '/home/'  
directory.

executing the following in sage notebook
import os
os.chdir('C:')
gives an error No such file or Directory

I set C up a a permanent shared folder from the devices menu but  
have no idea how to access it from within the virtual boxenvironment.


VirtualBox has its own filesystem completely separate from Windows.  
Given you set up a permanent shared folder, there's probably a mount  
point. Does


sage: os.system(ls /)

give anything that looks like it could be your C drive? Someone who  
actually uses VirtualBox could probably answer better.


- Robert


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Test if a variable is numerical

2010-05-07 Thread Robert Bradshaw

Try doing

x in RR

- Robert

On May 7, 2010, at 2:38 PM, Nathann Cohen wrote:


Hello everybody !!!

I am trying to find out how to check whether some Sage variable is
numerical (let's say real,  as opposed to None, False, {}, Set([]),
etc..), but was not lucky on Google... ^^;

Do you know the function I am looking for ? :-)

Thank youu !!!

Nathann

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] RDF Sparse matrix.

2010-04-30 Thread Robert Bradshaw

On Apr 30, 2010, at 9:34 AM, Thierry Dumont wrote:



I have questions about RDF (and CDF) sparse matrices. How are they  
implemented?


-for dense matrices, sage uses Scipy matrices and this is transparent.

-but, how are sparse matrices (RDF,CDF) implemented?
  1) Are they  Scipy matrices ?
  2) if yes: there are different data structures for sparse  
matrices  in scipy:

a) an intermediate version which uses a list representation,
not good for number crunching,
b) csc and csr format, which are extremely common in numerical  
linear algebra (SuperLU uses them, and iterative methods too).


  How hare matrix(RDF,...sparse=True) stored?


sage: m = matrix(RDF, 5, sparse=True)
sage: type(m)
type 'sage.matrix.matrix_generic_sparse.Matrix_generic_sparse'

So it's our completely generic sparse implementation, stored as a  
dictionary of non-zero entries.


http://hg.sagemath.org/sage-main/file/e2ccb846f296/sage/matrix/matrix_generic_sparse.pyx#l1

If it is possible for sage to build automatically csc or csr  
matrices, then using sparse solvers is trivial. Otherwise I think it  
is necessary to build Scipy matrices (lil matrices converted to csr  
or csc format).


We don't have support for that, but it would probably be a nice thing  
to have.


- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] power function with runtime error

2010-04-25 Thread Robert Bradshaw

On Apr 23, 2010, at 1:37 AM, bb wrote:


Mike Hansen schrieb:

On Mon, Apr 19, 2010 at 11:52 AM, bb bblo...@arcor.de wrote:

I get a runtime error, but just would expect infinity! Is there  
something

wrong or any explanation?



This is because when you do 2^3^4^5 you are computing that number
exactly as an integer, and that number is definitely not infinity.   
If

you wanted to use floating point arithmetic, then you should start
with something like 2.0:

sage: 2.0^3^4^5
+infinity

Doing something like float(2^3^4^5) computes 2^3^4^5 as an integer  
and

then tries to convert that to a float.

Also, note that when you type in such an expression, the operations
are done in the following manner:

var(sage: var('x, y, z')
(x, y, z)
sage: x^y^z
x^(y^z)

which is different than

sage: (x^y)^z
(x^y)^z

Since exponentiation is non-associative, you need to be careful with
such differences.

--Mike


Thank you for your answer! I think there is a fundamental question  
left apart from the question of assoziativity/non-assoziativity.  
There Sage (I think coming from python) does not follow the common  
rule to evaluate an expression with operators of the same precedence  
from left tor right.


The exponentiation operator is a common exception to the left-to-right  
rule. This is probably because a^(b^c) is more useful than (a^b)^c =  
a^(b*c). Magma, Mathematica, and even bc follow the right-to-left rule  
for exponentiation. (Maple actually raises an error if you don't have  
the parenthesis.)


Since Georg Cantor there is a difference between countable infinity  
(in the actual example) and noncountable infinity ( in the example  
calculated with a float). I would not say, that infinity is wrong in  
this case, only just because there is existing an infinite set of  
integers so that infinity never might be reached.


The infinity given here has nothing to do with set cardinalities, it  
is better understood as the compactification of the real line.


(I think that is the line of argument of your explanation?) The  
essential point is, one has to map the unlimited ideas of math to  
the restricted possibilities of a computer.


From a mathamatical point of view one can call the result of the  
calculation


sage: 2^(3^(4^5))
---
RuntimeError  Traceback (most recent  
call last)


/home/bb/sage-4.3.5/ipython console in module()

/home/bb/sage-4.3.5/local/lib/python2.6/site-packages/sage/rings/ 
integer.so in sage.rings.integer.Integer.__pow__ (sage/rings/ 
integer.c:12114)()


RuntimeError: exponent must be at most 9223372036854775807
sage:

just a bug! Infinity is infinity, if countable or not countable. The  
correct math-answer only could be countable infinity! But I think  
infinity would in any case be better than RuntimeError as an answer!


I strongly disagree--infinity is an approximation to very large  
numbers, not an exact answer. This is fine for floating point numbers  
where one is only working with approximations to real numbers anyways,  
but integer arithmetic is supposed to be exact. The error above is  
desirable, as it tells you it can't to the computation because it  
can't represent the result in memory (in particular, no one I know has  
a place to store all 9223372036854775807 x 8 bytes of the answer).


- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Load data from from other worksheet

2010-04-25 Thread Robert Bradshaw

On Apr 21, 2010, at 4:52 PM, Michael Rybalkin wrote:


I have installed local Sage server.

I need some kind of workspace with multiple worksheets and common data
storage while working via web interface. What can you recommend in
this case?


There aren't currently any good solutions to this unless you have  
access to the filesystem the computer is running on (e.g. you're  
running your own server) in which case you could use absolute paths.  
There was a lot of talk about improving this at the Sage Education Day  
last December, but I don't think anyone's actually had the time to  
implement it (or even work it out fully).



I want to have a bunch of common files for different worksheets. But I
don't want to link them explicity to other worksheets (by creating a
linked copy via web interface), because this data files are generated
dynamically. For example in one worksheet I wants to generate 1000
files with data and in another worksheet I want to load some of them.
I have found 2 solutions:
1. Little hack. Create some common directory in user's home directory
with worksheets and load data as
load(DATA + ../../common_dir/some_file)
But in this case I cannot use web interface to work with files in such
common directory.

2. Other hack. I can load data (or script) from another worksheet by
doing another hack:
load(DATA + ../../number/data/some_file)
In this case I can work with data via web interface via worksheet with
number number. But how can I get worksheet number (or path to it)
but its name? I need to call sagenb.notebook.worksheet.directory() for
some worksheet. Is it possible to get current notebook object or
something like this.


No, you can't get at that, because (for security reasons) the notebook  
server itself is running in a completely different process (and often  
as a different user) than the sage session you're working in.



If no good solution will be found then I will use 1st variant with
common directory in sage user's home directory.


That would probably be the best approach for now, though it may be a  
bit brittle as there are no guarantees about the future layout above  
DATA.


- Robert


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: loading a PARI script into SAGE

2010-04-25 Thread Robert Bradshaw

On Apr 24, 2010, at 11:32 PM, Alex P wrote:


Actually it does not seem to work, I get

--
| Sage Version 4.3.4, Release Date: 2010-03-19   |
| Type notebook() for the GUI, and license() for information.|
--
sage: gp(\\r cryptpr.gp)
---
TypeError Traceback (most recent call
last)

/Users/aleksandarpetrov/Desktop/Macaulay2/sage/ipython console in
module()

/Users/aleksandarpetrov/Desktop/Macaulay2/sage/local/lib/python2.6/
site-packages/sage/interfaces/expect.pyc in __call__(self, x, name)
  1030
  1031 if isinstance(x, basestring):
- 1032 return cls(self, x, name=name)
  1033 try:
  1034 return self._coerce_from_special_method(x)

/Users/aleksandarpetrov/Desktop/Macaulay2/sage/local/lib/python2.6/
site-packages/sage/interfaces/expect.pyc in __init__(self, parent,
value, is_name, name)
  1449 except (TypeError, KeyboardInterrupt,
RuntimeError, ValueError), x:
  1450 self._session_number = -1
- 1451 raise TypeError, x
  1452 self._session_number = parent._session_number
  1453

TypeError: Error executing code in GP/PARI:
CODE:
   sage[1]=\r cryptpr.gp;
GP/PARI ERROR:
 ***   unexpected character: sage[1]=\rcryptpr.gp;
 ^-
sage:


Same thing if I try the other command that William Stein suggested.


You have to do

sage: gp.eval(r\r cryptpr.gp;)

As gp(foo) only works if foo is an expression.

- Robert


On Apr 24, 4:21 pm, Alex P alexvpetr...@gmail.com wrote:

To William Stein: Great thanks.
To John Cremona: Sorry about that, won't happen again.

On Apr 24, 3:10 pm, William Stein wst...@gmail.com wrote:



On Fri, Apr 23, 2010 at 5:23 PM, Alex P alexvpetr...@gmail.com  
wrote:

Hi all,
I was trying to use a PARI/GP script in SAGE. I tried gp('\r
name_of_file.gp'), but SAGE said could not get the file.
So is there any way to do this.



You need



   sage: gp(\\r name.gp)



or



sage: gp(r\r name.gp)



William



10x in advance.
Alex



--
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
For more options, visit this group athttp://groups.google.com/group/sage-support
URL:http://www.sagemath.org



--
William Stein
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 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group athttp://groups.google.com/group/sage-support
URL:http://www.sagemath.org


--
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
For more options, visit this group athttp://groups.google.com/group/sage-support
URL:http://www.sagemath.org


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Large monomial exponents

2010-04-24 Thread Robert Bradshaw

On Apr 24, 2010, at 5:36 PM, Michael Rybalkin wrote:


How to get monomial with large exponent in the polynomial rings?

For example I hsave polynomial ring over large finite field:
p = next_prime(10^20)
R.x = PolynomialRing(GF(p), sparse=True)

Monomial x^(10^7) construction takes 2 seconds:
time tmp = x^(10^7)

Monomial x^(10^8) construction uses all 6 Gb server memory and cannot
finish.
And without 'sparse=True' option I cannot even get x^(10^6).

What is the limitations for monomial exponents in polynomial rings?
What can be done in my case? For example GAP handles this case without
any problem.


Seems like the sparse=True flag is horribly broken for GF(p)[x]:

sage: p = next_prime(10^20)
sage: R.x = PolynomialRing(GF(p), sparse=True)
sage: type(x)
type 'sage.rings.polynomial.polynomial_zz_pex.Polynomial_ZZ_pEX'

sage: R.x = PolynomialRing(QQ, sparse=True)
sage: x^(10^8)
x^1


- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: list vs. integer instances

2010-04-20 Thread Robert Bradshaw

On Apr 19, 2010, at 4:05 PM, wb wrote:


On Apr 20, 12:25 am, Robert Bradshaw rober...@math.washington.edu
wrote:

On Apr 19, 2010, at 2:50 PM, wb wrote:


coming from C I'm confused about this behavior in assignment:


Since you know C, it may make sense to think of lists as being  
similar

to pointers.



that makes sense - I guess I was expecting lists to behave like list
*classes* which have an overloaded assignment operator.
Turning this around: is there a 'list-like' data type in sage which
has 'true' assignment, i.e. copying all its content ?


Python inherits a lot from C. It is practically nothing like C++  
(despite both being object oriented). There's no such thing as  
assignment overloading--everything is heap allocated and you're just  
passing around references under the hood.


Try doing

sage: import copy
sage: copy.tab

to if some of the functions there work for you.

- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] list vs. integer instances

2010-04-19 Thread Robert Bradshaw

On Apr 19, 2010, at 2:50 PM, wb wrote:


coming from C I'm confused about this behavior in assignment:


Since you know C, it may make sense to think of lists as being similar  
to pointers.




1) using only integers --
sage: a=2
sage: b=2
sage: b=b+a
sage: b
4
sage: a
2

so (at least), after b=b+a, 'b' seems to have gotten its own instance,
however

2) using lists 
sage: a=[1,2]
sage: b=a
sage: b[0]=b[0]+a[0]
sage: b
[2, 2]
sage: a
[2, 2]   --- ?!?

(which results also if done directly in python). So, after
b[0]=b[0]+a[0], 'b' does not seem to get its own instance and 'a'
therefore also gets modified  ..!? ... which somehow seems
inconsistent with 1) and very strange anyway ...

Finally

3) -
sage: a=[1,2]
sage: b=a+[]    ! Trying to force (maybe?) an own
instance for 'b'
sage: b[0]=b[0]+a[0]
sage: b
[2, 2]
sage: a
[1, 2]   ok

in exmpl. 3) the list behaves similar to the integers in exmpl. 1).

Question: is the assignment b=a+[] the only way to achieve this ?

Thanks,
wb

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Invoking Lisp from within Sage

2010-04-14 Thread Robert Bradshaw

On Apr 13, 2010, at 11:20 PM, Adam Getchell wrote:


Hi all,

I realize this maybe a bit of an insane question, but I'm looking  
for a way to use ecl within sage besides:


./sage -ecl

I have googled for relevant results, but documentation on  
sage.interfaces.lisp seems broken right now:


http://sage.math.washington.edu/home/mhansen/sage-epydoc/sage.interfaces.lisp-module.html


That just happened to be a file sitting in someone's directory. It  
doesn't look like its in the user manual, http://hg.sagemath.org/sage-main/file/ea02bc44fa94/sage/interfaces/lisp.py 
 can serve as a reference though. Basically, you can do


sage: lisp((+ 1 2))
'3'

and whatever else you want, including reading in files, etc. You can  
also do


sage: a = lisp(1)
sage: b = lisp(2)
sage: a + b
3
sage: type(a+b)
class 'sage.interfaces.lisp.LispElement'


If it helps, here's the background:

We've got some rather neat causal dynamical triangulation (2d  
quantum gravity) code running in Lisp. The lisp environment lacking  
certain facilities, I thought it would be neat to find a way to run  
it within Sage and take advantage of all the nice facilities  
provided. I'm looking to avoid rewriting it in python for now,  
though I would certainly do it if advised that was the only way.


One of the primary goals of all the interfaces is so you can use your  
existing code right from Sage. Give the above a try.


- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Inverses of Large Sparse Matrices

2010-04-09 Thread Robert Bradshaw

On Apr 9, 2010, at 10:53 AM, Leo Maloney wrote:


I'm trying to compute the inverse of a 5000 x 5000 sparse matrix.


What is the basering?


I'm getting an EOF error after it runs for about 5 hours, and then it
states that sage is trying to access unallocated memory.  Is there a
way I can increase the memory for this computation?  Every time I
Google it, all I can find is the benefits sage(plant) has on memory.



What operating system are you on. Are you using Sage in a VM (on  
Windows)? If so, you can increase the amount of memory allocated to  
the virtual machine. Otherwise, have you checked to see if you even  
have any memory left on your computer when doing the computation?  
(Perhaps the only way to increase the memory is to buy more RAM or run  
it on a different computer.)


- Robert


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


Re: [sage-support] Some experiences

2010-04-07 Thread Robert Bradshaw

On Apr 6, 2010, at 11:22 PM, Rolandb wrote:


Hi, some experiences.

I moved from Vista 32 to Windows 7 64 during Easter. I have a Q6700
PC.

Three issues are maybe of general interest.

1) Virtualbox 4.3.4: A clumsy environment so I switched back to (the
new) VMware player 3.01 and (the old) Sage 4.1. Now I was positively
surprised how cool Sage works, and also the fact that I could run
multiple Sage sessions all calculating ... But maybe my Virtualbox
isn't properly installed?


Probably, though Virtualbox is rough around the edges (as are all  
options of running Sage on Windows).



2) I hoped for a considerable increase in speed, because 64bit
optimized c code or assembly  instructions are superior to 32bit. So I
tested a few simple operations, and I noticed hardly any improvement!
Did I installed the wrong version of Sage 4.1? I used sage-
vmware-4.1.7z.


Without recompiling for your machine, you won't be able to fully take  
advantage of all it has to offer. In any case, you're running it  
inside a VM which is probably fixed to be either 32 or 64 bit.



3) Whilst looking for need for speed, I found that many relatively
simple standard sage functions aren't optimized. For instance
CRT_list(v,moduli)?? states:

if len(v) == 0:
   return 0
   x = v[0]
   m = moduli[0]
   for i in range(1,len(v)):
   x = CRT(x,v[i],m,moduli[i])
   m *= moduli[i]
   return x%m

And CRT(a,b,m,n)??:

if isinstance(a,list):
   return CRT_list(a,b)
   g, alpha, beta = XGCD(m,n)
   if g != 1:
   raise ValueError, arguments a and b must be coprime
   return a+(b-a)*alpha*m

Just combining both gives:

def crt_faster(v,moduli):
   x = v[0]
   m = moduli[0]
   for i in range(1,len(v)):
   x +=(v[i]-x)*xgcd(m,moduli[i])[1]*m
   m *= moduli[i]
   return x%m

This improves speed by a factor of 1.5 to 2.


I'm assuming you're timing very small examples?


- Is there in the near future an effort to optimize those relatively
simple, but probably often used, routines?


Yes, you just did it :) We'd love for you to submit a patch. There's  
tons of stuff in Sage that could use optimization and cleanup (and  
sage/rings/arith.py is high on the list). Often what happens is  
someone needs some functionality, so they implement it, and then later  
someone else needs it to be fast, so they optimize it.


Some areas for future improvement may be using CRT_basis, and it's  
asymptotically faster (for a single call at least) to to CRT in a  
binary tree rather than linearly.



- What is the best way to check the most efficient routine? Installing
packages like FLINT?


FLINT is installed by default already. If your list consists of  
elements of Z[x], it will be used already under the hood.


- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


Re: [sage-support] problems with sage and brian simulator

2010-04-07 Thread Robert Bradshaw

On Apr 7, 2010, at 2:10 AM, Uri wrote:


I'm having some problems trying to use a program called Brian
Simulator (www.briansimulator.org) through Sage. This program is
written in Python an can be used as a python package (I've tried it
and I had no problem). However, when I try to use it in Sage I get
some problems involving units, which are defined inside Brian. For
example, if I write:

sage: from brian import *
sage: 1*mV

I get the following error:


AttributeErrorTraceback (most recent call
last)

/home/uri/ipython console in module()

/home/uri/sage-4.3.1/local/lib/python2.6/site-packages/sage/structure/
element.so in sage.structure.element.RingElement.__mul__ (sage/
structure/element.c:10382)()

/home/uri/sage-4.3.1/local/lib/python2.6/site-packages/sage/structure/
coerce.so in sage.structure.coerce.CoercionModel_cache_maps.bin_op
(sage/structure/coerce.c:6145)()

/home/uri/sage-4.3.1/local/lib/python2.6/site-packages/brian/units.pyc
in __mul__(self, other)
  1063 if isinstance(other,Unit):
  1064 u = Unit(float(self)*float(other))
- 1065 u.name = self.name + other.name
  1066 u.dispname = self.dispname + ' ' + other.dispname
  1067 u.dim = self.dim * other.dim

AttributeError: name


Does somebody know why it happens and how to avoid this error? What I
don't understand is that if I just write:

sage: mV

there's no problem at all. Thank you in advance!!


It appears that brian.units doesn't behave well with Sage integers  
(perhaps assuming anything that's not a float or int is a  
briansimulator unit). Try


sage: from brian import *
sage: int(1)*mV

or

sage: 1r*mV

- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


Re: [sage-support] standard deviations in sage

2010-04-07 Thread Robert Bradshaw

On Apr 7, 2010, at 9:29 AM, Kenneth A. Ribet wrote:


Hello All,

I asked myself how I could use sage to compute the standard  
deviation of a grade distribution for one of my courses.  Rooting  
around, I found that I can compute for example


sage: vector(RDF,[1,2,2,1]).standard_deviation()

and get the answer 0.57735026919.  However, if I try the same  
command with RDF replaced by RR, I get anAttributeError.  My  
first question is: What's going on here; how come RDF and RR are so  
different in this context?  Their respective descriptions look very  
similar --


Because no one's yet taken the time to unify the interfaces yet (the  
two different rings use different implementations under the hood-- 
the one for RDF is optimized as a double* whereas the one for RR is  
just the generic one). It would probably make sense to put a  
standard_deviation method higher up the inheritance tree.


To be clear, I consider this a bug (fortunately easy to fix) and a  
ticket should be filed.


An approximation to the field of real numbers using double  
precision floating point numbers. Answers derived from calculations  
in this approximation may differ from what they would be if those  
calculations were performed in the true field of real numbers. This  
is due to the rounding errors inherent to finite precision  
calculations.


An approximation to the field of real numbers using floating point  
numbers with any specified precision. Answers derived from  
calculations in this approximation may differ from what they would  
be if those calculations were performed in the true field of real  
numbers. This is due to the rounding errors inherent to finite  
precision calculations.


If I had found some documentation about the standard deviation  
command, I would probably have have found the answer to my first  
question.  This leads to my second question: Why I don't I see  
information about standard_deviation when I type  
standard_deviation? at the command line?



Sage has an object-oriented design, which is to say that functions are  
attached to objects rather than all dumped into the global session.  
This allows stuff like


sage: v = vector(RDF, [1,2,2,1])
sage: v.norm()
3.16227766017
sage: I = NumberField(x^3-x+1, 'a').ideal(2)
sage: I.norm()
8

where doing v.norm? and I.norm? can give good contextual information  
given the wide variety of objects and paradigms that Sage supports  
(and it makes tab completion work much smoother too). I could see a  
case for standard_deviation being a top-level function though, like we  
do for many other basic operations. (Typically f(X) calls X.f()).


- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


Re: [sage-support] Difference between sage and pyhton calculations

2010-04-06 Thread Robert Bradshaw

On Apr 5, 2010, at 9:44 PM, William Stein wrote:

On Mon, Apr 5, 2010 at 9:12 PM, Michael Welsh  
yom...@yomcat.geek.nz wrote:


On 6/04/2010, at 3:56 PM, Eugene Goldberg wrote:


Hello!

Here is my pyhtons results:

python
Python 2.6.5 (r265:79063, Mar 23 2010, 04:49:54)
[GCC 4.4.3] on linux2
Type help, copyright, credits or license for more  
information.

1+1

2

6e-6 % 10e-6

6.0002e-06




and here is sage:

./
sage
Sage Version 4.3.5, Release Date:
2010-03-28
sage: 1+1
2
sage: 6e-6 % 10e-6
-4.00e-6

I'm sure sage is wrong.. :(


Well, at least the two answers are equivalent mod 10e-6.


They're both the same...


No they aren't.

If you type

sage: s = 6e-6
sage: s.__mod__??

then you can read the documentation for Sage's % on real numbers.
Definitely the result

sage: 6e-6 - 10e-6
-4.00e-6

matches what is claimed in the docstring.   The actual function  
calls the

MPFR function mpfr_remainder, which is documented here:

  http://www.mpfr.org/algorithms.pdf

See Section 3.8.

This web page: http://pyref.infogami.com/operator-mod describes the  
Python
semantics for Python's __mod__ on float's.  They are different than  
MPFR's.


I would be in favor of following Python's conventions here--they at  
least seem more natural to me (after all, % is related to floor  
division not round division. :)


- Robert


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


Re: [sage-support] Difference between sage and pyhton calculations

2010-04-06 Thread Robert Bradshaw

On Apr 6, 2010, at 12:17 AM, Paul Zimmermann wrote:

If one wants to have the same answer as Python does (always  
nonnegative),

then function math.fmod can be used. For example,
sage: from math import fmod
sage: fmod(6e-6,10e-6)
6.0002e-06


first Python does not always give a nonnegative result:


(6e-6) % (-10e-6)

-4.0007e-06

secondly this does not match the math.fmod function either:

sage: from math import fmod
sage: fmod(6e-6,-10e-6)
6.0002e-06

I would recommend that Sage % follows one of the C99 standard  
functions,
fmod or remainder. Maybe fmod would be better, and remainder could  
be provided

as a different method.


I would rather agree with integers here

sage: -1 % 10
9

(Personally, I think C got % wrong, or at least the easy to implement  
choice won over the more useful, as x%n gives different results for  
various x in the same residue class mod n.)


- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


Re: [sage-support] Re: adding noise

2010-04-03 Thread Robert Bradshaw

On Apr 2, 2010, at 9:41 PM, G B wrote:

Thanks for the detailed response, Simon.  Please understand that I'm  
not being critical of Sage-- quite the contrary, I'm excited about  
what it might offer me once I master it.


I think you touch on one key to the problem-- I'm not a  
mathematician, I'm an engineer.  While most of the world would  
certainly accuse us of being sloppy dressers, mathematicians are one  
of the few groups that can legitimately accuse us of being sloppy  
thinkers.  I think that brand of sloppy thinking is what is at issue  
here, and when I say work around I mean become tolerant of.


Sage has already encouraged me to learn more about ring theory than  
I ever would have needed otherwise, but getting completely different  
results when executing plot(f(x),(x,0,2*pi)) vs. executing plot(f, 
(0,2*pi)) started playing on my patience a bit and has me wondering  
if I'm simply using an irreconcilably wrong tool for the job.  I  
think the intention of both of those statements is the same, and  
thus should yield the same result, and my suspicion is that the  
reason they don't is an artifact of the plumbing, but I may be  
missing something.


A good way to think about it is this: Python expressions are evaluated  
greedily, from the inside out. Thus


sage: plot(f(x),(x,0,2*pi))

is the same as

sage: A = f(x)# A is now sin(x) + 0.619...
sage: B = (x,0,2*pi)
sage: plot(A, B)

When you write something like sin(x), sin is actually getting called  
with the argument x, and the result is sin evaluated at the  
indeterminate x (in other words, it's not just returning the old thing  
back again). As a more concrete example.


sage: g(x) = sin(x) + sqrt(x)
sage: g(x)
sqrt(x) + sin(x)  # g was called with x and plugged in x for x
sage: g(5)
sqrt(5) + sin(5)
sage: var('y')
y
sage: g(y)
sqrt(y) + sin(y)
sage: g(x+y)
sqrt(x + y) + sin(x + y)


It's not the f(x)=sin(x)+T.get_random_element() form that troubles  
me though, for the record, I did try 'f(x)=sin(x) 
+T.get_random_element(x)'.  Expectedly, it doesn't like having an  
unwanted argument shoved down its throat.


What still feels awkward to me is how constructs like this behave:
var('x')
T=RealDistribution('gaussian',1)
f=lambda x: T.get_random_element()
g(x)=sin(x)+f(x)

To my mind, the way that is handled is particularly confusing.
[f(1),f(2),f(3)]  -- [-0.568652852118, 0.912307924442, 1.35997405644]

but,
[g(1),g(2),g(3)]  -- [sin(1) - 0.176035204293, sin(2) -  
0.176035204293, sin(3) - 0.176035204293]


In other words, calling f repeatedly gives different results each  
time, but calling g repeatedly does not.


That may be a case where the parenthetical syntax conspires with the  
overloaded meanings of function to expose my sloppy thinking, but  
it also kind of looks like a trap waiting to be triggered.


If sin(x) and f(x) are fundamentally different entities, and my  
engineering mind isn't completely convinced that they should be,


Yes, they are very different. The first are expression-like  
functions, where it makes sense to differentiate, integrate, typeset,  
and otherwise manipulate them as mathematical objects. Sin falls  
into this category. The other type are procedures which are are  
really arbitrary chunks of code which are the ones native to Python  
(and essentially every other procedural programming language). These  
are the ones that generate random numbers, test for primality, fetch  
webpages, save files, etc. Plot itself is such a function. It  
doesn't makes much sense to differentiate or typeset such functions,  
but they can be called.


Both types of functions are clearly essential, the confusion arises in  
the fact that it's possible to evaluate (and, sometimes, plot) both  
kinds. That being said, I think it should easier (and more natural) to  
try to do what you're trying to do here.


then the syntax should prevent the construction of g in such a  
manner.  Either execution of f should be deferred until g is called  
with a parameter, as I would expect, or an error should be thrown  
for providing illegal arguments to operator '+'.


The problem is that the two terms are evaluated before the + operator  
is hit, i.e.


sage: g(x) = sin(x) + f(x)

is the same as

sage: A = sin(x)   # actually calls sin (resulting in sin(x))
sage: B = f(x)   # actually calls f (resulting in 0.619)
sage: g(x) = A + B   # tries to add (which is just fine)

If I want g(x) defined as sin(x) plus the result of f(x) as x is  
defined at the definition of g, then the syntax should highlight  
that by forcing something like g(x)=sin(x) + `f(x)`


To get something deferred, which sounds like what you want, you could  
abandon the g(x) = ... syntax completely and always use lambda (or def)


sage: g = lambda x: sin(x) + f(x)

or

sage: def g(x):
...return sin(x) + f(x)


It may take some getting used to, but functions can even return other  
functions. For example, you 

Re: [sage-support] Potential Security Hole -- sh (shell) in Notebook

2010-04-01 Thread Robert Bradshaw

On Apr 1, 2010, at 6:04 PM, TianWei wrote:


The sh option in the sage notebook allows anyone to access the
command-line shell on the sage server. This grants users access to any
directory on the server, including configuration settings, etc. Even
on the Try Sage Online link on the main page (www.sagenb.org) lets
users do this.

This is a potential security hole for all sage servers.

(The sh option I'm talking about is in the drop-down menu that
selects the backend to process user commands, such as sage, maxima, r,
gap, gp, python, and so on)


Letting users run arbitrary Python commands (the default) is just as  
dangerous, e.g. anything one can do from the shell one can do with  
os.system(). This is a well-known potential vulnerability and should  
always be mitigated via other means (e.g. only letting trusted users  
use the server, granting the worksheet processes limited privileges,  
and/or running the whole thing inside a jail/zone/virtual machine).


- Robert

--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


Re: [sage-support] Re: Print only outputs?

2010-04-01 Thread Robert Bradshaw

On Apr 1, 2010, at 9:11 PM, TianWei wrote:


I for one would find hiding input cells useful because when I use sage
for my math homework, I like the pretty printing feature of the text
cells (using $...$), and often times I will use the output of the
calculation cells (e.g. graphs) to accompany the text, but the actual
sage commands themselves are sometimes irrelevant.


Probably not irrelevant to whoever is grading it :). In any case,  
there is the %hide mode for hiding input cells, but it doesn't seem to  
affect the printed view.



This is just my view.

On Apr 1, 7:39 pm, William Stein wst...@gmail.com wrote:
On Thu, Apr 1, 2010 at 10:27 AM, Eugene Goldberg  
omegat...@gmail.com wrote:

Hi!



Is it possible to print only output content of worksheet?


No, this isn't currently supported.  It would likely be easy to
implement.  Nobody has ever requested this feature before, as far  
as I

can remember.  Can you explain more about why you want it.

William




--
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
For more options, visit this group athttp://groups.google.com/group/sage-support
URL:http://www.sagemath.org



To unsubscribe, reply using remove me as the subject.


--
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 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


Re: [sage-support] Re: Is there an efficient method of producing indexed variables?

2010-04-01 Thread Robert Bradshaw

On Apr 1, 2010, at 9:21 PM, scott.h wrote:


That did exactly what I wanted to do!  Thank you very much for taking
the time to reply.  The command C = [var(C_%s % i) for i in
range(n)] in particular is what I was looking for.  I think I can
glean how %s works from how you've used it and will experiment a
little.  However if you, or anyone else, could point me in the
direction of some documentation for it that would be much
appreciated.  It's sort of hard to google/search.


How about http://diveintopython.org/native_data_types/formatting_strings.html



On Apr 1, 7:50 pm, Minh Nguyen nguyenmi...@gmail.com wrote:

Hi,

On Fri, Apr 2, 2010 at 12:36 PM, scott.h scott.he...@gmail.com  
wrote:


SNIP


It seems like this should be simple but for the life of me I can't
figure out how to do it.


Here I'm taking a guess at what you really want to do. See the
following Sage session:

[mv...@sage ~]$ sage
--
| Sage Version 4.3.5, Release Date:  
2010-03-28   |
| Type notebook() for the GUI, and license() for  
information.|

--
sage: n = 3
sage: M = random_matrix(ZZ, nrows=n); M
[ 2  2 -2]
[ 4  2 -7]
[ 2 -1  1]
sage: # create a list of unknown constants; these are actually
symbolic variables
sage: C = [var(C_%s % i) for i in range(n)]; C
[C_0, C_1, C_2]
sage: X = [randint(1, 10) for i in range(n)]; X
[2, 3, 2]
sage: F = [C[i] * exp(M[i,i] * x) for i in range(n)]; F
[C_0*e^(2*x), C_1*e^(2*x), C_2*e^x]
sage: [F[i].substitute(x=X[i]) for i in range(n)]
[C_0*e^4, C_1*e^6, C_2*e^2]

--
Regards
Minh Van Nguyen


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

To unsubscribe, reply using remove me as the subject.


--
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
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


<    1   2   3   4   5   6   7   8   >