Re: [sage-support] Dependence set of a symbolic expression

2011-12-03 Thread Santanu Sarkar
Thankx a lot.

On 2 December 2011 02:18, Laurent  wrote:
>> sage: x0,x1,x2,x3,x4,x5,x6,x7,x8,x9 = var('x0,x1,x2,x3,x4,x5,x6,x7,x8,x9')
>> sage: S = 1*x1 + 2*x3 + 3*x4 + 4*x5 + 5*x7 + 6*x9
>> sage: S.variables()
>> (x1, x3, x4, x5, x7, x9)
>
>
> By the way :
>
> sage: x=var('x')
> sage: S=sin(x)**2+cos(x)**2
> sage: S.variables()
> (x,)
> sage: S.simplify_trig().variables()
> ()
>
> thus one has to be somewhat careful.
>
> Laurent
>
>
> --
> 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


[sage-support] Re: matrix help

2011-12-03 Thread Chappman
Is it possible to make an entry in Q[i,j] equal to a entry in U[i,j]?
I have to have the two functions separately for each matrix though
just like my code above
i.e.

def U(N,M):
...
...
...
return U
def Q(N,M)
...
...
...
Q[i,j]=U(N,M)
return Q

Kind Regards
Chappman



On Dec 3, 4:26 am, "D. S. McNeil"  wrote:
> > def U(N,M):
> >    U=matrix(ZZ,N*M)
> >    for i in range(N*M):
> >        for j in range(N*M):
> >            U[i,j]=1
> >    return U
> > def Q(N,M):
> >    Q=matrix(ZZ,N*M)
> >    for i in range(N*M):
> >        for j in range(N*M):
> >            Q[i,j]=U(N,M)
> >    return Q
>
> U(N,M) is a function which returns a matrix.  The line Q[i,j]=U(N,M)
> attempts to set the (i,j)-th entry of the Q matrix, defined over ZZ,
> to an NxM matrix, which isn't going to work.  (Hence the "cannot
> coerce a matrix to an integer" error message -- it's trying to fit
> U(N,M) into an entry of Q, and it can't figure out how to do it.)
>
> BTW, you might also be interested in the command ones_matrix:
>
> sage: ones_matrix(ZZ,3,4)
> [1 1 1 1]
> [1 1 1 1]
> [1 1 1 1]
>
> 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.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org


[sage-support] SageTeX, Numpy, and Verbatim Environment

2011-12-03 Thread Mark
I'm trying to represent Sage non-native elements in a LaTeX document
using SageTeX.  Sage generates the representation without complaint,
but the result does not compile properly on the second LaTeX step
(LaTeX-Sage-LaTeX*).  Latex complains about missing $ inserted.  I've
included a simple illustration below with a numpy array.

Thanks for any pointers.
Mark

\documentclass{article}
\usepackage{sagetex}

\begin{document}

\begin{sagesilent}
import numpy as np
npmatrix = np.matrix([[1,2],[3,4]])
sgmatrix = matrix([[1,2],[3,4]])
\end{sagesilent}

Below is the Sage representation of the matrix
\[
\sage{sgmatrix}
\]

Here is the numpy representation of the matrix.
\[
\sage{npmatrix}
\]
The above fails in LaTeX with the message: Missing \$ inserted.

Yet the generated code from the *.sout file seems to work just fine
(after removing a
few empty braces \{\}).
\[
\begin{array}{l}
\verb|[[1|\phantom{x}\verb|2]|\\
\phantom{x}\verb|[3|\phantom{x}\verb|4]]|
\end{array}
\]

\end{document}

-- 
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: Power series expansion

2011-12-03 Thread Anton Sherwood

On 2011-12-02 08:17, Julie wrote:

Unfortunately, having the Tayor series approach out, don't think it's
really appropriate for my problem afterall, as what I esentially need
to do is find the coefficientsof p^0*y^0, p, y, p^2*y etc in the
formula
(0.030*0.248244^y)y+0.05721*(0.248244^y)p +0.08838*(0.248244^y)

> [...]

Since this is not a polynomial in p and y, what does it mean to obtain 
the coefficients of p^j y^k *if not* those of something very similar to 
a Taylor series?


--
Anton Sherwood *\\* www.bendwavy.org *\\* www.zazzle.com/tamfang

--
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: matrix help

2011-12-03 Thread Justin C. Walker

On Dec 3, 2011, at 02:50 , Chappman wrote:

> Is it possible to make an entry in Q[i,j] equal to a entry in U[i,j]?
> I have to have the two functions separately for each matrix though
> just like my code above

Definitely.  You can do it roughly as your code snippets show, or there are 
built-in "short-cuts" depending on what you want to do.  Here are a few:

  Q=deepcopy(U)  # This copies everything

Note that
1. if you use this inside a procedure, you have to import the name:
   from copy import deepcopy
2. if you use copy instead of deepcopy, you don't get what you might expect.  
Try this:

Q=matrix(ZZ,6)
U=Q
U[1,1]=4
Q

The reason is that more complex data types are copied by "pointer" (for speed); 
the "deepcopy" procedure actually makes a full copy, while "copy" just copies 
structure pointers, while the data values are "shared" between the copies.

