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, 30 Jan 2021 23:43:42 +01002 sets of coordinates in EuclideanSpace?https://ask.sagemath.org/question/55500/2-sets-of-coordinates-in-euclideanspace/Hello,
I would like to work with 2 vectors in EuclideanSpace each having x1,y1,z1 and x2,y2,z2 coordinates. I will be needing to switch back and forth between cartesian and spherical coordinates as well.
As an example, say, (r1,0,0) -> (x1,y1,z1) while (r2,0,0)->(x2,y2,z2) in the same EuclideanSpace.
How would one work with multiple vectors (with independent coordinates) in EuclideanSpace?
Should one define 2 chart for spherical coordinates and 2 for cartesian coordinates?
Or should one create 2 different EuclideanSpace and combine them (if possible)?
Fri, 29 Jan 2021 21:28:08 +0100https://ask.sagemath.org/question/55500/2-sets-of-coordinates-in-euclideanspace/Answer by eric_g for <p>Hello,</p>
<p>I would like to work with 2 vectors in EuclideanSpace each having x1,y1,z1 and x2,y2,z2 coordinates. I will be needing to switch back and forth between cartesian and spherical coordinates as well.</p>
<p>As an example, say, (r1,0,0) -> (x1,y1,z1) while (r2,0,0)->(x2,y2,z2) in the same EuclideanSpace.</p>
<p>How would one work with multiple vectors (with independent coordinates) in EuclideanSpace?</p>
<p>Should one define 2 chart for spherical coordinates and 2 for cartesian coordinates? </p>
<p>Or should one create 2 different EuclideanSpace and combine them (if possible)?</p>
https://ask.sagemath.org/question/55500/2-sets-of-coordinates-in-euclideanspace/?answer=55510#post-id-55510In `EuclideanSpace`, there are three predefined coordinate charts, which are returned by the methods `cartesian_coordinates()`, `spherical_coordinates()` and `cylindrical_coordinates()`:
sage: E.<x,y,z> = EuclideanSpace()
sage: E.cartesian_coordinates()
Chart (E^3, (x, y, z))
sage: E.spherical_coordinates()
Chart (E^3, (r, th, ph))
sage: E.cylindrical_coordinates()
Chart (E^3, (rh, ph, z))
But you can define as many charts as you want by means of the method `chart()`. For instance:
sage: Cartes1.<x1, y1, z1> = E.chart()
sage: Cartes1
Chart (E^3, (x1, y1, z1))
To complete the construction, you have to specify the transition map from previously defined coordinates:
sage: Cartes_to_Cartes1 = E.cartesian_coordinates().transition_map(Cartes1, [x-2, y+3, z])
sage: Cartes_to_Cartes1.display()
x1 = x - 2
y1 = y + 3
z1 = z
as well as its inverse, either by asking Sage to compute it (method `inverse()`) or by specifying it by hand (method `set_inverse()`):
sage: Cartes_to_Cartes1.inverse().display()
x = x1 + 2
y = y1 - 3
z = z1
Then Sage can compute vector field components in the new coordinate frame:
sage: v = E.vector_field(x+z, y*z, x*y)
sage: v.display()
(x + z) e_x + y*z e_y + x*y e_z
sage: v.display(Cartes1)
(x1 + z1 + 2) d/dx1 + (y1 - 3)*z1 d/dy1 + ((x1 + 2)*y1 - 3*x1 - 6) d/dz1
For more details, see the [coordinate chart documentation](https://doc.sagemath.org/html/en/reference/manifolds/sage/manifolds/chart.html).Sat, 30 Jan 2021 12:27:46 +0100https://ask.sagemath.org/question/55500/2-sets-of-coordinates-in-euclideanspace/?answer=55510#post-id-55510Comment by curios_mind for <p>In <code>EuclideanSpace</code>, there are three predefined coordinate charts, which are returned by the methods <code>cartesian_coordinates()</code>, <code>spherical_coordinates()</code> and <code>cylindrical_coordinates()</code>:</p>
<pre><code>sage: E.<x,y,z> = EuclideanSpace()
sage: E.cartesian_coordinates()
Chart (E^3, (x, y, z))
sage: E.spherical_coordinates()
Chart (E^3, (r, th, ph))
sage: E.cylindrical_coordinates()
Chart (E^3, (rh, ph, z))
</code></pre>
<p>But you can define as many charts as you want by means of the method <code>chart()</code>. For instance:</p>
<pre><code>sage: Cartes1.<x1, y1, z1> = E.chart()
sage: Cartes1
Chart (E^3, (x1, y1, z1))
</code></pre>
<p>To complete the construction, you have to specify the transition map from previously defined coordinates:</p>
<pre><code>sage: Cartes_to_Cartes1 = E.cartesian_coordinates().transition_map(Cartes1, [x-2, y+3, z])
sage: Cartes_to_Cartes1.display()
x1 = x - 2
y1 = y + 3
z1 = z
</code></pre>
<p>as well as its inverse, either by asking Sage to compute it (method <code>inverse()</code>) or by specifying it by hand (method <code>set_inverse()</code>):</p>
<pre><code>sage: Cartes_to_Cartes1.inverse().display()
x = x1 + 2
y = y1 - 3
z = z1
</code></pre>
<p>Then Sage can compute vector field components in the new coordinate frame:</p>
<pre><code>sage: v = E.vector_field(x+z, y*z, x*y)
sage: v.display()
(x + z) e_x + y*z e_y + x*y e_z
sage: v.display(Cartes1)
(x1 + z1 + 2) d/dx1 + (y1 - 3)*z1 d/dy1 + ((x1 + 2)*y1 - 3*x1 - 6) d/dz1
</code></pre>
<p>For more details, see the <a href="https://doc.sagemath.org/html/en/reference/manifolds/sage/manifolds/chart.html">coordinate chart documentation</a>.</p>
https://ask.sagemath.org/question/55500/2-sets-of-coordinates-in-euclideanspace/?comment=55515#post-id-55515Thank you so much! this is really awesome. I love the way sagemath handle these things.Sat, 30 Jan 2021 23:43:42 +0100https://ask.sagemath.org/question/55500/2-sets-of-coordinates-in-euclideanspace/?comment=55515#post-id-55515