[sage-support] Re: sage server

2009-10-26 Thread David Guichard

Thanks! I'll give it a try.

-- David

--~--~-~--~~~---~--~~
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: Python lists and removals

2009-10-26 Thread kcrisman

Great, thanks to both of you.  No wonder I didn't see it in the
documentation for lists!  Luckily my lists are probably very short
(len<5) so don't have to worry about algorithms for now, just a
bugfix.

- kcrisman

On Oct 26, 5:02 pm, Jason Grout  wrote:
> Dag Sverre Seljebotn wrote:
>
> > a) for x in L[:]: ... # makes a copy
> > b) remove from the end of the list...
>
> c) use list comprehensions to construct a new list, then del the old list.
>
> Jason
--~--~-~--~~~---~--~~
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: Python lists and removals

2009-10-26 Thread Jason Grout

Dag Sverre Seljebotn wrote:
> 
> a) for x in L[:]: ... # makes a copy
> b) remove from the end of the list...


c) use list comprehensions to construct a new list, then del the old list.


Jason


--~--~-~--~~~---~--~~
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: Python lists and removals

2009-10-26 Thread Dag Sverre Seljebotn

kcrisman wrote:
> Dear support,
> 
> I'm trying to resolve #7315 and have discovered something that
> disturbs me, but probably is reasonable to someone who really
> understands Python lists.  Namely:
> 
> {{{
 L=[1,2,3,4]
 for x in L:
> ... L.remove(x)
> ... x
> ... L
> ...
> 1
> [2, 3, 4]
> 3
> [2, 4]
 L
> [2, 4]
> }}}
> 
> Somehow it is going by the index of the list, not the actual
> elements.  Assuming this is intended behavior, what is the right
> workaround?  Any link to the official Python documentation would be
> wonderful as well.

As you say, the iterator goes by index. This isn't really "solvable" the 
way you seem to expect because of how lists fundamentally work. Workarounds:

a) for x in L[:]: ... # makes a copy
b) remove from the end of the list...

If your list is big: Note that removing from the middle of a list is 
going to be expensive since the remainder of the list is copied for each 
iteration. You should consider alternative ways of expressing your 
algorithm (or, if you have to do this, look around for a linked list 
implementation for Python).

Removing from the end is cheap, so is removing from either end using 
collections.deque.

-- 
Dag Sverre

--~--~-~--~~~---~--~~
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: Python lists and removals

2009-10-26 Thread Jason Grout

kcrisman wrote:
> Dear support,
> 
> I'm trying to resolve #7315 and have discovered something that
> disturbs me, but probably is reasonable to someone who really
> understands Python lists.  Namely:
> 
> {{{
 L=[1,2,3,4]
 for x in L:
>  L.remove(x)
>  x
>  L
> 
> 1
> [2, 3, 4]
> 3
> [2, 4]
 L
> [2, 4]
> }}}
> 
> Somehow it is going by the index of the list, not the actual
> elements.  Assuming this is intended behavior, what is the right
> workaround?  Any link to the official Python documentation would be
> wonderful as well.


http://docs.python.org/reference/compound_stmts.html#the-for-statement

"There is a subtlety when the sequence is being modified by the loop 
(this can only occur for mutable sequences, i.e. lists). An internal 
counter is used to keep track of which item is used next, and this is 
incremented on each iteration. When this counter has reached the length 
of the sequence the loop terminates. This means that if the suite 
deletes the current (or a previous) item from the sequence, the next 
item will be skipped (since it gets the index of the current item which 
has already been treated). Likewise, if the suite inserts an item in the 
sequence before the current item, the current item will be treated again 
the next time through the loop. This can lead to nasty bugs that can be 
avoided by making a temporary copy using a slice of the whole sequence, 
e.g.,

for x in a[:]:
 if x < 0: a.remove(x)


Thanks,

Jason


--~--~-~--~~~---~--~~
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] Python lists and removals

2009-10-26 Thread kcrisman

Dear support,

