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, 29 Oct 2020 18:44:44 +0100Generators of simplicial homologyhttps://ask.sagemath.org/question/54070/generators-of-simplicial-homology/ I have this code to compute the homology of a simplicial complex
S = SimplicialComplex([[5, 2], [5, 2, 1], [5, 0], [5, 1], [4, 3], [4, 3, 0], [4, 2], [4, 0], [3, 0], [3, 1], [2, 1],])
S.homology(generators = True)
The output only consists of the homology, and does not contain the generators. Am I missing something?
Thu, 29 Oct 2020 12:49:00 +0100https://ask.sagemath.org/question/54070/generators-of-simplicial-homology/Answer by John Palmieri for <p>I have this code to compute the homology of a simplicial complex</p>
<pre><code>S = SimplicialComplex([[5, 2], [5, 2, 1], [5, 0], [5, 1], [4, 3], [4, 3, 0], [4, 2], [4, 0], [3, 0], [3, 1], [2, 1],])
S.homology(generators = True)
</code></pre>
<p>The output only consists of the homology, and does not contain the generators. Am I missing something?</p>
https://ask.sagemath.org/question/54070/generators-of-simplicial-homology/?answer=54078#post-id-54078This looks like a missing feature and/or a bug. Note that the [documentation](https://doc.sagemath.org/html/en/reference/homology/sage/homology/cell_complex.html#sage.homology.cell_complex.GenericCellComplex.homology) for `S.homology()` says, regarding `generators`:
> Since trac ticket #6100, the result may not be what you expect when not using CHomP since its return is in terms of the chain complex.
The bug is that there is no result at all, but you can recover it by doing:
sage: S.chain_complex().homology(generators=True)
{0: [(Z, Chain(0:(0, 0, 0, 1, 0, 0)))],
1: [(Z, Chain(1:(0, 1, -1, 0, 0, 0, -1, 1, 0))),
(Z, Chain(1:(0, 0, 0, 0, 1, -1, -1, 1, 1)))],
2: []}
To interpret this, you need to know how the simplicial complex is turned into a chain complex. The simplices in each dimension are sorted in order to construct the matrices representing the boundary maps, so to get the first generator in dimension 1, for example, you would look at
sage: S._n_cells_sorted(1)
[(0, 3), (0, 4), (0, 5), (1, 2), (1, 3), (1, 5), (2, 4), (2, 5), (3, 4)]
The first generator is given by `(0, 1, -1, 0, 0, 0, -1, 1, 0)`, which means the sum of 1 x (item 1 in list), -1 x (item 2), etc.:
(0, 4) - (0, 5) - (2, 4) + (2, 5)Thu, 29 Oct 2020 18:05:03 +0100https://ask.sagemath.org/question/54070/generators-of-simplicial-homology/?answer=54078#post-id-54078Comment by John Palmieri for <p>This looks like a missing feature and/or a bug. Note that the <a href="https://doc.sagemath.org/html/en/reference/homology/sage/homology/cell_complex.html#sage.homology.cell_complex.GenericCellComplex.homology">documentation</a> for <code>S.homology()</code> says, regarding <code>generators</code>:</p>
<blockquote>
<p>Since trac ticket #6100, the result may not be what you expect when not using CHomP since its return is in terms of the chain complex.</p>
</blockquote>
<p>The bug is that there is no result at all, but you can recover it by doing:</p>
<pre><code>sage: S.chain_complex().homology(generators=True)
{0: [(Z, Chain(0:(0, 0, 0, 1, 0, 0)))],
1: [(Z, Chain(1:(0, 1, -1, 0, 0, 0, -1, 1, 0))),
(Z, Chain(1:(0, 0, 0, 0, 1, -1, -1, 1, 1)))],
2: []}
</code></pre>
<p>To interpret this, you need to know how the simplicial complex is turned into a chain complex. The simplices in each dimension are sorted in order to construct the matrices representing the boundary maps, so to get the first generator in dimension 1, for example, you would look at </p>
<pre><code>sage: S._n_cells_sorted(1)
[(0, 3), (0, 4), (0, 5), (1, 2), (1, 3), (1, 5), (2, 4), (2, 5), (3, 4)]
</code></pre>
<p>The first generator is given by <code>(0, 1, -1, 0, 0, 0, -1, 1, 0)</code>, which means the sum of 1 x (item 1 in list), -1 x (item 2), etc.:</p>
<pre><code>(0, 4) - (0, 5) - (2, 4) + (2, 5)
</code></pre>
https://ask.sagemath.org/question/54070/generators-of-simplicial-homology/?comment=54081#post-id-54081This problem is being tracked at https://trac.sagemath.org/ticket/30838.Thu, 29 Oct 2020 18:44:44 +0100https://ask.sagemath.org/question/54070/generators-of-simplicial-homology/?comment=54081#post-id-54081Comment by springfieldgion for <p>This looks like a missing feature and/or a bug. Note that the <a href="https://doc.sagemath.org/html/en/reference/homology/sage/homology/cell_complex.html#sage.homology.cell_complex.GenericCellComplex.homology">documentation</a> for <code>S.homology()</code> says, regarding <code>generators</code>:</p>
<blockquote>
<p>Since trac ticket #6100, the result may not be what you expect when not using CHomP since its return is in terms of the chain complex.</p>
</blockquote>
<p>The bug is that there is no result at all, but you can recover it by doing:</p>
<pre><code>sage: S.chain_complex().homology(generators=True)
{0: [(Z, Chain(0:(0, 0, 0, 1, 0, 0)))],
1: [(Z, Chain(1:(0, 1, -1, 0, 0, 0, -1, 1, 0))),
(Z, Chain(1:(0, 0, 0, 0, 1, -1, -1, 1, 1)))],
2: []}
</code></pre>
<p>To interpret this, you need to know how the simplicial complex is turned into a chain complex. The simplices in each dimension are sorted in order to construct the matrices representing the boundary maps, so to get the first generator in dimension 1, for example, you would look at </p>
<pre><code>sage: S._n_cells_sorted(1)
[(0, 3), (0, 4), (0, 5), (1, 2), (1, 3), (1, 5), (2, 4), (2, 5), (3, 4)]
</code></pre>
<p>The first generator is given by <code>(0, 1, -1, 0, 0, 0, -1, 1, 0)</code>, which means the sum of 1 x (item 1 in list), -1 x (item 2), etc.:</p>
<pre><code>(0, 4) - (0, 5) - (2, 4) + (2, 5)
</code></pre>
https://ask.sagemath.org/question/54070/generators-of-simplicial-homology/?comment=54079#post-id-54079This is perfect, thank a lot!Thu, 29 Oct 2020 18:14:21 +0100https://ask.sagemath.org/question/54070/generators-of-simplicial-homology/?comment=54079#post-id-54079Comment by John Palmieri for <p>This looks like a missing feature and/or a bug. Note that the <a href="https://doc.sagemath.org/html/en/reference/homology/sage/homology/cell_complex.html#sage.homology.cell_complex.GenericCellComplex.homology">documentation</a> for <code>S.homology()</code> says, regarding <code>generators</code>:</p>
<blockquote>
<p>Since trac ticket #6100, the result may not be what you expect when not using CHomP since its return is in terms of the chain complex.</p>
</blockquote>
<p>The bug is that there is no result at all, but you can recover it by doing:</p>
<pre><code>sage: S.chain_complex().homology(generators=True)
{0: [(Z, Chain(0:(0, 0, 0, 1, 0, 0)))],
1: [(Z, Chain(1:(0, 1, -1, 0, 0, 0, -1, 1, 0))),
(Z, Chain(1:(0, 0, 0, 0, 1, -1, -1, 1, 1)))],
2: []}
</code></pre>
<p>To interpret this, you need to know how the simplicial complex is turned into a chain complex. The simplices in each dimension are sorted in order to construct the matrices representing the boundary maps, so to get the first generator in dimension 1, for example, you would look at </p>
<pre><code>sage: S._n_cells_sorted(1)
[(0, 3), (0, 4), (0, 5), (1, 2), (1, 3), (1, 5), (2, 4), (2, 5), (3, 4)]
</code></pre>
<p>The first generator is given by <code>(0, 1, -1, 0, 0, 0, -1, 1, 0)</code>, which means the sum of 1 x (item 1 in list), -1 x (item 2), etc.:</p>
<pre><code>(0, 4) - (0, 5) - (2, 4) + (2, 5)
</code></pre>
https://ask.sagemath.org/question/54070/generators-of-simplicial-homology/?comment=54080#post-id-54080I don't think it's perfect — it should be fixed — but I'm glad it's helpful.Thu, 29 Oct 2020 18:36:40 +0100https://ask.sagemath.org/question/54070/generators-of-simplicial-homology/?comment=54080#post-id-54080