ruletest7.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import sympy.physics.mechanics as _me
  2. import sympy as _sm
  3. import math as m
  4. import numpy as _np
  5. x, y = _me.dynamicsymbols('x y')
  6. x_d, y_d = _me.dynamicsymbols('x_ y_', 1)
  7. e = _sm.cos(x)+_sm.sin(x)+_sm.tan(x)+_sm.cosh(x)+_sm.sinh(x)+_sm.tanh(x)+_sm.acos(x)+_sm.asin(x)+_sm.atan(x)+_sm.log(x)+_sm.exp(x)+_sm.sqrt(x)+_sm.factorial(x)+_sm.ceiling(x)+_sm.floor(x)+_sm.sign(x)
  8. e = (x)**2+_sm.log(x, 10)
  9. a = _sm.Abs(-1*1)+int(1.5)+round(1.9)
  10. e1 = 2*x+3*y
  11. e2 = x+y
  12. am = _sm.Matrix([e1.expand().coeff(x), e1.expand().coeff(y), e2.expand().coeff(x), e2.expand().coeff(y)]).reshape(2, 2)
  13. b = (e1).expand().coeff(x)
  14. c = (e2).expand().coeff(y)
  15. d1 = (e1).collect(x).coeff(x,0)
  16. d2 = (e1).collect(x).coeff(x,1)
  17. fm = _sm.Matrix([i.collect(x)for i in _sm.Matrix([e1,e2]).reshape(1, 2)]).reshape((_sm.Matrix([e1,e2]).reshape(1, 2)).shape[0], (_sm.Matrix([e1,e2]).reshape(1, 2)).shape[1])
  18. f = (e1).collect(y)
  19. g = (e1).subs({x:2*x})
  20. gm = _sm.Matrix([i.subs({x:3}) for i in _sm.Matrix([e1,e2]).reshape(2, 1)]).reshape((_sm.Matrix([e1,e2]).reshape(2, 1)).shape[0], (_sm.Matrix([e1,e2]).reshape(2, 1)).shape[1])
  21. frame_a = _me.ReferenceFrame('a')
  22. frame_b = _me.ReferenceFrame('b')
  23. theta = _me.dynamicsymbols('theta')
  24. frame_b.orient(frame_a, 'Axis', [theta, frame_a.z])
  25. v1 = 2*frame_a.x-3*frame_a.y+frame_a.z
  26. v2 = frame_b.x+frame_b.y+frame_b.z
  27. a = _me.dot(v1, v2)
  28. bm = _sm.Matrix([_me.dot(v1, v2),_me.dot(v1, 2*v2)]).reshape(2, 1)
  29. c = _me.cross(v1, v2)
  30. d = 2*v1.magnitude()+3*v1.magnitude()
  31. dyadic = _me.outer(3*frame_a.x, frame_a.x)+_me.outer(frame_a.y, frame_a.y)+_me.outer(2*frame_a.z, frame_a.z)
  32. am = (dyadic).to_matrix(frame_b)
  33. m = _sm.Matrix([1,2,3]).reshape(3, 1)
  34. v = m[0]*frame_a.x +m[1]*frame_a.y +m[2]*frame_a.z