IndexeFunction

89 views
Skip to first unread message

Guillaume Anciaux

unread,
Feb 10, 2015, 12:43:05 PM2/10/15
to sy...@googlegroups.com
Dear all,

I am interested in doing a small thing (perhaps).

I wish to have an 'indexed function'

The purpose would be to have something like
**************
f = symbols('f', cls=IndexedFunction)
i = Idx('i')
print diff(f[i](x),x)
**************

I cannot compute derivatives if the dependency to x is not provided.

1) Can it be done ?
2) Is this a proper way to asses derivatives of vector/tensor fields and associated derivatives ?

Thanks in advance for your help.




Aaron Meurer

unread,
Feb 10, 2015, 4:38:52 PM2/10/15
to sy...@googlegroups.com
I think it would be useful.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/edb80c92-f0e9-4cab-ac39-18a239c9a650%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Kalevi Suominen

unread,
Feb 10, 2015, 5:32:47 PM2/10/15
to sy...@googlegroups.com

Technically an index is just another argument, though it often takes only a finite number of values.
Would it be possible to use functions like f(i, x)?

Aaron Meurer

unread,
Feb 10, 2015, 8:34:18 PM2/10/15
to sy...@googlegroups.com
Yes, I think pretty much all uses of Indexed can be replaced with a
multiargument function, but it helps to think about some things as an
index rather than an argument of a function, so I'm in support of
improving Indexed to work better.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/8410e258-0998-4d65-baba-d3cde66cf283%40googlegroups.com.

Guillaume Anciaux

unread,
Feb 11, 2015, 9:13:33 AM2/11/15
to sy...@googlegroups.com
That is true that if you can replace indexes with a multiple argument function. But an index is an integer not a real.
Furthermore the feature that makes indexed quantity behave just like a numpy array is neat.

I think that when you manipulate a tensor/matrix field it would be nice be be able to do algebra.

I also noticed that you cannot differentiate with respect to an indexed value:
***************************************************
f = IndexedBase('f')

i = Idx('i')
diff(f[i]**2,f[i])

>> Can't differentiate wrt the variable: f[i], 1

****************************************************

So, I understand that the idea is pleasant. Someone willing to extend indexes ? Otherwise, how can I help ? Do you have pointers to the ways indexes are working ?

Thanks

Guillaume


Francesco Bonazzi

unread,
Feb 11, 2015, 10:47:17 AM2/11/15
to sy...@googlegroups.com


On Tuesday, February 10, 2015 at 1:43:05 PM UTC+1, Guillaume Anciaux wrote:
Dear all,

I am interested in doing a small thing (perhaps).

I wish to have an 'indexed function'

The purpose would be to have something like
**************
f = symbols('f', cls=IndexedFunction)
i = Idx('i')
print diff(f[i](x),x)
**************


This is a bit out of topic, but there's another open source CAS which deals very well with indexed objects:
http://redberry.cc/

Guillaume Anciaux

unread,
Feb 11, 2015, 11:07:36 AM2/11/15
to sy...@googlegroups.com
For various reasons I wish to stay in Python world...

Francesco Bonazzi

unread,
Feb 11, 2015, 11:57:20 AM2/11/15
to sy...@googlegroups.com

On Wednesday, February 11, 2015 at 10:13:33 AM UTC+1, Guillaume Anciaux wrote:

So, I understand that the idea is pleasant. Someone willing to extend indexes ? Otherwise, how can I help ? Do you have pointers to the ways indexes are working ?


I am slowly developing the code in sympy.tensor.tensor, which is meant to be much more powerful than the indexed quantities. There's still a lot to do, unfortunately.

Anyways, if you are willing to help, you're more than welcome!

Joachim Durchholz

unread,
Feb 11, 2015, 2:05:27 PM2/11/15
to sy...@googlegroups.com
Am 11.02.2015 um 12:07 schrieb Guillaume Anciaux:
> For various reasons I wish to stay in Python world...

You can still look at how they're dealing with it and see how their
ideas may apply in the Python world.

Francesco Bonazzi

unread,
Feb 11, 2015, 2:29:53 PM2/11/15
to sy...@googlegroups.com

Redberry is written in Java, which has no REPL and no operator overloading. They solved these issues by providing bindings to Groovy, which is somewhat a sort of scripted version of Java, extending Java to support a REPL and operator overloading.

Their code is really interesting, they have already implemented many cases of manipulations of indexed quantities, including derivatives, derivatives of summations of indexed quantities, valence-sensitivity (i.e. covariant vs contravariant indices).

They suggest to use IntelliJ IDEA as an IDE to work with Redberry, its great advantage over IPython is the ability to search for class locations and automatically import them. For the rest I prefer IPython notebook.

Jorge Ramos

unread,
Feb 15, 2024, 10:55:33 AM2/15/24
to sympy
So, after 8 beautiful years, is there a way to do this today?

I see posts regarding this very issue in GitHub, StackOverflow, everywhere!
Reply all
Reply to author
Forward
0 new messages