1 | initial version |
It suffices to attach the function mybracket
that you have defined to the vector field class, which is VectorField
. You have to import the latter first:
from sage.manifolds.differentiable.vectorfield import VectorField
VectorField.mybracket = mybracket
So the whole code becomes:
from sage.manifolds.differentiable.vectorfield import VectorField
def mybracket(A, B):
return B.bracket(A)
VectorField.mybracket = mybracket
Then
M.<x,y> = EuclideanSpace()
X = M.vector_field(0,1-y*x^2, name='X')
Y = M.vector_field(-(y-1),x, name='Y')
X.mybracket(Y).display()
yields
[Y,X] = (-x^2*y + 1) e_x + (-x^3 + 2*x*y^2 - 2*x*y) e_y
and
X.mybracket(Y) == Y.bracket(X)
gives
True
2 | No.2 Revision |
It suffices to attach the function mybracket
that you have defined to the vector field class, which is VectorField
. You have to import the latter first:
from sage.manifolds.differentiable.vectorfield import VectorField
VectorField.mybracket = mybracket
So the whole code becomes:
from sage.manifolds.differentiable.vectorfield import VectorField
def mybracket(A, B):
return B.bracket(A)
VectorField.mybracket = mybracket
Then
M.<x,y> = EuclideanSpace()
X = M.vector_field(0,1-y*x^2, name='X')
Y = M.vector_field(-(y-1),x, name='Y')
X.mybracket(Y).display()
yields
[Y,X] = (-x^2*y + 1) e_x + (-x^3 + 2*x*y^2 - 2*x*y) e_y
and
X.mybracket(Y) == Y.bracket(X)
-X.bracket(Y)
gives
True