I'm trying to resolve #7315 and have discovered something that
disturbs me, but probably is reasonable to someone who really
understands Python lists.  Namely:

{{{
>>> L=[1,2,3,4]
>>> for x in L:
... L.remove(x)
... x
... L
...
1
[2, 3, 4]
3
[2, 4]
>>> L
[2, 4]
}}}

Somehow it is going by the index of the list, not the actual
elements.  Assuming this is intended behavior, what is the right
workaround?  Any link to the official Python documentation would be
wonderful as well.

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
-~--~~~~--~~--~--~---



[sage-support] hold function

2009-10-26 Thread Mikie

Does anyone have a Sage hold frunction?  Look at the code below
-
def LikeSimplify1a(ex1,ex2,ex3,ex4):
 eq1=str(ex1)+"+"+"("+str(ex2)+")"+"+"+"("+str(ex3)+")"+"+"+"("+str
(ex4)+")"
 n1=SR(ex1);n2=SR(ex2);n3=SR(ex3);n4=SR(ex4)
 eq2=maxima.ratsimp(n1+n2+n3+n4)
 return eq1,eq2


Input

a1=LikeSimplify1a('-2*(-x-2*x^2-x)','-sqrt(12)-x','-2*(4-10)','10');a1
[0];a1[1];#a1[2]
---
Output
---
  '-2*(-x-2*x^2-x)+(-sqrt(12)-x)+(-2*(4-10))+(10)'
4*x^2+3*x-2*sqrt(3)+22

This is in the notebook and is about what I want.  When I use it on my
server the -sqrt(12) becomes -2sqrt(3).  I don't want this.  Can
anyone help me with a hold function that works in a Python script?
Thanx


--~--~-~--~~~---~--~~
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] Installation difficulties

2009-10-26 Thread dmb

Hello,

I just obtained a new mac and an trying to install sage on it.  I have
copied the dmg to the applications folder, clicked on it and gone
through the installation process.  I was asked to enter a password,
but I did not enter my password for my account, but rather one for
sage usage (a stupid idea on my part).
Now everytiime I attempt to run sage, I get the following

IOError: [Errno 30] Read-only file system: '/Volumes/sage-4.1.2-
OSX-10.6-Intel-64bit-i386-Darwin/sage/local/lib/libcord.la'


I have tried to delete the files as root, but I still get the same
error message

Thanks,

Duane Broline

--~--~-~--~~~---~--~~
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] nearest integral vector with LLL

2009-10-26 Thread adam mohamed
Hi All,

 I would like to know if the search for the nearest vector using LLL in  a
lattice over a number field  is implemented in Sage. The documentation does
not say anything about that, unfortunately. Thanks.

Regards,





-- 
adam

--~--~-~--~~~---~--~~
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: Factorize/collect a sub expression

2009-10-26 Thread Francois Maltey

mpad a écrit :
> Hello everyone,
>
> I am new to sage (thanks for it ! it looks excellent !) and have been
> trying to re-factor some long expressions.
> As an example :
>
> sage: var('x,y,a,b,c,d')
> (x, y, a, b, c, d)
> sage: T=expand((x^2+y^2)*(a*b+a^2-2*d*c+c^2-3*b^2));T
> a^2*x^2 + a^2*y^2 + a*b*x^2 + a*b*y^2 - 3*b^2*x^2 - 3*b^2*y^2 +
> c^2*x^2 + c^2*y^2 - 2*c*d*x^2 - 2*c*d*y^2
> sage: T.collect(x^2+y^2)
> a^2*x^2 + a^2*y^2 + a*b*x^2 + a*b*y^2 - 3*b^2*x^2 - 3*b^2*y^2 +
> c^2*x^2 + c^2*y^2 - 2*c*d*x^2 - 2*c*d*y^2
>
> I've played a bit and got lost in the doc... but could not find a way
> to have sage re-factor a given sub-expression out.
> (also it seems that T.coeffs(x^2+y^2) makes sage hanging...)
>
>   
collect operates over variables, and doesn't operate over subexpressions 
or polynomial as x^2+y^2.

