ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 05 Oct 2019 15:45:12 -0500Changing chart multiple times in sagemanifoldshttps://ask.sagemath.org/question/47660/changing-chart-multiple-times-in-sagemanifolds/ In sagemanifolds, I would like to change from an initial chart to a second and then, from the second to the third. My attempts fail. Is this my fault or a sagemanifolds problem? (Apologies if I already asked this.)
Here is a minimal (not) working example. I run the following file:
theManifold = Manifold(1, 'M', r'\mathcal{M}')
theOpenSet = theManifold.open_subset('U')
theFirstChart.<x> = theOpenSet.chart(r'x')
g = theManifold.riemannian_metric('g')
g[0,0] = 1
show(g.display())
theSecondChart.<y> = theOpenSet.chart(r'y')
ChangeFirst_to_Second = theFirstChart.transition_map(theSecondChart,[x])
show(g.display(theSecondChart.frame()))
theThirdChart.<z> = theOpenSet.chart(r'z')
ChangeSecond_to_Third = theSecondChart.transition_map(theThirdChart,[y])
show(g.display(theThirdChart.frame()))
The output is
g=dx⊗dx
g=dy⊗dy
and then a few screens of error messages, of which the most clear is "no common chart for the multiplication". Thu, 29 Aug 2019 12:28:21 -0500https://ask.sagemath.org/question/47660/changing-chart-multiple-times-in-sagemanifolds/Answer by eric_g for <p>In sagemanifolds, I would like to change from an initial chart to a second and then, from the second to the third. My attempts fail. Is this my fault or a sagemanifolds problem? (Apologies if I already asked this.)</p>
<p>Here is a minimal (not) working example. I run the following file: </p>
<pre><code>theManifold = Manifold(1, 'M', r'\mathcal{M}')
theOpenSet = theManifold.open_subset('U')
theFirstChart.<x> = theOpenSet.chart(r'x')
g = theManifold.riemannian_metric('g')
g[0,0] = 1
show(g.display())
theSecondChart.<y> = theOpenSet.chart(r'y')
ChangeFirst_to_Second = theFirstChart.transition_map(theSecondChart,[x])
show(g.display(theSecondChart.frame()))
theThirdChart.<z> = theOpenSet.chart(r'z')
ChangeSecond_to_Third = theSecondChart.transition_map(theThirdChart,[y])
show(g.display(theThirdChart.frame()))
</code></pre>
<p>The output is </p>
<pre><code>g=dx⊗dx
g=dy⊗dy
</code></pre>
<p>and then a few screens of error messages, of which the most clear is "no common chart for the multiplication". </p>
https://ask.sagemath.org/question/47660/changing-chart-multiple-times-in-sagemanifolds/?answer=47661#post-id-47661The issue arises because you have not fully defined the transition maps on the manifold: the inverse maps are missing. You have to generate them by invoking
ChangeFirst_to_Second.inverse()
just after the definition of `ChangeFirst_to_Second` and
ChangeSecond_to_Third.inverse()
just after the definition of `ChangeSecond_to_Third`. Then everything is OK.
The reason why the inverse transition maps are not automatically evaluated is that in certain cases Sage is not capable to compute them (the method `inverse()` returns then an error); the user has then to provide them by hand, via the method [set_inverse()](http://doc.sagemath.org/html/en/reference/manifolds/sage/manifolds/chart.html#sage.manifolds.chart.CoordChange.set_inverse).
**EDIT:** actually, in the present case, the inverse transition maps should not be required to compute the expression of $g$ in the third frame. This will be fixed in the next release of SageMath, thanks to the Trac ticket [#28072](https://trac.sagemath.org/ticket/28072), which has been merged in SageMath 8.9.beta2.Thu, 29 Aug 2019 14:37:08 -0500https://ask.sagemath.org/question/47660/changing-chart-multiple-times-in-sagemanifolds/?answer=47661#post-id-47661Comment by eric_g for <p>The issue arises because you have not fully defined the transition maps on the manifold: the inverse maps are missing. You have to generate them by invoking</p>
<pre><code>ChangeFirst_to_Second.inverse()
</code></pre>
<p>just after the definition of <code>ChangeFirst_to_Second</code> and</p>
<pre><code>ChangeSecond_to_Third.inverse()
</code></pre>
<p>just after the definition of <code>ChangeSecond_to_Third</code>. Then everything is OK.</p>
<p>The reason why the inverse transition maps are not automatically evaluated is that in certain cases Sage is not capable to compute them (the method <code>inverse()</code> returns then an error); the user has then to provide them by hand, via the method <a href="http://doc.sagemath.org/html/en/reference/manifolds/sage/manifolds/chart.html#sage.manifolds.chart.CoordChange.set_inverse">set_inverse()</a>.</p>
<p><strong>EDIT:</strong> actually, in the present case, the inverse transition maps should not be required to compute the expression of $g$ in the third frame. This will be fixed in the next release of SageMath, thanks to the Trac ticket <a href="https://trac.sagemath.org/ticket/28072">#28072</a>, which has been merged in SageMath 8.9.beta2.</p>
https://ask.sagemath.org/question/47660/changing-chart-multiple-times-in-sagemanifolds/?comment=48196#post-id-48196SageMath 8.9 is out now. You can check that your example works nicely with it.Sat, 05 Oct 2019 15:45:12 -0500https://ask.sagemath.org/question/47660/changing-chart-multiple-times-in-sagemanifolds/?comment=48196#post-id-48196Comment by my_screen_name for <p>The issue arises because you have not fully defined the transition maps on the manifold: the inverse maps are missing. You have to generate them by invoking</p>
<pre><code>ChangeFirst_to_Second.inverse()
</code></pre>
<p>just after the definition of <code>ChangeFirst_to_Second</code> and</p>
<pre><code>ChangeSecond_to_Third.inverse()
</code></pre>
<p>just after the definition of <code>ChangeSecond_to_Third</code>. Then everything is OK.</p>
<p>The reason why the inverse transition maps are not automatically evaluated is that in certain cases Sage is not capable to compute them (the method <code>inverse()</code> returns then an error); the user has then to provide them by hand, via the method <a href="http://doc.sagemath.org/html/en/reference/manifolds/sage/manifolds/chart.html#sage.manifolds.chart.CoordChange.set_inverse">set_inverse()</a>.</p>
<p><strong>EDIT:</strong> actually, in the present case, the inverse transition maps should not be required to compute the expression of $g$ in the third frame. This will be fixed in the next release of SageMath, thanks to the Trac ticket <a href="https://trac.sagemath.org/ticket/28072">#28072</a>, which has been merged in SageMath 8.9.beta2.</p>
https://ask.sagemath.org/question/47660/changing-chart-multiple-times-in-sagemanifolds/?comment=47669#post-id-47669@eric_g: Thanks for the further update, and I'm glad to learn this will be fixed in the next release.Fri, 30 Aug 2019 08:19:00 -0500https://ask.sagemath.org/question/47660/changing-chart-multiple-times-in-sagemanifolds/?comment=47669#post-id-47669Comment by eric_g for <p>The issue arises because you have not fully defined the transition maps on the manifold: the inverse maps are missing. You have to generate them by invoking</p>
<pre><code>ChangeFirst_to_Second.inverse()
</code></pre>
<p>just after the definition of <code>ChangeFirst_to_Second</code> and</p>
<pre><code>ChangeSecond_to_Third.inverse()
</code></pre>
<p>just after the definition of <code>ChangeSecond_to_Third</code>. Then everything is OK.</p>
<p>The reason why the inverse transition maps are not automatically evaluated is that in certain cases Sage is not capable to compute them (the method <code>inverse()</code> returns then an error); the user has then to provide them by hand, via the method <a href="http://doc.sagemath.org/html/en/reference/manifolds/sage/manifolds/chart.html#sage.manifolds.chart.CoordChange.set_inverse">set_inverse()</a>.</p>
<p><strong>EDIT:</strong> actually, in the present case, the inverse transition maps should not be required to compute the expression of $g$ in the third frame. This will be fixed in the next release of SageMath, thanks to the Trac ticket <a href="https://trac.sagemath.org/ticket/28072">#28072</a>, which has been merged in SageMath 8.9.beta2.</p>
https://ask.sagemath.org/question/47660/changing-chart-multiple-times-in-sagemanifolds/?comment=47668#post-id-47668@my_screen_name: you are right: in the current stable version of Sage (8.8), there are unnecessary restrictions in the handling of coordinate changes. This is fixed by the Trac ticket [#28072](https://trac.sagemath.org/ticket/28072), which has been merged in Sage 8.9.beta2. In particular, with run with Sage 8.9.beta8, your original code gives no error and displays $g = \mathrm{d}z\otimes\mathrm{d}z$ in the last line. I have edited my answer accordingly.Fri, 30 Aug 2019 04:24:58 -0500https://ask.sagemath.org/question/47660/changing-chart-multiple-times-in-sagemanifolds/?comment=47668#post-id-47668Comment by my_screen_name for <p>The issue arises because you have not fully defined the transition maps on the manifold: the inverse maps are missing. You have to generate them by invoking</p>
<pre><code>ChangeFirst_to_Second.inverse()
</code></pre>
<p>just after the definition of <code>ChangeFirst_to_Second</code> and</p>
<pre><code>ChangeSecond_to_Third.inverse()
</code></pre>
<p>just after the definition of <code>ChangeSecond_to_Third</code>. Then everything is OK.</p>
<p>The reason why the inverse transition maps are not automatically evaluated is that in certain cases Sage is not capable to compute them (the method <code>inverse()</code> returns then an error); the user has then to provide them by hand, via the method <a href="http://doc.sagemath.org/html/en/reference/manifolds/sage/manifolds/chart.html#sage.manifolds.chart.CoordChange.set_inverse">set_inverse()</a>.</p>
<p><strong>EDIT:</strong> actually, in the present case, the inverse transition maps should not be required to compute the expression of $g$ in the third frame. This will be fixed in the next release of SageMath, thanks to the Trac ticket <a href="https://trac.sagemath.org/ticket/28072">#28072</a>, which has been merged in SageMath 8.9.beta2.</p>
https://ask.sagemath.org/question/47660/changing-chart-multiple-times-in-sagemanifolds/?comment=47663#post-id-47663eric_g: Thanks for the answer. I assume it is correct, but it seems a surprising situation. Since $\psi_3\circ\psi_1^{-1} = (\psi_3\circ\psi_2^{-1})\circ(\psi_2\circ\psi_1^{-1})$, I don't see why the inverse maps should need to be defined. In particular, in the example I'm thinking of (converting standard Schwarzschild coordinates to Regge-Wheeler tortoise coordinates, then Eddington-Finkelstein null coordinates, and then Kruskal), it is impossible to invert the first coordinate transform. Does this mean that, while I can directly define a transition map from the first coordinate system to the third, I can't define it by going from the first to the second and then the second to the third? This seems like an unnecessary restriction.
rburing: I would also like clearer error message.Thu, 29 Aug 2019 16:39:32 -0500https://ask.sagemath.org/question/47660/changing-chart-multiple-times-in-sagemanifolds/?comment=47663#post-id-47663Comment by rburing for <p>The issue arises because you have not fully defined the transition maps on the manifold: the inverse maps are missing. You have to generate them by invoking</p>
<pre><code>ChangeFirst_to_Second.inverse()
</code></pre>
<p>just after the definition of <code>ChangeFirst_to_Second</code> and</p>
<pre><code>ChangeSecond_to_Third.inverse()
</code></pre>
<p>just after the definition of <code>ChangeSecond_to_Third</code>. Then everything is OK.</p>
<p>The reason why the inverse transition maps are not automatically evaluated is that in certain cases Sage is not capable to compute them (the method <code>inverse()</code> returns then an error); the user has then to provide them by hand, via the method <a href="http://doc.sagemath.org/html/en/reference/manifolds/sage/manifolds/chart.html#sage.manifolds.chart.CoordChange.set_inverse">set_inverse()</a>.</p>
<p><strong>EDIT:</strong> actually, in the present case, the inverse transition maps should not be required to compute the expression of $g$ in the third frame. This will be fixed in the next release of SageMath, thanks to the Trac ticket <a href="https://trac.sagemath.org/ticket/28072">#28072</a>, which has been merged in SageMath 8.9.beta2.</p>
https://ask.sagemath.org/question/47660/changing-chart-multiple-times-in-sagemanifolds/?comment=47662#post-id-47662Can we catch the `KeyError` and raise a more meaningful error message instead?Thu, 29 Aug 2019 15:39:25 -0500https://ask.sagemath.org/question/47660/changing-chart-multiple-times-in-sagemanifolds/?comment=47662#post-id-47662