是否可以在 sympy 中实现牛顿点表示法(或拉格朗日素数表示法)? [英] Is it possible to implement Newton's Dot Notation (or Lagrange's Prime Notation) in sympy?

查看:64
本文介绍了是否可以在 sympy 中实现牛顿点表示法(或拉格朗日素数表示法)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Leibniz 的符号可能有点混乱,尤其是在物理问题中,时间是函数被微分的唯一变量.此外,是否可以不显示像 x(t) 这样的函数的 (t) 并且 sympy 仍然理解 x 是一个函数t 并如此对待它?

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?

推荐答案

您可以使用 力学模块,它是围绕牛顿物理学设计的.特别是,dynamicssymbols 会给你一个隐含依赖于 t 的符号.

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)

默认情况下,这些仍会使用 (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]: ẏ

在您开发的任何交互式环境中,例如 IPython notebook(也有像 mpprint 这样的函数,如果使用 init_vprinting 而不是 init_printing您想从 scrpt 打印内容).

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).

如果您想了解有关 SymPy 机制模块的更多信息,请阅读文档,并查看 教程 来自 2014 SciPy 会议.

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.

这篇关于是否可以在 sympy 中实现牛顿点表示法(或拉格朗日素数表示法)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