factor(T) is right if T is a product. It's also possible to use 
T.rational_simplify()
Theses calculus are fine only because T is a product.

For theses expressions it's not so pretty to play with 
T.subs_expr(x^2+y^2==r^2) because x^2 and y^2 aren't close in the formula.

T.subs_expr(x^2==r^2-y^2) is a little better, and I find pretty the 
expand(T.subs_expr(x^2==r^2-y^2) 

You can also look at T.collect(a).collect(b).collect(c), or in the 
opposite direction T.collect(x).collect(y)






> Thanks for any help !
>
> Cheers,
>
> P.A.
>
> >
>
>
>   


--~--~-~--~~~---~--~~
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: From Google Earth to Sage. Is sage capable of this?

2009-10-26 Thread Jason Grout

brandon holmes wrote:
> Thank you! i am very surprised anyone had any sort of answer! I will 
> play around with the links and see what i can come up with!
> 


Also, you can duplicate exactly what Mathematica did (get data from COM) 
using python.  Search for "python COM" in google.  Except, of course, if 
you are on windows, you can't run Sage, unless you export the data and 
then import it into Sage separately.

You could use matplotlib on Windows, though, to draw graphs like what 
you showed.

Jason


--~--~-~--~~~---~--~~
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] Obsolete online installation instructions

2009-10-26 Thread JDM

Windows installation instructions on this page are obsolete:
http://www.sagemath.org/doc/installation/binary.html
Also the link to readme.txt is broken.

--~--~-~--~~~---~--~~
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] Factorize/collect a sub expression

2009-10-26 Thread mpad

Hello everyone,

I am new to sage (thanks for it ! it looks excellent !) and have been
trying to re-factor some long expressions.
As an example :

sage: var('x,y,a,b,c,d')
(x, y, a, b, c, d)
sage: T=expand((x^2+y^2)*(a*b+a^2-2*d*c+c^2-3*b^2));T
a^2*x^2 + a^2*y^2 + a*b*x^2 + a*b*y^2 - 3*b^2*x^2 - 3*b^2*y^2 +
c^2*x^2 + c^2*y^2 - 2*c*d*x^2 - 2*c*d*y^2
sage: T.collect(x^2+y^2)
a^2*x^2 + a^2*y^2 + a*b*x^2 + a*b*y^2 - 3*b^2*x^2 - 3*b^2*y^2 +
c^2*x^2 + c^2*y^2 - 2*c*d*x^2 - 2*c*d*y^2

I've played a bit and got lost in the doc... but could not find a way
to have sage re-factor a given sub-expression out.
(also it seems that T.coeffs(x^2+y^2) makes sage hanging...)

Thanks for any help !

Cheers,

P.A.

--~--~-~--~~~---~--~~
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: "Typeset" problem with sech(x)

2009-10-26 Thread Burcin Erocal

Hi,

On Sun, 25 Oct 2009 19:44:21 -0700 (PDT)
John H Palmieri  wrote:

> 
> On Oct 25, 7:37 pm, Marshall Hampton  wrote:
> > Latex doesn't actually support \sech, so this can't really be
> > considered an error on Sage's part.
> >
> > Note that
> >
> > sage: latex('sech(x)')
> >
> > gives
> >
> > \text{sech(x)}
> 
> On the other hand,
> 
> sage: latex(sech)
> 
> gives
> 
> \sech
> 
> I think the problem is in sage/functions/hyperbolic.py:
> 
> PrimitiveFunction.__init__(self, "sech", latex=r"\sech",
>approx=lambda x: 1/math.cosh(x))
> 
> Which hyperbolic functions have broken latex methods?


Here is the relevant ticket:

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


In the symbolic function refactoring patch [1], I fixed the problems
with sin^{-1}. It seems that \sech still remains 

[1] 
http://groups.google.com/group/sage-devel/browse_thread/thread/6f1efcad26909d3

I will try to clean up the symbolic functions patch next week and
submit it for review. I can try to fix the other typesetting problems
then if nobody beats me to it.


Cheers,
Burcin

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---