Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Project: test
Views: 131
version()
SageMath version 7.5, Release Date: 2017-01-11
%typeset_mode True n = 6
Rn = Manifold(n, 'R^' + str(n), latex_name=r'\mathbb{R}^' + str(n), start_index=1) print(Rn) Rn
6-dimensional differentiable manifold R^6
R6\displaystyle \mathbb{R}^6
# The canonical global chart on R^n E = Rn.chart(coordinates=' '.join('x' + str(i) for i in Rn.irange())) print(E) E
Chart (R^6, (x1, x2, x3, x4, x5, x6))
(R6,(x1,x2,x3,x4,x5,x6))\displaystyle \left(\mathbb{R}^6,(x_{1}, x_{2}, x_{3}, x_{4}, x_{5}, x_{6})\right)
# Define the open subset on R^n where we will have polar coordinates and restric the canonical chart # we should actually exclude more in order to have diffeomorphism U = Rn.open_subset('U', coord_def={E: [sum(map(lambda x: x**2, E[:])) > 0]}) print(U) U E_U = E.restrict(U) print(E_U) E_U
Open subset U of the 6-dimensional differentiable manifold R^6
U\displaystyle U
Chart (U, (x1, x2, x3, x4, x5, x6))
(U,(x1,x2,x3,x4,x5,x6))\displaystyle \left(U,(x_{1}, x_{2}, x_{3}, x_{4}, x_{5}, x_{6})\right)
# Define another chart on U for the spherical coordinates #P_U = U.chart(r"r:(0,+oo) ph:(0,2*pi):\phi " + r" ".join("th" + str(i+1) + r":(0,pi):\theta_" + str(i+1) for i in range(Rn.dim() - 2))) P_U = U.chart(r"r:(0,+oo) " + r" ".join("th" + str(i) + r":(0,pi):\theta_" + str(i) for i in range(1, Rn.dim() - 1)) + r" th%d:(0,2*pi):\theta_%d" % (Rn.dim()-1, Rn.dim()-1)) print(P_U) P_U
Chart (U, (r, th1, th2, th3, th4, th5))
(U,(r,θ1,θ2,θ3,θ4,θ5))\displaystyle \left(U,(r, {\theta_1}, {\theta_2}, {\theta_3}, {\theta_4}, {\theta_5})\right)
P_U.coord_range()
r: (0,+);θ1: (0,π);θ2: (0,π);θ3: (0,π);θ4: (0,π);θ5: (0,2π)\displaystyle r :\ \left( 0 , +\infty \right) ;\quad {\theta_1} :\ \left( 0 , \pi \right) ;\quad {\theta_2} :\ \left( 0 , \pi \right) ;\quad {\theta_3} :\ \left( 0 , \pi \right) ;\quad {\theta_4} :\ \left( 0 , \pi \right) ;\quad {\theta_5} :\ \left( 0 , 2 \, \pi \right)
assumptions()
x1 is real x2 is real x3 is real x4 is real x5 is real x6 is real r is real th1 is real th2 is real th3 is real th4 is real th5 is real
[r>0\displaystyle r > 0, θ1>0\displaystyle {\theta_1} > 0, θ1<π\displaystyle {\theta_1} < \pi, θ2>0\displaystyle {\theta_2} > 0, θ2<π\displaystyle {\theta_2} < \pi, θ3>0\displaystyle {\theta_3} > 0, θ3<π\displaystyle {\theta_3} < \pi, θ4>0\displaystyle {\theta_4} > 0, θ4<π\displaystyle {\theta_4} < \pi, θ5>0\displaystyle {\theta_5} > 0, θ5<2π\displaystyle {\theta_5} < 2 \, \pi]
# Let's build the transition maps! # First a helper function... def p_to_e_x(i, P_U): # returns the ith coordinate of the transition function n = P_U.domain().dim() if i < n: return P_U[1]*prod(sin(P_U[j]) for j in range(2, i+1))*cos(P_U[i+1]) else: return P_U[1]*prod(sin(P_U[j]) for j in range(2, n+1)) for i in Rn.irange(): show(p_to_e_x(i, P_U)) mapping = [p_to_e_x(i, P_U) for i in Rn.irange()] %time transit_P_to_E = P_U.transition_map(E_U, mapping) transit_P_to_E.display()
rcos(θ1)\displaystyle r \cos\left({\theta_1}\right)
rcos(θ2)sin(θ1)\displaystyle r \cos\left({\theta_2}\right) \sin\left({\theta_1}\right)
rcos(θ3)sin(θ1)sin(θ2)\displaystyle r \cos\left({\theta_3}\right) \sin\left({\theta_1}\right) \sin\left({\theta_2}\right)
rcos(θ4)sin(θ1)sin(θ2)sin(θ3)\displaystyle r \cos\left({\theta_4}\right) \sin\left({\theta_1}\right) \sin\left({\theta_2}\right) \sin\left({\theta_3}\right)
rcos(θ5)sin(θ1)sin(θ2)sin(θ3)sin(θ4)\displaystyle r \cos\left({\theta_5}\right) \sin\left({\theta_1}\right) \sin\left({\theta_2}\right) \sin\left({\theta_3}\right) \sin\left({\theta_4}\right)
rsin(θ1)sin(θ2)sin(θ3)sin(θ4)sin(θ5)\displaystyle r \sin\left({\theta_1}\right) \sin\left({\theta_2}\right) \sin\left({\theta_3}\right) \sin\left({\theta_4}\right) \sin\left({\theta_5}\right)
CPU time: 148.43 s, Wall time: 153.18 s
{x1=rcos(θ1)x2=rcos(θ2)sin(θ1)x3=rcos(θ3)sin(θ1)sin(θ2)x4=rcos(θ4)sin(θ1)sin(θ2)sin(θ3)x5=rcos(θ5)sin(θ1)sin(θ2)sin(θ3)sin(θ4)x6=rsin(θ1)sin(θ2)sin(θ3)sin(θ4)sin(θ5)\displaystyle \left\{\begin{array}{lcl} x_{1} & = & r \cos\left({\theta_1}\right) \\ x_{2} & = & r \cos\left({\theta_2}\right) \sin\left({\theta_1}\right) \\ x_{3} & = & r \cos\left({\theta_3}\right) \sin\left({\theta_1}\right) \sin\left({\theta_2}\right) \\ x_{4} & = & r \cos\left({\theta_4}\right) \sin\left({\theta_1}\right) \sin\left({\theta_2}\right) \sin\left({\theta_3}\right) \\ x_{5} & = & r \cos\left({\theta_5}\right) \sin\left({\theta_1}\right) \sin\left({\theta_2}\right) \sin\left({\theta_3}\right) \sin\left({\theta_4}\right) \\ x_{6} & = & r \sin\left({\theta_1}\right) \sin\left({\theta_2}\right) \sin\left({\theta_3}\right) \sin\left({\theta_4}\right) \sin\left({\theta_5}\right) \end{array}\right.