ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 03 May 2018 12:50:55 +0200Error regarding declaring tensor field in Sagehttps://ask.sagemath.org/question/42244/error-regarding-declaring-tensor-field-in-sage/This is my code regarding declaration of tensor field for 3 dimensional differentiable manifold
M = Manifold(3, 'M')
U = M.open_subset('U')
V = M.open_subset('V')
M.declare_union(U,V);
c_xyz.<x,y,z> = U.chart()
c_uvw.<u,v,w> = V.chart()
eU = c_xyz.frame()
eV = c_uvw.frame()
t= M.tensor_field(1,1, name='t')
t[eU,:]== [1,1]
It is showing error as I cannot properly declare t.Any help is appreciatedWed, 02 May 2018 16:02:11 +0200https://ask.sagemath.org/question/42244/error-regarding-declaring-tensor-field-in-sage/Comment by slelievre for <p>This is my code regarding declaration of tensor field for 3 dimensional differentiable manifold
M = Manifold(3, 'M')
U = M.open_subset('U') <br>
V = M.open_subset('V')
M.declare_union(U,V);
c_xyz.<x,y,z> = U.chart()
c_uvw.<u,v,w> = V.chart()
eU = c_xyz.frame()
eV = c_uvw.frame()
t= M.tensor_field(1,1, name='t')
t[eU,:]== [1,1]
It is showing error as I cannot properly declare t.Any help is appreciated</p>
https://ask.sagemath.org/question/42244/error-regarding-declaring-tensor-field-in-sage/?comment=42249#post-id-42249To display inline code, like `z = x*y`, use backticks.
To display blocks of code or error messages, skip a line above and below,
and do one of the following (all give the same result):
- indent all code lines with 4 spaces
- select all code lines and click the "code" button (the icon with '101 010')
- select all code lines and hit ctrl-K
For instance, typing
If we define `f` by
def f(x, y):
return (x, y)
then `f(2, 3)` returns `(2, 3)` but `f(2)` gives:
TypeError: f() takes exactly 2 arguments (1 given)
produces:
> If we define `f` by
>
> def f(x, y):
> return (x, y)
>
> then `f(2, 3)` returns `(2, 3)` but `f(2)` gives:
>
> TypeError: f() takes exactly 2 arguments (1 given)
Please edit your question to do that.Thu, 03 May 2018 12:50:55 +0200https://ask.sagemath.org/question/42244/error-regarding-declaring-tensor-field-in-sage/?comment=42249#post-id-42249Answer by danielvolinski for <p>This is my code regarding declaration of tensor field for 3 dimensional differentiable manifold
M = Manifold(3, 'M')
U = M.open_subset('U') <br>
V = M.open_subset('V')
M.declare_union(U,V);
c_xyz.<x,y,z> = U.chart()
c_uvw.<u,v,w> = V.chart()
eU = c_xyz.frame()
eV = c_uvw.frame()
t= M.tensor_field(1,1, name='t')
t[eU,:]== [1,1]
It is showing error as I cannot properly declare t.Any help is appreciated</p>
https://ask.sagemath.org/question/42244/error-regarding-declaring-tensor-field-in-sage/?answer=42247#post-id-42247I've been using SageMath for a short time but I think I can help you.
I don't understand your last command: `t[eU,:]== [1,1]`. You are comparing the tensor with `[1,1]`. I guess this is not what you intended. In essence you are defining a structure akin to a 3 by 3 matrix, so in order to define the tensor I would use something like:
t[0,0], t[1,1], t[2,2] = 1, 2, 3
In order to see the tensor you can use
t[eU,:]
or
t.display(eU)
Wed, 02 May 2018 19:41:02 +0200https://ask.sagemath.org/question/42244/error-regarding-declaring-tensor-field-in-sage/?answer=42247#post-id-42247