To find out more about using Sage as a program/scripting language, check out 
the documentation on  and .  Python 
is the language used by Sage.

Also, use expressions like "matrix?" to get on-line documentation on 
procedure/function/variable names; "??" gets both documentation and the code 
implementing the call (if possible; some built-in python things may not have 
code viewable).

Finally, the TAB after a string will try to show you known names that begin 
with the string.  If you type the full name of a class, followed by ".", and 
then TAB, you will get a list of associated "method", "class variable", and 
"instance variable" names.  You can then use the "?" to find out more.

HTH

Justin

--
Justin C. Walker, Curmudgeon at Large
Institute for the Absorption of Federal Funds
---
My wife 'n kids 'n dogs are gone,
I can't get Jesus on the phone,
But Ol' Milwaukee's Best is my best friend.
---


-- 
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] backend for matplotlib

2011-12-03 Thread Vasudev
I've installed sage from binaries for 64-bit for fedora , on my fedora 16
laptop , the default backend for matplotlib is set to be Agg , when i set
GTKAgg it says i need pyGTK 2.4 or something , do i have to install those
versions ?? don't tell me i need development versions of these libraries ,i
am able to use matplotlib on python 2.7 without any problem and any devel
libraries , installed through yum (fedora 16 versions) , I remember , i did
not face any such problem , when i did install sage 4.5 on my ubuntu box ,
is it a new bug or just another added inconvinience ,i found some old
threads about matplotlib backend error , the suggested answers were the
things i tried already none worked!! , what's the deal ??

am i better of installing from source ??

actually i wanted to do this (i have done this in past) , but i don't have
time , my lappy has to occupied for 3-4 hrs.

-- 
Vasudev

-- 
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: matrix help

2011-12-03 Thread Jason Grout

On 12/3/11 4:16 PM, Justin C. Walker wrote:

Q=matrix(ZZ,6)
U=Q
U[1,1]=4
Q



Uh, I thought you wanted to use copy, which actually does copy the matrix:


sage: Q=matrix(ZZ,2)
sage: U=copy(Q)
sage: U[1,1]=4
sage: U
[0 0]
[0 4]
sage: Q
[0 0]
[0 0]

You don't need to use deepcopy to copy a matrix.

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


Re: [sage-support] Re: matrix help

2011-12-03 Thread Justin C. Walker

On Dec 3, 2011, at 15:21 , Jason Grout wrote:

> On 12/3/11 4:16 PM, Justin C. Walker wrote:
>> Q=matrix(ZZ,6)
>> U=Q
>> U[1,1]=4
>> Q
> 
> 
> Uh, I thought you wanted to use copy, which actually does copy the matrix:
> 
> 
> sage: Q=matrix(ZZ,2)
> sage: U=copy(Q)
> sage: U[1,1]=4
> sage: U
> [0 0]
> [0 4]
> sage: Q
> [0 0]
> [0 0]
> 
> You don't need to use deepcopy to copy a matrix.

Yup; that was part of my learning curve for the day (see my sage-devel reply).

Justin

--
Justin C. Walker, Curmudgeon-At-Large, Director
Institute for the Enhancement of the Director's Income

The path of least resistance:
it's not just for electricity any more.




-- 
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] computing the cup-product in the cohomology of a simplicial complex

2011-12-03 Thread Felix Breuer
Hello everyone!

I would like to compute the cup-product of two chains in the cohomology of 
a simplicial complex.

What I have so far, is that I have the simplicial complex realized as a 
SimplicialComplex in sage and I can compute its cohomology groups. They 
are: {0: 0, 1: Z x Z, 2: Z^28, 3: Z^9}. What I would like to do, is to take 
two generators of the cohomology group in degree 1 and compute that their 
cup-product is non-trivial. What is the best way to do this?


As I gather from Trac issue 
#6102, 
I can't simply compute the cohomology ring, as this functionality is not 
yet implemented. So I have to do this by hand, but that's okay. AFAICT, 
there are two things I need to figure out.

1) How can I get my hands on two representatives of the generators of the 
first cohomology group? I am not sure, whether I can have sage compute 
these for me (see ticket 
#6100). 
If yes, how? If no, I could maybe construct these two by hand (as I "know" 
how my simplicial complex "looks"). But in what format do I have to 
construct these chains so that I can use them in step 2?

2) How can I compute coboundaries of chains in the cochain complex? I know 
that sage will give me the cochain complex induced by my simplicial complex 
including the (co)boundary maps. But how do I apply these coboundary maps 
to chains? What format do these chains need to have?


Sorry, if these questions are somewhat fuzzy, but I am new to sage. Thank 
you for any help you can give!

Best,
Felix

-- 
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] SageTeX, Numpy, and Verbatim Environment

2011-12-03 Thread Dan Drake
On Sat, 03 Dec 2011 at 09:16AM -0800, Mark wrote:
> I'm trying to represent Sage non-native elements in a LaTeX document
> using SageTeX.  Sage generates the representation without complaint,
> but the result does not compile properly on the second LaTeX step
> (LaTeX-Sage-LaTeX*).  Latex complains about missing $ inserted.  I've
> included a simple illustration below with a numpy array.

