Simon Hirscher
непрочитано,11. 9. 2014. 09:42:4611.9.14.Пријавите се да бисте одговорили аутору
Пријавите се да бисте проследили
Немате дозволу за брисање порука у овој групи
Пријавите се да бисте пријавили поруку
Прикажи оригиналну поруку
Имејл адресе су анонимне за ову групу или вам треба дозвола за преглед имејл адреса чланова да бисте видели оригиналну поруку
– sy...@googlegroups.com
Hi,
I'm working on an extension for sympy.diffgeom. Since expressions
often get very complicated in differential geometry, it sometimes
makes sense to e.g. simply keep a tensor as the indexed symbol it
is, sometimes one inserts its actual components' values (and
tries to simplify further). Put differently, my mathematical
objects (mostly tensors) carry names but also have values and I'd
like to let the user decide when he wants use what and enable him
to replace names by their values later on (without the need for
him to use replace()/subs() because this requires way too much
manual effort).
Basically, this is the analogy of the famous pitfall:
>>> x, y = symbols('x, y')
>>> y = x + 2
>>> x = 2
>>> y
x + 2
whereas I would actually like to provide a way to do exactly
this: Replace the symbol 'x' by its value later on.
(Obviously, this would allow lazy calculation of tensor
components. Hence, the user could build expressions involving
tensors without needing to calculate all of their components
first – after all, he might only need some of them.)
So: Are there any best practices in this regard or is there even
a general function in SymPy to expand/evaluate such abstract
symbols in terms of their (still abstract/non-numerical) values?
I imagine something like this:
>>> R[0, 1, 0, 1]
R_{0101}
>>> R[0, 1, 0, 1].expand() (or .eval()/.doit()/.compute() or something)
<some complicated expression in terms of coordinate functions>
Thank you for your time!