Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

lagranian mechanics

I'm working on using sage to help with the Euler-Lagrange equation in my mechanics class. I have this worked up so far for a simple pendulum.

var('m,l,g,th,thdot,thdotdot,t') th = function('th',t) thdot = th.diff(t) thdotdot = thdot.diff(t) L = 1/2ml^2thdot^2 - mgl(1-cos(th)) diff(L,thdot)

but that gives off the error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_23.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -- coding: utf-8 --\n" + _support_.preparse_worksheet_cell(base64.b64decode("dmFyKCdtLGwsZyx0aCx0aGRvdCx0aGRvdGRvdCx0JykKdGggPSBmdW5jdGlvbigndGgnLHQpCnRoZG90ID0gdGguZGlmZih0KQp0aGRvdGRvdCA9IHRoZG90LmRpZmYodCkKTCA9IDEvMiptKmxeMip0aGRvdF4yIC0gbSpnKmwqKDEtY29zKHRoKSkKZGlmZihMLHRoZG90KQ=="),globals())+"\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in <module>

File "/tmp/tmpTPoOKC/___code___.py", line 8, in <module> exec compile(u'diff(L,thdot) File "", line 1, in <module>

File "/home/eric/sage/local/lib/python2.6/site-packages/sage/calculus/functional.py", line 130, in derivative return f.derivative(args, *kwds) File "expression.pyx", line 2502, in sage.symbolic.expression.Expression.derivative (sage/symbolic/expression.cpp:11917) File "derivative.pyx", line 216, in sage.misc.derivative.multi_derivative (sage/misc/derivative.c:2191) File "expression.pyx", line 2570, in sage.symbolic.expression.Expression._derivative (sage/symbolic/expression.cpp:12263) TypeError: argument symb must be a symbol

I don't have any idea what all this means other than I'm guessing it doesn't like that I am trying to take the derivative with respect to a function?

Any help would be appreciated.

lagranian mechanics

I'm working on using sage to help with the Euler-Lagrange equation in my mechanics class. I have this worked up so far for a simple pendulum.

var('m,l,g,th,thdot,thdotdot,t') var('m,l,g,th,thdot,thdotdot,t')

th = function('th',t) function('th',t)

thdot = th.diff(t) th.diff(t)

thdotdot = thdot.diff(t) thdot.diff(t)

L = 1/2ml^2thdot^2 - mgl(1-cos(th)) (1-cos(th))

diff(L,thdot)

but that gives off the error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_23.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -- coding: utf-8 --\n" + _support_.preparse_worksheet_cell(base64.b64decode("dmFyKCdtLGwsZyx0aCx0aGRvdCx0aGRvdGRvdCx0JykKdGggPSBmdW5jdGlvbigndGgnLHQpCnRoZG90ID0gdGguZGlmZih0KQp0aGRvdGRvdCA9IHRoZG90LmRpZmYodCkKTCA9IDEvMiptKmxeMip0aGRvdF4yIC0gbSpnKmwqKDEtY29zKHRoKSkKZGlmZihMLHRoZG90KQ=="),globals())+"\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in <module>

File "/tmp/tmpTPoOKC/___code___.py", line 8, in <module> exec compile(u'diff(L,thdot) File "", line 1, in <module>

File "/home/eric/sage/local/lib/python2.6/site-packages/sage/calculus/functional.py", line 130, in derivative return f.derivative(args, *kwds) File "expression.pyx", line 2502, in sage.symbolic.expression.Expression.derivative (sage/symbolic/expression.cpp:11917) File "derivative.pyx", line 216, in sage.misc.derivative.multi_derivative (sage/misc/derivative.c:2191) File "expression.pyx", line 2570, in sage.symbolic.expression.Expression._derivative (sage/symbolic/expression.cpp:12263) TypeError: argument symb must be a symbol

I don't have any idea what all this means other than I'm guessing it doesn't like that I am trying to take the derivative with respect to a function?

Any help would be appreciated.

click to hide/show revision 3
Fixed formatting.

lagranian mechanics

I'm working on using sage to help with the Euler-Lagrange equation in my mechanics class. I have this worked up so far for a simple pendulum.

var('m,l,g,th,thdot,thdotdot,t')

var('m,l,g,th,thdot,thdotdot,t')
th = function('th',t)

function('th',t) thdot = th.diff(t)

th.diff(t) thdotdot = thdot.diff(t)

thdot.diff(t) L = 1/2ml^2thdot^2 1/2*m*l^2*thdot^2 - mgl(1-cos(th))

diff(L,thdot)

m*g*l*(1-cos(th)) diff(L,thdot)

but that gives off the error: error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_23.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -- -*- coding: utf-8 --\n" -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("dmFyKCdtLGwsZyx0aCx0aGRvdCx0aGRvdGRvdCx0JykKdGggPSBmdW5jdGlvbigndGgnLHQpCnRoZG90ID0gdGguZGlmZih0KQp0aGRvdGRvdCA9IHRoZG90LmRpZmYodCkKTCA9IDEvMiptKmxeMip0aGRvdF4yIC0gbSpnKmwqKDEtY29zKHRoKSkKZGlmZihMLHRoZG90KQ=="),globals())+"\n"); _support_.preparse_worksheet_cell(base64.b64decode("dmFyKCdtLGwsZyx0aCx0aGRvdCx0aGRvdGRvdCx0JykKdGggPSBmdW5jdGlvbigndGgnLHQpCnRoZG90ID0gdGguZGlmZih0KQp0aGRvdGRvdCA9IHRoZG90LmRpZmYodCkKTCA9IDEvMiptKmxeMip0aGRvdF4yIC0gbSpnKmwqKDEtY29zKHRoKSkKZGlmZihMLHRoZG90KQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>

<module> File "/tmp/tmpTPoOKC/___code___.py", line 8, in <module> exec compile(u'diff(L,thdot) File "", line 1, in <module>

<module> File "/home/eric/sage/local/lib/python2.6/site-packages/sage/calculus/functional.py", line 130, in derivative return f.derivative(args, *kwds) f.derivative(*args, **kwds) File "expression.pyx", line 2502, in sage.symbolic.expression.Expression.derivative (sage/symbolic/expression.cpp:11917) File "derivative.pyx", line 216, in sage.misc.derivative.multi_derivative (sage/misc/derivative.c:2191) File "expression.pyx", line 2570, in sage.symbolic.expression.Expression._derivative (sage/symbolic/expression.cpp:12263) TypeError: argument symb must be a symbol

symbol

I don't have any idea what all this means other than I'm guessing it doesn't like that I am trying to take the derivative with respect to a function?

Any help would be appreciated.

click to hide/show revision 4
retagged

lagranian mechanics

I'm working on using sage to help with the Euler-Lagrange equation in my mechanics class. I have this worked up so far for a simple pendulum.

var('m,l,g,th,thdot,thdotdot,t')
th = function('th',t)
thdot = th.diff(t)
thdotdot = thdot.diff(t)
L = 1/2*m*l^2*thdot^2 - m*g*l*(1-cos(th))
diff(L,thdot)

but that gives off the error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_23.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("dmFyKCdtLGwsZyx0aCx0aGRvdCx0aGRvdGRvdCx0JykKdGggPSBmdW5jdGlvbigndGgnLHQpCnRoZG90ID0gdGguZGlmZih0KQp0aGRvdGRvdCA9IHRoZG90LmRpZmYodCkKTCA9IDEvMiptKmxeMip0aGRvdF4yIC0gbSpnKmwqKDEtY29zKHRoKSkKZGlmZihMLHRoZG90KQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>

  File "/tmp/tmpTPoOKC/___code___.py", line 8, in <module>
    exec compile(u'diff(L,thdot)
  File "", line 1, in <module>

  File "/home/eric/sage/local/lib/python2.6/site-packages/sage/calculus/functional.py", line 130, in derivative
     return f.derivative(*args, **kwds)
  File "expression.pyx", line 2502, in sage.symbolic.expression.Expression.derivative (sage/symbolic/expression.cpp:11917)
  File "derivative.pyx", line 216, in sage.misc.derivative.multi_derivative (sage/misc/derivative.c:2191)
  File "expression.pyx", line 2570, in sage.symbolic.expression.Expression._derivative (sage/symbolic/expression.cpp:12263)
 TypeError: argument symb must be a symbol

I don't have any idea what all this means other than I'm guessing it doesn't like that I am trying to take the derivative with respect to a function?

Any help would be appreciated.