The first place to look for these kind of problems is the .sagetex.sout
file, which in this case, has

newlabel{@sageinline1}{{%
\begin{array}{l}
\verb|[[1|\phantom{x}\verb|2]|\\
\phantom{x}\verb|[3|\phantom{x}\verb|4]]|
\end{array}}{}{}{}{}}

What strikes me there is \verb -- verbatim stuff does not play nicely
as the argument to another command.

The problem here is that NumPy matrices emit goofy LaTeX code. As a
workaround, you should convert your NumPy matrices to Sage matrices.
Here's one way to do it; perhaps someone else knows a better way:

\sage{matrix(npmatrix.tolist())}


Dan

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


signature.asc
Description: Digital signature


[sage-support] Re: SageTeX, Numpy, and Verbatim Environment

2011-12-03 Thread Jason Grout

On 12/3/11 9:24 PM, Dan Drake wrote:

On Sat, 03 Dec 2011 at 09:16AM -0800, Mark wrote:

I'm trying to represent Sage non-native elements in a LaTeX document
using SageTeX.  Sage generates the representation without complaint,
but the result does not compile properly on the second LaTeX step
(LaTeX-Sage-LaTeX*).  Latex complains about missing $ inserted.  I've
included a simple illustration below with a numpy array.


The first place to look for these kind of problems is the .sagetex.sout
file, which in this case, has

newlabel{@sageinline1}{{%
\begin{array}{l}
\verb|[[1|\phantom{x}\verb|2]|\\
\phantom{x}\verb|[3|\phantom{x}\verb|4]]|
\end{array}}{}{}{}{}}

What strikes me there is \verb -- verbatim stuff does not play nicely
as the argument to another command.

The problem here is that NumPy matrices emit goofy LaTeX code. As a
workaround, you should convert your NumPy matrices to Sage matrices.
Here's one way to do it; perhaps someone else knows a better way:

\sage{matrix(npmatrix.tolist())}


The Sage matrix() command should be able to just take the numpy array 
and deal with it too (but not a numpy *matrix* object, which is probably 
something that should be added)


matrix(npmatrix.A)

should work.

( .A converts the matrix to a numpy array)

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] Re: computing the cup-product in the cohomology of a simplicial complex

2011-12-03 Thread John H Palmieri


On Saturday, December 3, 2011 6:15:03 PM UTC-8, Felix Breuer wrote:
>
> Hello everyone!
>
> I would like to compute the cup-product of two chains in the cohomology of 
> a simplicial complex.
>

Me too.
 

>
> What I have so far, is that I have the simplicial complex realized as a 
> SimplicialComplex in sage and I can compute its cohomology groups. They 
> are: {0: 0, 1: Z x Z, 2: Z^28, 3: Z^9}. What I would like to do, is to take 
> two generators of the cohomology group in degree 1 and compute that their 
> cup-product is non-trivial. What is the best way to do this?
>  
>

>
> As I gather from Trac issue 
> #6102, 
> I can't simply compute the cohomology ring, as this functionality is not 
> yet implemented. So I have to do this by hand, but that's okay. AFAICT, 
> there are two things I need to figure out.
>
> 1) How can I get my hands on two representatives of the generators of the 
> first cohomology group? I am not sure, whether I can have sage compute 
> these for me (see ticket 
> #6100). 
> If yes, how? If no, I could maybe construct these two by hand (as I "know" 
> how my simplicial complex "looks"). But in what format do I have to 
> construct these chains so that I can use them in step 2?
>

If you install the optional Sage package "chomp", then it should be able to 
give you representatives.  Type "sage -i chomp" (or while you're running 
Sage, I think "install_package('chomp')" should work).  Once you've 
installed chomp, do this:

sage: X = (your favorite simplicial complex)
sage: X.cohomology(generators=True)


> 2) How can I compute coboundaries of chains in the cochain complex? I know 
> that sage will give me the cochain complex induced by my simplicial complex 
> including the (co)boundary maps. But how do I apply these coboundary maps 
> to chains? What format do these chains need to have?
>

Actually, it might be better to do this:

sage: X = ...  # some simplicial complex
sage: C = X.chain_complex(cochain=True)  # its cochain complex
sage: print C._chomp_repr_()

This prints a basis for the cochains in each dimension, along with the 
coboundary of each element, but note that the dimensions are wrong.  Oops, 
just found a bug.  For example, if X only has 0-, 1-, and 2-simplices, then 
when you print C._chomp_repr_(), the elements which say they're in 
dimension 0 are actually in dimension 2, etc.: the chain complex is printed 
upside-down.

sage: C.homology(generators=True)

This should now print the cohomology groups along with generators for each 
one, as a vector in terms of the basis given in the previous step.  The 
chain complex itself is stored as a collection of matrices (representing 
the coboundary maps), so you can just multiply any vector of the 
appropriate dimension by the coboundary matrix to compute the coboundary.

Try this out and see if it's helpful.  Improving the simplicial complex 
stuff in Sage is on the to-do list, as you've observed.  Progress has been 
slow...

-- 
John

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