Coefficent Matrix in Python - Group elements -
i have obtatained matrix in python using sympy:
> matrix([[-theta*l*m2*omega**2*cos(omega*t) + x*k*cos(omega*t) - > x*omega**2*(m1 + m2)*cos(omega*t)], [theta*g*cos(omega*t) - > theta*l*omega**2*cos(omega*t) - x*omega**2*cos(omega*t)]])
i need find expression like:
[coefficient matrix]*(unknowns vectors)
where (unknowns vector) is:
matrix([[x],[theta]]).
i tried use solve, simplify , collect sympy without success (i can errors or [] return).
take jacobian:
in [16]: a.jacobian(matrix([x, theta])) out[16]: ⎡ 2 2 ⎤ ⎢k⋅cos(ω⋅t) - ω ⋅(m₁ + m₂)⋅cos(ω⋅t) -l⋅m₂⋅ω ⋅cos(ω⋅t) ⎥ ⎢ ⎥ ⎢ 2 2 ⎥ ⎣ -ω ⋅cos(ω⋅t) g⋅cos(ω⋅t) - l⋅ω ⋅cos(ω⋅t)⎦ in [17]: a.jacobian(matrix([x, theta]))*matrix([x, theta]) out[17]: ⎡ 2 ⎛ 2 ⎞⎤ ⎢- theta⋅l⋅m₂⋅ω ⋅cos(ω⋅t) + x⋅⎝k⋅cos(ω⋅t) - ω ⋅(m₁ + m₂)⋅cos(ω⋅t)⎠⎥ ⎢ ⎥ ⎢ ⎛ 2 ⎞ 2 ⎥ ⎣ theta⋅⎝g⋅cos(ω⋅t) - l⋅ω ⋅cos(ω⋅t)⎠ - x⋅ω ⋅cos(ω⋅t) ⎦ in [22]: out[22]: ⎡ 2 2 ⎤ ⎢- theta⋅l⋅m₂⋅ω ⋅cos(ω⋅t) + x⋅k⋅cos(ω⋅t) - x⋅ω ⋅(m₁ + m₂)⋅cos(ω⋅t)⎥ ⎢ ⎥ ⎢ 2 2 ⎥ ⎣ theta⋅g⋅cos(ω⋅t) - theta⋅l⋅ω ⋅cos(ω⋅t) - x⋅ω ⋅cos(ω⋅t) ⎦
by way, if use theta
or theta
(not uppercase), sympy print actual greek letter theta:
in [24]: symbols('theta') out[24]: θ
Comments
Post a Comment