Using sympy in python is substitute values into a 10x10 matrix

asked 2012-07-13 17:11:03 +0100

tuteinstein gravatar image

Hi,

I'm trying to substitute values into a symbolic 10X10 antisymmetric matrix in an iterative code. The symbolic expressions happen to be pretty complicated algebraic expressions (with some trig functions). I need to perform at least 10,000-20,000 iterations to get a meaningful result. But, it's taking too long to perform the substitution - like about 100 seconds per iteration. An example of what the expressions look like is:

(-1024 x1^18 (-1 + 3 Sqrt[3] x2 - 12 x2^2 + 9 Sqrt[3] x2^3 - 12 x2^4 + 3 Sqrt[3] x2^5 - x2^6) + 9216 x1^17 (Sqrt[3] - 9 x2 + 12 Sqrt[3] x2^2 - 27 x2^3 + 12 Sqrt[3] x2^4 - 9 x2^5 + Sqrt[3] x2^6) + 2048 x1^15 (Sqrt[3] (157 + 33 y1^2) - 9 x2 (157 + 34 y1^2) - 9 x2^5 (157 + 36 y1^2) + Sqrt[3] x2^6 (157 + 36 y1^2) - 9 x2^3 (471 + 106 y1^2) + 3 Sqrt[3] x2^2 (628 + 139 y1^2) + 3 Sqrt[3] x2^4 (628 + 143 y1^2)) - 256 x1^16 (-463 - 33 y1^2 + 3 Sqrt[3] x2 (463 + 34 y1^2) + 3 Sqrt[3] x2^5 (463 + 36 y1^2) - x2^6 (463 + 36 y1^2) + 3 Sqrt[3] x2^3 (1389 + 106 y1^2) - 3 x2^2 (1852 + 139 y1^2) - 3 x2^4 (1852 + 143 y1^2)) + 448 x1^13 (-27 x2 (1998 + 1400 y1^2 + 171 y1^4) - 18 x2^5 (2997 + 2224 y1^2 + 288 y1^4) + 2 Sqrt[3] x2^6 (2997 + 2224 y1^2 + 288 y1^4) + Sqrt[3] (5994 + 4076 y1^2 + 483 y1^4) + 12 Sqrt[3] x2^4 (5994 + 4417 y1^2 + 568 y1^4) + 9 Sqrt[3] x2^2 (7992 + 5724 y1^2 + 715 y1^4) - 18 x2^3 (8991 + 6548 y1^2 + 832 y1^4)) - 64 x1^14 (-28986 - 11996 y1^2 - 483 y1^4 + 9 Sqrt[3] x2 (9662 + 4120 y1^2 + 171 y1^4) + 6 Sqrt[3] x2^5 (14493 + 6544 y1^2 + 288 y1^4) - 2 x2^6 (14493 + 6544 y1^2 + 288 y1^4) - 12 x2^4 (28986 + 12997 y1^2 + 568 y1^4) - 9 x2^2 (38648 + 16844 y1^2 + 715 y1^4) + 6 Sqrt[3] x2^3 (43479 + 19268 y1^2 + 832 y1^4)) - (1 + y1^2)^4 (3 + 4 y1^2)^2 (-27 (1 + y1^2)^3 + 27 Sqrt[3] x2 (1 + y1^2)^2 (3 + 4 y1^2) + 3 Sqrt[3] x2^5 (3 + 4 y1^2)^3 - x2^6 (3 + 4 y1^2)^3 - 9 x2^4 (3 + 4 y1^2)^2 (4 + 5 y1^2) + 3 Sqrt[3] x2^3 (3 + 4 y1^2)^2 (9 + 10 y1^2) - 27 x2^2 (12 + 43 y1^2 + 51 y1^4 + 20 y1^6)) + 96 x1^11 (-18 x2^5 (42629 + 64876 y1^2 + 27104 y1^4 + 2688 y1^6) + 2 Sqrt[3] x2^6 (42629 + 64876 y1^2 + 27104 y1^4 + 2688 y1^6) + Sqrt[3] (85258 ... (more)

edit retag flag offensive close merge delete