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.Sat, 01 Jun 2019 15:40:56 +0200How to create/use matrices valued in differential forms?https://ask.sagemath.org/question/46667/how-to-createuse-matrices-valued-in-differential-forms/First, for context, I am working with holomorphic Hermitian vector bundles, and I need to compute the connection and curvature matrices, and compute some representatives for Chern classes and the Chern form.
Ultimately I want to have a matrix which is valued in differential forms, and when I multiply matrices, I want the component-wise multiplication to be the wedge product of forms.
When I naively try to build a matrix of forms 'by hand', or when I pre-define my matrix space to be valued in the module of differential forms, I get an error telling me that the space of differential forms is a not a ring.
For example,
import sys
import mpmath
sys.modules['sympy.mpmath'] = mpmath
M = Manifold(2, 'M', field='complex')
U = M.open_subset('U')
c_xy.<x,y> = U.chart()
e_xy = c_xy.frame()
a = M.diff_form(2, name='a')
a.parent()
eU = c_xy.frame()
a.degree()
a[eU,0,1] = x*y^2 + 2*x
a.display(eU)
A = matrix([[a, a], [a, a]])
prints out
Module Omega^2(M) of 2-forms on the 2-dimensional complex manifold M
2
a = (x*y^2 + 2*x) dx/\dy
and raises a type error:
TypeError: base_ring (=Module Omega^2(M) of 2-forms on the 2-dimensional complex manifold M) must be a ringSat, 25 May 2019 17:16:00 +0200https://ask.sagemath.org/question/46667/how-to-createuse-matrices-valued-in-differential-forms/Comment by slelievre for <p>First, for context, I am working with holomorphic Hermitian vector bundles, and I need to compute the connection and curvature matrices, and compute some representatives for Chern classes and the Chern form. </p>
<p>Ultimately I want to have a matrix which is valued in differential forms, and when I multiply matrices, I want the component-wise multiplication to be the wedge product of forms. </p>
<p>When I naively try to build a matrix of forms 'by hand', or when I pre-define my matrix space to be valued in the module of differential forms, I get an error telling me that the space of differential forms is a not a ring. </p>
<p>For example, </p>
<pre><code>import sys
import mpmath
sys.modules['sympy.mpmath'] = mpmath
M = Manifold(2, 'M', field='complex')
U = M.open_subset('U')
c_xy.<x,y> = U.chart()
e_xy = c_xy.frame()
a = M.diff_form(2, name='a')
a.parent()
eU = c_xy.frame()
a.degree()
a[eU,0,1] = x*y^2 + 2*x
a.display(eU)
A = matrix([[a, a], [a, a]])
</code></pre>
<p>prints out</p>
<pre><code>Module Omega^2(M) of 2-forms on the 2-dimensional complex manifold M
2
a = (x*y^2 + 2*x) dx/\dy
</code></pre>
<p>and raises a type error:</p>
<pre><code>TypeError: base_ring (=Module Omega^2(M) of 2-forms on the 2-dimensional complex manifold M) must be a ring
</code></pre>
https://ask.sagemath.org/question/46667/how-to-createuse-matrices-valued-in-differential-forms/?comment=46762#post-id-46762To 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, z):
> return x * y * z
>
> then `f(2, 3, 5)` returns `30` but `f(2*3*5)` gives:
>
> TypeError: f() takes exactly 3 arguments (1 given)
produces:
> If we define `f` by
>
> def f(x, y, z):
> return x * y * z
>
> then `f(2, 3, 5)` returns `30` but `f(2*3*5)` gives:
>
> TypeError: f() takes exactly 3 arguments (1 given)Sat, 01 Jun 2019 15:40:56 +0200https://ask.sagemath.org/question/46667/how-to-createuse-matrices-valued-in-differential-forms/?comment=46762#post-id-46762Comment by sum8tion for <p>First, for context, I am working with holomorphic Hermitian vector bundles, and I need to compute the connection and curvature matrices, and compute some representatives for Chern classes and the Chern form. </p>
<p>Ultimately I want to have a matrix which is valued in differential forms, and when I multiply matrices, I want the component-wise multiplication to be the wedge product of forms. </p>
<p>When I naively try to build a matrix of forms 'by hand', or when I pre-define my matrix space to be valued in the module of differential forms, I get an error telling me that the space of differential forms is a not a ring. </p>
<p>For example, </p>
<pre><code>import sys
import mpmath
sys.modules['sympy.mpmath'] = mpmath
M = Manifold(2, 'M', field='complex')
U = M.open_subset('U')
c_xy.<x,y> = U.chart()
e_xy = c_xy.frame()
a = M.diff_form(2, name='a')
a.parent()
eU = c_xy.frame()
a.degree()
a[eU,0,1] = x*y^2 + 2*x
a.display(eU)
A = matrix([[a, a], [a, a]])
</code></pre>
<p>prints out</p>
<pre><code>Module Omega^2(M) of 2-forms on the 2-dimensional complex manifold M
2
a = (x*y^2 + 2*x) dx/\dy
</code></pre>
<p>and raises a type error:</p>
<pre><code>TypeError: base_ring (=Module Omega^2(M) of 2-forms on the 2-dimensional complex manifold M) must be a ring
</code></pre>
https://ask.sagemath.org/question/46667/how-to-createuse-matrices-valued-in-differential-forms/?comment=46717#post-id-46717It seems that someone fixed it for me. How do I do it myself?Thu, 30 May 2019 16:25:09 +0200https://ask.sagemath.org/question/46667/how-to-createuse-matrices-valued-in-differential-forms/?comment=46717#post-id-46717Comment by ortollj for <p>First, for context, I am working with holomorphic Hermitian vector bundles, and I need to compute the connection and curvature matrices, and compute some representatives for Chern classes and the Chern form. </p>
<p>Ultimately I want to have a matrix which is valued in differential forms, and when I multiply matrices, I want the component-wise multiplication to be the wedge product of forms. </p>
<p>When I naively try to build a matrix of forms 'by hand', or when I pre-define my matrix space to be valued in the module of differential forms, I get an error telling me that the space of differential forms is a not a ring. </p>
<p>For example, </p>
<pre><code>import sys
import mpmath
sys.modules['sympy.mpmath'] = mpmath
M = Manifold(2, 'M', field='complex')
U = M.open_subset('U')
c_xy.<x,y> = U.chart()
e_xy = c_xy.frame()
a = M.diff_form(2, name='a')
a.parent()
eU = c_xy.frame()
a.degree()
a[eU,0,1] = x*y^2 + 2*x
a.display(eU)
A = matrix([[a, a], [a, a]])
</code></pre>
<p>prints out</p>
<pre><code>Module Omega^2(M) of 2-forms on the 2-dimensional complex manifold M
2
a = (x*y^2 + 2*x) dx/\dy
</code></pre>
<p>and raises a type error:</p>
<pre><code>TypeError: base_ring (=Module Omega^2(M) of 2-forms on the 2-dimensional complex manifold M) must be a ring
</code></pre>
https://ask.sagemath.org/question/46667/how-to-createuse-matrices-valued-in-differential-forms/?comment=46669#post-id-46669Hi
maybe you can give your code,
so someone might be more easily able to help you.
your post is in duplicate, maybe you can delete one of them?(but in fact I do not know if it is possible on the sagemath site !Sat, 25 May 2019 19:14:06 +0200https://ask.sagemath.org/question/46667/how-to-createuse-matrices-valued-in-differential-forms/?comment=46669#post-id-46669Comment by ortollj for <p>First, for context, I am working with holomorphic Hermitian vector bundles, and I need to compute the connection and curvature matrices, and compute some representatives for Chern classes and the Chern form. </p>
<p>Ultimately I want to have a matrix which is valued in differential forms, and when I multiply matrices, I want the component-wise multiplication to be the wedge product of forms. </p>
<p>When I naively try to build a matrix of forms 'by hand', or when I pre-define my matrix space to be valued in the module of differential forms, I get an error telling me that the space of differential forms is a not a ring. </p>
<p>For example, </p>
<pre><code>import sys
import mpmath
sys.modules['sympy.mpmath'] = mpmath
M = Manifold(2, 'M', field='complex')
U = M.open_subset('U')
c_xy.<x,y> = U.chart()
e_xy = c_xy.frame()
a = M.diff_form(2, name='a')
a.parent()
eU = c_xy.frame()
a.degree()
a[eU,0,1] = x*y^2 + 2*x
a.display(eU)
A = matrix([[a, a], [a, a]])
</code></pre>
<p>prints out</p>
<pre><code>Module Omega^2(M) of 2-forms on the 2-dimensional complex manifold M
2
a = (x*y^2 + 2*x) dx/\dy
</code></pre>
<p>and raises a type error:</p>
<pre><code>TypeError: base_ring (=Module Omega^2(M) of 2-forms on the 2-dimensional complex manifold M) must be a ring
</code></pre>
https://ask.sagemath.org/question/46667/how-to-createuse-matrices-valued-in-differential-forms/?comment=46671#post-id-46671just for information: there is a button 101 which allows you to display code more readable.Sun, 26 May 2019 08:06:33 +0200https://ask.sagemath.org/question/46667/how-to-createuse-matrices-valued-in-differential-forms/?comment=46671#post-id-46671Answer by eric_g for <p>First, for context, I am working with holomorphic Hermitian vector bundles, and I need to compute the connection and curvature matrices, and compute some representatives for Chern classes and the Chern form. </p>
<p>Ultimately I want to have a matrix which is valued in differential forms, and when I multiply matrices, I want the component-wise multiplication to be the wedge product of forms. </p>
<p>When I naively try to build a matrix of forms 'by hand', or when I pre-define my matrix space to be valued in the module of differential forms, I get an error telling me that the space of differential forms is a not a ring. </p>
<p>For example, </p>
<pre><code>import sys
import mpmath
sys.modules['sympy.mpmath'] = mpmath
M = Manifold(2, 'M', field='complex')
U = M.open_subset('U')
c_xy.<x,y> = U.chart()
e_xy = c_xy.frame()
a = M.diff_form(2, name='a')
a.parent()
eU = c_xy.frame()
a.degree()
a[eU,0,1] = x*y^2 + 2*x
a.display(eU)
A = matrix([[a, a], [a, a]])
</code></pre>
<p>prints out</p>
<pre><code>Module Omega^2(M) of 2-forms on the 2-dimensional complex manifold M
2
a = (x*y^2 + 2*x) dx/\dy
</code></pre>
<p>and raises a type error:</p>
<pre><code>TypeError: base_ring (=Module Omega^2(M) of 2-forms on the 2-dimensional complex manifold M) must be a ring
</code></pre>
https://ask.sagemath.org/question/46667/how-to-createuse-matrices-valued-in-differential-forms/?answer=46687#post-id-46687At the moment (SageMath 8.7), differential forms of degree $p$ on a manifold $M$ are considered to belong to (i.e. their parent is) the set $\Omega^p(M)$ of all differential forms of degree $p$, which is a $C^\infty(M)$-module and not a ring. Hence one cannot construct matrices from them. However, since SageMath 8.8.beta3 (see the ticket [#27584](https://trac.sagemath.org/ticket/27584) for details), it is possible to consider the graded algebra
$$\Omega^*(M) = \bigoplus^n_{p=0} \Omega^p(M), $$
where $n = \mathrm{dim}\ M$.
The set $ \Omega^* (M) $ is a ring, the multiplication of which is the wedge product. It is therefore possible to form matrices from its elements. The latter are called *mixed differential forms*, so that, continuing from your example, one may write
sage: aa = M.mixed_form(comp=[0, 0, a], name='aa')
sage: aa.parent()
Graded algebra Omega^*(M) of mixed differential forms
on the 2-dimensional complex manifold M
sage: aa.display(eU)
aa = [0] + [0] + [(x*y^2 + 2*x) dx/\dy]
It is now possible to form a matrix and use the standard matrix operations:
sage: A = matrix([[aa, aa], [aa, aa]])
sage: A
[Mixed differential form aa on the 2-dimensional complex manifold M
Mixed differential form aa on the 2-dimensional complex manifold M]
[Mixed differential form aa on the 2-dimensional complex manifold M
Mixed differential form aa on the 2-dimensional complex manifold M]
sage: A.base_ring()
Graded algebra Omega^*(M) of mixed differential forms
on the 2-dimensional complex manifold M
sage: A[0,1]
Mixed differential form aa on the 2-dimensional complex manifold M
sage: det(A)
Mixed differential form aa/\aa-aa/\aa on the 2-dimensional complex manifold M
sage: det(A).display(eU)
aa/\aa-aa/\aa = [0] + [0] + [0]
The above feature will be available in the next stable release of SageMath (8.8), which should appear in a few weeks. Meanwhile you can install the latest development version (8.8.beta6 as of today) to use it, see e.g. the section *"1. Starting from the latest sources"* in this [page](https://sagemanifolds.obspm.fr/contrib.html).Mon, 27 May 2019 14:12:16 +0200https://ask.sagemath.org/question/46667/how-to-createuse-matrices-valued-in-differential-forms/?answer=46687#post-id-46687