Created
November 16, 2020 17:19
-
-
Save Rhyssmcm/1391a36c1d502808ecfb582f941a65cc to your computer and use it in GitHub Desktop.
(Q1)Use Python to show that the partial derivatives of φ and ψ defined in (3.2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sympy as sym | |
m, ell, x3, x4, M, g, F, m = sym.symbols('m, ell, x3, x4, M, g, F, m') | |
# φ(F, x3, x4) | |
phi = 4*m*ell*x4**2*sym.sin(x3) + 4*F - 3*m*g*sym.sin(x3)*sym.cos(x3) | |
phi /= 4*(M+m) - 3*m*sym.cos(x3)**2 | |
dphi_x3 = phi.diff(x3) | |
dphi_x4 = phi.diff(x4) | |
dphi_F = phi.diff(F) | |
psi = -3*(m*ell*x4**2*sym.sin(x3)*sym.cos(x3) + F*sym.cos(x3) - (M+m)*g*sym.sin(x3)) | |
psi /= (4*(M+m) - 3*m*sym.cos(x3)**2)*ell | |
dpsi_x3 = psi.diff(x3) | |
dpsi_x4 = psi.diff(x4) | |
dpsi_F = psi.diff(F) | |
# Equilibrium point | |
Feq = 0 | |
x3eq = 0 | |
x4eq = 0 | |
dphi_F_eq = dphi_F.subs([(F, Feq), (x3, x3eq), (x4, x4eq)]) | |
dphi_x3_eq = dphi_x3.subs([(F, Feq), (x3, x3eq), (x4, x4eq)]) | |
dphi_x4_eq = dphi_x4.subs([(F, Feq), (x3, x3eq), (x4, x4eq)]) | |
dpsi_F_eq = dpsi_F.subs([(F, Feq), (x3, x3eq), (x4, x4eq)]) | |
dpsi_x3_eq = dpsi_x3.subs([(F, Feq), (x3, x3eq), (x4, x4eq)]) | |
dpsi_x4_eq = dpsi_x4.subs([(F, Feq), (x3, x3eq), (x4, x4eq)]) | |
sym.pprint(dphi_F_eq) | |
sym.pprint(dphi_x3_eq) | |
sym.pprint(dphi_x4_eq) | |
sym.pprint(dpsi_F_eq) | |
sym.pprint(dpsi_x3_eq) | |
sym.pprint(dpsi_x4_eq) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment