<jupyter_start><jupyter_text>I assume Spong angles are $\theta_1$ and $\theta_2$.<jupyter_code>from __future__ import print_function, division
from sympy import *
init_printing(use_unicode=True)
m1, l1, lc1, I1, theta1, theta1dot = symbols('m1 l1 l_{c1} I1 theta1 thetadot1')
m2, lc2, I2, theta2, theta2dot = symbols('m2 l_{c2} I2 theta2 thetadot2')
M = Matrix([[m2*l1*(l1+2*lc2*cos(theta2))+I1+I2,
             m2*l1*lc2*cos(theta2)+I2],
            [m2*l1*lc2*cos(theta2)+I2,
             I2]])
M
C = Matrix([[-2*m2*l1*lc2*sin(theta2)*theta2dot,
             -m2*l1*lc2*sin(theta2)*theta2dot],
            [m2*l1*lc2*sin(theta2)*theta1dot,
             0]])
C
g = symbols('g')
G = g*Matrix([[-m1*lc1*sin(theta1)-m2*(l1*sin(theta1)+lc2*sin(theta1+theta2))],
              [-m2*lc2*sin(theta1+theta2)]])
G<jupyter_output><empty_output><jupyter_text>Now, let's change the notations to the one that Russ used [here](http://underactuated.csail.mit.edu/underactuated.html?chapter=acrobot) by having ${}^{\texttt{Russ}}I={}^{\texttt{Spong}}I+ml_c^2$ and ${}^{\texttt{Russ}}\theta_1={}^{\texttt{Spong}}\theta_1+\pi/2$<jupyter_code>q1, q1dot = symbols('q1 q1dot')
q2, q2dot = symbols('q2 q2dot')
M.subs([(I1,I1+m1*lc1**2), (I2,I2+m2*lc2**2), 
        (theta1,q1+pi/2), (theta2,q2)])
C.subs([(I1,I1+m1*lc1**2), (I2,I2+m2*lc2**2),
        (theta1,q1+pi/2), (theta2,q2)])
G.subs([(I1,I1+m1*lc1**2), (I2,I2+m2*lc2**2),
        (theta1,q1+pi/2), (theta2,q2)])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.21868652674339878, 'fraction_numerical': 0.08801624915368991, 'mean_word_length': 5.057377049180328, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '456728', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 713, 'n_tokens_neox': 701, 'n_words': 91, 'path': 'src/2.1_LQR/Spong-Russ-equivalence.ipynb', 'repo_name': 'atabakd/MuJoCo-Tutorials', 'size': '1477'}