On Tue, Jul 6, 2010 at 7:41 AM, Ryan Hinton <[email protected]> wrote: > On Jul 2, 4:25 pm, Burcin Erocal <[email protected]> wrote: >> On Fri, 2 Jul 2010 09:21:25 -0700 (PDT) >> >> Ryan Hinton <[email protected]> wrote: >> > Well, it's a little dangerous for someone (me) who doesn't really >> > understand how to *use* the tool to *design the interface* to the >> > tool. But since I'm rarely bothered by my own ignorance, I'll charge >> > ahead. :-) >> >> > After writing a long, detailed email, I realized it's probably better >> > to start a wiki page instead. See >> >> > <http://wiki.sagemath.org/symbolics/Indexedexpressions> >> >> > for my thoughts. Thanks for your help! >> >> The wiki page is a good idea. Thanks for taking the time to write your >> ideas up. >> >> Here is a patch with the first steps to use indexed expressions: >> >> http://sage.math.washington.edu/home/burcin/indexed_expression.patch >> >> I used the slice notation to denote dimensions. If you have a >> variable x, and you want an index with dimension 3, you write: >> >> sage: var('i') >> i >> sage: x[i:3] >> x.i >> >> Dimensions are not printed, but they are there. :) >> >> I'm afraid I don't understand what you expect sum() to do. We already >> have a sum() method for symbolic expressions. Please take that into >> account as well. >> >> Note that GiNaC cannot take derivatives of indexed expressions [1]. >> Perhaps this is a show stopper for you. >> >> [1]http://www.ginac.de/reference/classGiNaC_1_1indexed.html#a0c7f2f4501e... >> >> On a completely different note... I prefer to use the brackets to access >> the operands of an expression, instead of creating indexed expressions. >> There has been several complaints about not being able to access the >> operands lately, and I think this is the most natural way to do so. >> >> You will see that there is already a __getitem__() method in >> expression.pyx which was commented during the symbolics switch. I >> suggest we uncomment that and use a different method (.indexed()?) for >> the indexed expressions. >> >> Cheers, >> Burcin > > Thank you very much for your work. Your guess is correct: I need to > take derivatives. What I want is something like the following. > > sage: var('x, d, i, n') > sage: monomial = (x[i:n] ^ d[i:n]).product() # form a product of all > the x[i]^d[i] > sage: partial = monomial.derivative(x[i]) > > So ``partial`` should look something like > > d[i] * x[1]^d[1] * x[2]^d[2] * ... * x[i]^(d[i] - 1) * ... * x[n]^d[n] > > but I don't know how this would be calculated or displayed. Of > course, then I need to weight and sum several (another symbolic > dimension) of these monomials, take derivatives of these sums, etc. > > As for syntax, I think the slice syntax is clever and fairly > intuitive. I can also understand using brackets to access operands in > an expression. Personally, I think the brackets make more sense for > indexing, but they would probably see more use for operand access. It > wouldn't bother me to use an ``indexed()`` method instead. I would be > happy to review a patch to add either one.
I like the slice syntax as well. I think it'd be nice to reserve the __getitem__ notation for subscripts. - Robert -- To post to this group, send an email to [email protected] To unsubscribe from this group, send an email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org
