ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 16 Aug 2019 02:29:54 -0500cosmological spacetimeshttp://ask.sagemath.org/question/47496/cosmological-spacetimes/ Hi,
I need an example on how to perform the Einstein Field Equations for a universe which is anisotropic and where the clustering of masses are aligned to an arbitrary axis (axial pole).
Just like the example given for Friedmann equations in the sagemanifolds examples website.
ThanksvickFri, 16 Aug 2019 02:29:54 -0500http://ask.sagemath.org/question/47496/Tensor orderinghttp://ask.sagemath.org/question/46976/tensor-ordering/I've been trying to figure out how tensor indices work with sage and I have a really simple question - how are the indices ordered after contracting two tensors? For example, if I have two tensors S,T or type (s_1,s_2) and (t_1,t_2) and I contract them, how will the indices of the resulting tensor be ordered? e.g. if S and T are both of type (3,3), then:
$$ S.\text{contract}(1,T,4) = S^{abc}_{\quad def} {\color{white}*} T^{ghi}_{\quad jbk}$$
how would the resulting tensors indicices be ordered?
$$R^{ac\quad ghi}_{\quad def \quad jk}$$
or
$$
R^{acghi}_{\quad \quad defjk}$$
I tried looking on the page for tensor indices but I couldn't figure it out; experimentation seemed to suggest the second but I wanted to be sure. Thanks; and sorry if this is a silly question whose explanation I missed in the docsjoshualinSun, 23 Jun 2019 01:57:27 -0500http://ask.sagemath.org/question/46976/Sagemanifold - Connection components from a tensor (not a metric)http://ask.sagemath.org/question/44572/sagemanifold-connection-components-from-a-tensor-not-a-metric/ Dear community.
This might sound *dump*, but I'm trying to determine whether a tensor satisfy the properties of a metric (under certain conditions). Of course it is a (0,2)-symmetric tensor, call it $S$, but I cannot (to my understanding) calculate the (Levi-Civita-like) connection components that would be associated to $S$... unless I declare it as a metric.
The way it is implemented makes sense... and it's solid!
## What I did...?
I defined like a metric and calculate the associated connection (and curvatures)
## Why should I do something else?
In the file `src/sage/manifolds/differentiable/metric.py` the metric is defined (as it should) to be symmetric, but it does not allow to consider extensions of General Relativity like say Einstein--Strauss model. Thus, I need an instance to calculate the *derived quantities* of a tensor that is a generalization of a metric.
### Question:
**Is this possible?**DoxTue, 04 Dec 2018 02:18:37 -0600http://ask.sagemath.org/question/44572/Subtitute functions - in a differential equation - Sagemanifoldhttp://ask.sagemath.org/question/44557/subtitute-functions-in-a-differential-equation-sagemanifold/Dear community,
I have a differential equation that depends on a function $\xi(t)$, but is a component of a tensor (calculated with `sagemanifold`)
M = Manifold(4, 'M', latex_name=r"\mathcal{M}")
U.<t,r,th,ph> = M.chart(r't r:(0,+oo) th:(0,pi):\theta ph:(0,2*pi):\phi')
xi = function('xi')(t)
f = function('f')(t)
h = function('h')(t)
g = function('g')(t)
Ric = M.tensor_field(0,2, 'Ric')
Ric[0,0] = 3/2*f*h - 3/4*h^2 + 3/2*f*xi + 3/4*xi^2 - 3/2*diff(h, t) - 3/2*diff(xi, t)
Ric.display()
I'd like to define the restriction to $\xi = 0$, and assign it to a new tensor
Ric0 = M.tensor_field(0,2, 'Ric0')
Ric0[0,0] = Ric[0,0].substitute_expression({xi:0, diff(xi, t):0})
Ric0.display()
but I get an `AttributeError` because the
AttributeError: 'ChartFunctionRing_with_category.element_class' object has no attribute 'substitute_expression'
I know that it works for functions
var('t')
xi = function('xi')(t)
f = function('f')(t)
h = function('h')(t)
ode = 3/2*f*h - 3/4*h^2 + 3/2*f*xi + 3/4*xi^2 - 3/2*diff(h, t) - 3/2*diff(xi, t)
ode0 = ode.substitute_expression({xi:0, diff(xi, t):0})
<h2>Question</h2>
Is there a way to substitute functions that are not `đđđđ.đđ˘đđđđđđ.đđĄđđđđđđđđ.đ´đĄđđđđđđđđ` but `ChartFunctionRing_with_category.element_class`?DoxMon, 03 Dec 2018 11:33:37 -0600http://ask.sagemath.org/question/44557/Assignation of components of a differential form (or multivector field) in sagemanifoldhttp://ask.sagemath.org/question/44374/assignation-of-components-of-a-differential-form-or-multivector-field-in-sagemanifold/Dear all. I've crossed with the task of assigning components to a multivector field, and it's tedious! (specially higher ranks)
**Question**: Is there an efficient way of assigning components to tensors with symmetries?DoxThu, 22 Nov 2018 03:30:47 -0600http://ask.sagemath.org/question/44374/Tensor density in sagemanifolds?http://ask.sagemath.org/question/44371/tensor-density-in-sagemanifolds/Hello community.
I've just realized that within the class `TensorField` there are subclasses `DiffForm` and `MultivectorField`. I was wondering whether a maximal (i.e. rank $n$ in $n$ dimensions) differential form or multivector field are considered as tensor densities. I'm thinking in the Levi-Civita epsilon.
Well, more generally... Is there a way to assign a density weight to a tensor?DoxThu, 22 Nov 2018 02:30:38 -0600http://ask.sagemath.org/question/44371/Error regarding declaring tensor field in Sagehttp://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 appreciatedShouvikWed, 02 May 2018 09:02:11 -0500http://ask.sagemath.org/question/42244/Exterior algebra errorhttp://ask.sagemath.org/question/39523/exterior-algebra-error/Hi,
I'm new to Sage, and I've been having a lot of trouble constructing a particular algebra. I want to construct the exterior algebra (over $\mathbb{Q}$) on generators $w_{i,j} = w_{j,i}$ where $1 \le i < j \le n$ for some $n$ (for concreteness, say $n = 6$). I want this particular generating set so that I can define an $S_n$ action, but that's the next challenge. I've been attempting the following rough outline:
1. Construct a vector space $V \cong \mathbb{Q}^n$, with basis $\{v_i\}$.
2. Take a tensor product $V \otimes V$, with basis $w_{i,j} = v_i \otimes v_j$.
3. Take a quotient to impose relations $w_{i,i} = 0$ and $w_{i,j} = w_{j,i}$.
4. Take the exterior algebra on the quotient.
Several possible data structures for $V$ (FiniteRankFreeModule, VectorSpace, FreeModule) seem to fail at step 2. Are tensor products implemented for these? The most promising structure, CombinatorialFreeModule, fails at step 4 for an unknown reason. I get an error "base must be a ring or a subcategory of Rings()", even though the base is $\mathbb{Q}$.
Here's the specific code I've tried.
indices = range(1,7)
V = CombinatorialFreeModule(QQ, indices)
V2 = tensor((V,V))
w = V2.basis()
relations = []
for i in indices:
relations.append(w[i,i])
for j in range(i+1,7)
relations.append(w[i,j] - w[j,i])
R = V2.submodule(relations)
V3 = V2.quotient_module(R)
A = ExteriorAlgebra(V3)
The last line gives an error, "base must be a ring or a subcategory of Rings()". The command `V2.base() in Rings()` returns true, but I can't get around the error.
Any help would be appreciated, either in fixing this error or approaching the construction in a different way.Nat MayerMon, 13 Nov 2017 21:57:15 -0600http://ask.sagemath.org/question/39523/Tensor product of polynomial algebrashttp://ask.sagemath.org/question/33165/tensor-product-of-polynomial-algebras/I want to make the tensor product of polynomial algebras. Evidently, the following is not the right way to do this:
sage: P.<x> = PolynomialRing(QQ)
sage: tensor([P, P])
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-2-17decd317813> in <module>()
----> 1 tensor([P, P])
/usr/lib/python2.7/site-packages/sage/categories/covariant_functorial_construction.pyc in __call__(self, args, **kwargs)
219 """
220 args = tuple(args) # a bit brute force; let's see if this becomes a bottleneck later
--> 221 assert(all( hasattr(arg, self._functor_name) for arg in args))
222 assert(len(args) > 0)
223 return getattr(args[0], self._functor_name)(*args[1:], **kwargs)
AssertionError:
This does work for `CombinatorialFreeModule`s but I can't figure out how to turn one of those into a polynomial algebra.jan0Wed, 20 Apr 2016 21:47:22 -0500http://ask.sagemath.org/question/33165/Index notationhttp://ask.sagemath.org/question/29595/index-notation/ I am taking a course in general relativity, and I was planing to use sage for doing calculations.
I have
from sage.tensor.modules.tensor_with_indices import TensorWithIndices
M = FiniteRankFreeModule(QQ, 4, name='M')
e = M.basis('e')
a = M.tensor((2,0), name='a')
a[:] = [[2,0,1,-1], [1,0,3,2], [-1,1,0,0], [-2,1,1,-2]]
g = M.tensor((0,2), name='g')
g[:] = [[1,0,0,0], [0,1,0,0], [0,0,1,0],[0,0,0,1]]
v=M.tensor((1,0), name='v')
v[:]=[-1,2,0,-2]
I wanted to calculate $a^{^i,^j}$
Is there some way to tell Sage what is the metric, and do the index lowering automatically? I did it manually, but it's cumbersome for more complicated calculations.
A=a['^ik']*g['_jk'];A[:]
Also, I don't know how to compute $vĂŽ v_i$, since
v['^i']*g['_ij']*v['i']
does not work.
Apart from that, I would like to know if there is a way to do this kind of computations with tensor fields and index notation, including derivatives, etc.MLainzFri, 25 Sep 2015 17:51:23 -0500http://ask.sagemath.org/question/29595/Differential forms and tensorshttp://ask.sagemath.org/question/9297/differential-forms-and-tensors/Dear all,
A long time ago I was trying to implement a SAGE code for working with [Differential Forms with values in a certain Lie algebra](http://doxdrum.wordpress.com/2011/02/10/sage-tip-creating-a-class-for-non-abelian-forms/), but due to my lack of programming knowledge, I couldn't.
This kind of objects are important for working with *non-Abelin gauge theories*.
**Question**
Is it possible to define and work with those objects?
So far there is no reference of it in the manual.
Thank you!DoxWed, 05 Sep 2012 08:48:24 -0500http://ask.sagemath.org/question/9297/how to get two modules tensor_prduct()http://ask.sagemath.org/question/23430/how-to-get-two-modules-tensor_prduct/ u = vector(QQ, [1/2, 1/3, 1/4, 1/5])
v = vector(ZZ, [60, 180, 600])
u.outer_product(v),v.outer_product(u),u.tensor_product(v),v.tensor_product(u)
(
[ 30 90 300] [ 30 90 300]
[ 20 60 200] [ 30 20 15 12] [ 20 60 200] [ 30 20 15 12]
[ 15 45 150] [ 90 60 45 36] [ 15 45 150] [ 90 60 45 36]
[ 12 36 120], [300 200 150 120], [ 12 36 120], [300 200 150 120]
)
above are two vectors'tensor_product,but when use two mudules,cannot run....
M=FreeModule(ZZ,3);M
N=FreeModule(ZZ,7);N
M.outer_product(N),M.tensor_product(N)
AttributeError Traceback (most recent call last)
<ipython-input-1-ad4483c60043> in <module>()
1 M=FreeModule(ZZ,Integer(3));M
2 N=FreeModule(ZZ,Integer(7));N
----> 3 M.outer_product(N),M.tensor_product(N)
/home/sageserver/sage/local/lib/python2.7/site-packages/sage/structure/parent.so in sage.structure.parent.Parent.__getattr__ (build/cythonized/sage/structure/parent.c:7367)()
/home/sageserver/sage/local/lib/python2.7/site-packages/sage/structure/misc.so in sage.structure.misc.getattr_from_other_class (build/cythonized/sage/structure/misc.c:1687)()
AttributeError: 'FreeModule_ambient_pid_with_category' object has no attribute 'outer_product'
cjshWed, 16 Jul 2014 02:05:27 -0500http://ask.sagemath.org/question/23430/define/generate new variables automaticallyhttp://ask.sagemath.org/question/10765/definegenerate-new-variables-automatically/Dear all,
I'd like to use symbolic boxes in SAGE to check the proof of a theorem.
sage: var('a11, a12, a13, a21, a22, a23, a31, a32, a33');
sage: A = matrix(SR, 3, 3, [a11, a12, a13, a21, a22, a23, a31, a32, a33])
It is really time-consuming..
[genvarname@MATLAB](http://www.mathworks.de/de/help/matlab/ref/genvarname.html)
I can use this function with two/three for-loops to construct one symbolic matrix/tensor.
Thanks in advance!
gundamlhThu, 21 Nov 2013 23:44:22 -0600http://ask.sagemath.org/question/10765/What is the name of a tensor product?http://ask.sagemath.org/question/8750/what-is-the-name-of-a-tensor-product/I have a tensor like
tensor([a,b,c])
where a, b, c lie in some CombinatorialFreeModule. Where (in Sage syntax) does this tensor lie? (I need to know, because I am writing a function using module_morphism, and it requires me to explicitly specify its codomain.)
Writing
type(tensor([a,b,c]))
doesn't help (it just gives generic trash).darijgrinbergMon, 27 Feb 2012 11:33:16 -0600http://ask.sagemath.org/question/8750/