9

Leibniz's notation can just be a bit cluttering, especially in physics problems where time is the only variable that functions are being differentiated with respect to. Additionally, is it possible to not display the (t) for a function like x(t) with sympy still understanding that x is a function of t and treating it as such?

pixatlazaki
  • 572
  • 8
  • 19

1 Answers1

12

You can use the mechanics module, which was designed around Newtonian physics. In particular, dynamicssymbols will give you a symbol which implicitly depends on t.

In [10]: x, y = dynamicsymbols('x y')

In [11]: x
Out[11]: x(t)

By default, these will still print with the (t), but if you enable the mechanics printers, they will not.

In [1]: from sympy.physics.mechanics import dynamicsymbols, init_vprinting

In [2]: init_vprinting
Out[2]: <function sympy.physics.vector.printing.init_vprinting>

In [3]: init_vprinting()

In [4]: x
Out[4]: x

In [5]: t = sympy.Symbol('t')

In [6]: y.diff(t)
Out[6]: ẏ

Use init_vprinting instead of init_printing in whatever interactive environment you develop in, such as the IPython notebook (there are also functions like mpprint if you want to print things from a scrpt).

If you want to know more about the SymPy mechanics module, read the documentation, and also take a look at the tutorial from the 2014 SciPy conference.

user
  • 5,370
  • 8
  • 47
  • 75
asmeurer
  • 86,894
  • 26
  • 169
  • 240