x with a dot above instead of dx/dt when differentiating

Viewed 24

Is there a way to change the expression for derivatives when using SymPy in Python?

from sympy import * 
x, t = symbols('x t')
expr_diff = Derivative(x, t)

In my code, expr_diff gives dx/dt. However, I would rather get the derivative of x with respect to t expressed as (x with a dot above).

1 Answers

There is a way to change it, but it requires to use the sympy.physics.mechanics package:

from sympy import *
from sympy.physics.mechanics import init_vprinting

# this is responsible to visualize time derivatives with dots
init_vprinting()

# then you need to define x as a functions of time
t = symbols("t")
x = Function("x")(t)

# Now you can visualize derivatives with dots
Derivative(x, t)
Related