Reputation: 407
I'm trying to get an indefinite integral from sympy, but it is not actually solving it. I just get the input expression repeated. Here is the setup:
rt = sympy.Matrix([t**2, sympy.cos(t)+t*sympy.sin(t),sympy.sin(t)-t*sympy.cos(t)])
vt = sympy.diff(rt)
vt_norm = vt.norm()
vt_int = sympy.integrate(vt_norm, t)
print("position function:")
display(rt)
print("velocity function:")
display(vt)
print("velocity norm")
display(vt_norm)
print("vt_integrate")
display(vt_int)
print("vt_integrate , do_it")
display(vt_int.doit())
Here is the output:
Any suggestions?
Upvotes: 2
Views: 315
Reputation: 14480
I presume t is real and if you explain that to sympy then it can give you a simpler result. The result can simplify further if t is positive:
In [11]: t = Symbol('t', real=True)
In [12]: rt = sympy.Matrix([t**2, sympy.cos(t)+t*sympy.sin(t),sympy.sin(t)-t*sympy.cos(t)])
...: vt = sympy.diff(rt)
...: vt_norm = vt.norm()
In [13]: vt_norm
Out[13]:
________________________________
╱ 2 2 2 2 2
╲╱ t ⋅sin (t) + t ⋅cos (t) + 4⋅t
In [14]: vt_norm.simplify()
Out[14]: √5⋅│t│
In [15]: vt_norm.simplify().integrate(t)
Out[15]:
⎧ 2
⎪-√5⋅t
⎪─────── for t ≤ 0
⎪ 2
⎨
⎪ 2
⎪ √5⋅t
⎪ ───── otherwise
⎩ 2
Upvotes: 4