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

Reply via email to