增加对变量的时间依赖性

时间:2019-07-03 12:51:46

标签: python-3.x sympy physics

我试图增加对变量的时间依赖性。我已经使用sympy定义了变量(theta和theta_dot)。在计算偏导数时没有问题,但是在计算相对于时间的总导数时遇到麻烦。

我正在处理的方程式是Euler Lagrange方程式。

enter image description here

我用过sympy

<html>
<head>
<meta charset="utf-8">
<title>Lightbox Example</title>
<link rel="stylesheet" href="css/lightbox.css">
</head>
<body>
<section>
    <div>
    <a class="example-image-link" href="http://lokeshdhakar.com/projects/lightbox2/images/image-3.jpg" data-lightbox="example-set" data-title="Click the right half of the image to move forward."><img class="example-image" src="http://lokeshdhakar.com/projects/lightbox2/images/thumb-3.jpg" alt=""/></a>
    <a class="example-image-link" href="http://lokeshdhakar.com/projects/lightbox2/images/image-4.jpg" data-lightbox="example-set" data-title="Or press the right arrow on your keyboard."><img class="example-image" src="http://lokeshdhakar.com/projects/lightbox2/images/thumb-4.jpg" alt="" /></a>
    <a class="example-image-link" href="http://lokeshdhakar.com/projects/lightbox2/images/image-5.jpg" data-lightbox="example-set" data-title="The next image in the set is preloaded as you're viewing."><img class="example-image" src="http://lokeshdhakar.com/projects/lightbox2/images/thumb-5.jpg" alt="" /></a>
    <a class="example-image-link" href="http://lokeshdhakar.com/projects/lightbox2/images/image-6.jpg" data-lightbox="example-set" data-title="Click anywhere outside the image or the X to the right to close."><img class="example-image" src="http://lokeshdhakar.com/projects/lightbox2/images/thumb-6.jpg" alt="" /></a>
    </div>
</section>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>

<script src="js/lightbox.js"></script>
</body>
</html>

diff(L,theta)

查找偏导数。

理想情况下,我想知道一种将时间导数整合到方程中的好方法。

1 个答案:

答案 0 :(得分:0)

您可以在sympy中使用dynamicsymbols。

list_of_variables=[dynamicsymbols("theta"),dynamicsymbols("theta",1)]

f = diff(diff(i, list_of_variables[1]), 't') - diff(i, list_of_variables[0])

这是类似的帖子。

https://math.stackexchange.com/questions/3014868/euler-lagrange-formalism-with-sympy