ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 01 Jun 2015 23:39:24 -0500solving matrix equationhttps://ask.sagemath.org/question/26986/solving-matrix-equation/ Could anyone please tell me how to solve a matrix equation? In the following code I have an extremely complicated matrix O. But I know that the matrix O equals to P. (I'm deriving what textbook didn't and the textbook said that they are same.)
var('theta, phi, psi, omega_1, omega_2, omega_3, t, f, g, h') #Variables are defined.
theta=function('theta')(t); phi=function('phi')(t); psi=function('psi')(t);
R1=matrix([[cos(phi), sin(phi),0],[-sin(phi), cos(phi), 0],[0, 0, 1]])
R2=matrix([[1,0,0],[0, cos(theta), sin(theta)],[0, -sin(theta), cos(theta)]])
R3=matrix([[cos(psi),sin(psi),0],[-sin(psi),cos(psi),0],[0,0,1]])
P=matrix([[0,omega_3,-omega_2],[-omega_3, 0, omega_1],[omega_2, -omega_1, 0]])
R=R3*R2*R1
R_T=R.T; R_dev=R.derivative(t)
O=R_dev*R_T
view(O)
assuming that O==P, How can I obtain the omega_1, omega_2, omega_3 as function of theta, phi, psi, t?
Sat, 30 May 2015 08:59:56 -0500https://ask.sagemath.org/question/26986/solving-matrix-equation/Answer by FrédéricC for <p>Could anyone please tell me how to solve a matrix equation? In the following code I have an extremely complicated matrix O. But I know that the matrix O equals to P. (I'm deriving what textbook didn't and the textbook said that they are same.)</p>
<pre><code>var('theta, phi, psi, omega_1, omega_2, omega_3, t, f, g, h') #Variables are defined.
theta=function('theta')(t); phi=function('phi')(t); psi=function('psi')(t);
R1=matrix([[cos(phi), sin(phi),0],[-sin(phi), cos(phi), 0],[0, 0, 1]])
R2=matrix([[1,0,0],[0, cos(theta), sin(theta)],[0, -sin(theta), cos(theta)]])
R3=matrix([[cos(psi),sin(psi),0],[-sin(psi),cos(psi),0],[0,0,1]])
P=matrix([[0,omega_3,-omega_2],[-omega_3, 0, omega_1],[omega_2, -omega_1, 0]])
R=R3*R2*R1
R_T=R.T; R_dev=R.derivative(t)
O=R_dev*R_T
view(O)
</code></pre>
<p>assuming that O==P, How can I obtain the omega_1, omega_2, omega_3 as function of theta, phi, psi, t?</p>
https://ask.sagemath.org/question/26986/solving-matrix-equation/?answer=26991#post-id-26991 Use this to simplify the matrix:
O.parent()([x.full_simplify() for x in O.list()])
Then omega_i will just be the coefficients of this simplified matrix.
**EDIT:**
The command t.full_simplify() tries to simplify t as much as possible and return the result. The rest of the line is the application to the list of matrix coefficients O.list(), and then rebuilding the matrix ; O.parent() is the space of matrices of the correct size over the correct ring. This matrix space can swallow the list and give back a matrix. This could also be done more simply using
O.apply_map(lambda t:t.full_simplify())
Sun, 31 May 2015 04:46:38 -0500https://ask.sagemath.org/question/26986/solving-matrix-equation/?answer=26991#post-id-26991Comment by Nownuri1 for <p>Use this to simplify the matrix:</p>
<pre><code>O.parent()([x.full_simplify() for x in O.list()])
</code></pre>
<p>Then omega_i will just be the coefficients of this simplified matrix.</p>
<p><strong>EDIT:</strong></p>
<p>The command t.full_simplify() tries to simplify t as much as possible and return the result. The rest of the line is the application to the list of matrix coefficients O.list(), and then rebuilding the matrix ; O.parent() is the space of matrices of the correct size over the correct ring. This matrix space can swallow the list and give back a matrix. This could also be done more simply using</p>
<pre><code>O.apply_map(lambda t:t.full_simplify())
</code></pre>
https://ask.sagemath.org/question/26986/solving-matrix-equation/?comment=27003#post-id-27003I appreciate for your answer. It works perfectly. But could you please let me know what the code means? The 'parent()()' and 'x.full_simplify()'?Mon, 01 Jun 2015 23:39:24 -0500https://ask.sagemath.org/question/26986/solving-matrix-equation/?comment=27003#post-id-27003