Oops - except the m \ddot{x} formats properly in the notebook.

On Thursday, August 14, 2014 11:09:08 AM UTC-7, Rathmann wrote:
>
> Thanks a lot!  It turned out that init_vprinting() gives the behavior I 
> wanted.
>
> In case others want to go down this path, I am appending a minimal 
> notebook entry which shows the syntax.  I am really impressed that diff(L, 
> xdot) just works, and that I can use solve to get algebraic expressions for 
> velocities and accelerations.
>
> One additional question - is there a better way to get the time variable 
> than  dynamicsymbols._t ?  I look at that leading underscore as an 
> indication that I shouldn't be touching it from user code.
>
> ------------------
>
> In [1]:
>
> from sympy.physics.vector import dynamicsymbols
> from sympy import diff, symbols, S
> from sympy.physics.vector import init_vprinting
>  
> init_vprinting()
>  
> # Simplest test case .. particle of mass m in uniform gravitational field g
> x = dynamicsymbols('x')
> t = dynamicsymbols._t
> xdot = diff(x,t)
> m, g = symbols('m g')
>  
> T = (m * xdot**2)/S(2) #kinetic energy
> V = m*g*x # potential energy is just mgh
> L = T - V
>  
> #Euler-Lagrange equation
> diff(L, xdot,t) - diff(L,x)
>
>
> Out[1]:
> gm+mx¨
>
>
>
>
>
> On Wednesday, August 13, 2014 10:24:47 PM UTC-7, Jason Moore wrote:
>>
>> Oh, you should use
>>
>> sympy.physics.vector.init_printing() 
>>
>> If you want the dot notation in latex in your notebooks.
>>
>>
>> Jason
>> moorepants.info
>> +01 530-601-9791
>>
>>
>> On Wed, Aug 13, 2014 at 10:23 PM, Jason Moore <moore...@gmail.com> wrote:
>>
>>> You can subclass a printer and have it do what you want. You can see 
>>> here:
>>>
>>>
>>> https://github.com/sympy/sympy/blob/master/sympy/physics/vector/printing.py#L145
>>>
>>> where we subclass the latex printer and get the \dot{} notation for 
>>> derivatives, for example. There is also an example here:
>>>
>>> http://docs.sympy.org/dev/modules/printing.html
>>>
>>> of subclassing to do custom derivative printing. Maybe exactly what you 
>>> want.
>>>
>>> The LagrangesMethod in sympy.physics.mechanics works with the classes 
>>> available in that package (RigidBody, ReferemceFrame, etc). The other one 
>>> is more basic math. So if you want to write all the math yourself then 
>>> maybe the later is preferable, but if you want to use the objects in 
>>> sympy.physics.mechanics to build up a rigid body system and find the 
>>> equations of motion, the use the former.
>>>
>>>
>>> Jason
>>> moorepants.info
>>> +01 530-601-9791
>>>  
>>>
>>> On Wed, Aug 13, 2014 at 10:13 PM, Rathmann <rathm...@gmail.com> wrote:
>>>
>>>> Hello,
>>>>
>>>> I have been watching the lectures of Susskind's "Theoretical Minimum" 
>>>> course, and using Sympy with IPython notebook to take notes, and work 
>>>> through some of the examples.
>>>>
>>>> Sympy is serious overkill for this purpose, but overall it has been 
>>>> working well.
>>>>
>>>> A couple of questions:
>>>>
>>>>    - What is the best way to deal with dynamics variables and the dot 
>>>>    convention for printing? (In physics, the first time derivative of x is 
>>>>    often written as \dot{x} instead of dx/dt.)  Is there an easy way 
>>>>    to get IPython notebook to print dynamics variables using the dot 
>>>>    convention, and still give the nice LaTeX-rendered equations?  If I use 
>>>>    vprint (from physics.vector), I get the variables  with primes, but 
>>>> just a 
>>>>    text rendering of the equations. 
>>>>    - I notice sympy.physics.mechanics.LagrangesMethod and 
>>>>    sympy.calculus.euler.euler_equations both implement Lagrangian 
>>>> mechanics. 
>>>>    Is one of these more "official"  than the other?  Both seem to work for 
>>>> the 
>>>>    very simple examples I have tried. 
>>>>
>>>> Thanks
>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "sympy" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to sympy+un...@googlegroups.com.
>>>> To post to this group, send email to sy...@googlegroups.com.
>>>> Visit this group at http://groups.google.com/group/sympy.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/sympy/fe1737e3-3b19-40e5-8983-5d64bfad8e2f%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/sympy/fe1737e3-3b19-40e5-8983-5d64bfad8e2f%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/2cc6e324-d82d-4210-a1aa-46f99ffc5d12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to