Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

'm using the symbolic package sympy to store a 10X10 antisymmetric matrix in terms of 10 variables. and then at every iteration step, i substitute numerical values into the entries of the matrix. however, it's taking too long to substitute values because the symbolic expressions are very complicated. It takes around 100 seconds for the every substitution and I need at least 10,000 iterations to get a meaningful result.

So, I was wondering whether there is any speedy way to substitute the values. Right now, I'm just substituting values into the top diagonal half of the matrix, which halves the number of substitutions, but it's still taking too long.

Thanks!

share|improve this question
    
It's perfectly okay to ask here. Another place you might ask is at ask.sagemath.org. Sage is built on Python and it has sympy built into it as well. Therefore, the percentage of users there that might use this same software would be much higher. If nothing else, maybe using Sage itself is better. I have no idea, but they could tell you there. Also, you'd probably want to provide a bit more detail... what formulas (at least one example). –  Graphth Jul 13 '12 at 19:48
2  
This issue does not look like it has much to do with the matrix. You want to evaluate 45 complicated expressions 10000 times. It is natural to look at those 45 expressions to see if they have common parts, and if they do, eliminate the repetition. –  user31373 Jul 13 '12 at 20:37
1  
If you provide more information about the matrix you're trying to generate and what it's entries are supposed to mean, perhaps people here could help with a more direct attack on speeding it up? –  Nick Alger Jul 18 '12 at 21:26
    
Can you do the computation numerically instead of symbolically? –  Hurkyl Dec 31 '12 at 1:23

1 Answer 1

If the elements do indeed contain common terms or subexpressions, then you can use the cse() function to help you eliminate them, so you only do repetitive evaluations once.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.