# Revision history [back]

### Trouble with spheical coordinates in sagemanifolds

I'm probably doing something obviously wrong, but I'd appreciate help with the following.

theManifold = Manifold(3, 'M', r'\mathcal{M}')
theOpenSet = theManifold.open_subset('theOpenSet')
CartesianChart.<x,y,z> = theOpenSet.chart(r'x y z')
g = theManifold.lorentzian_metric('g')
g[0,0] = 1
g[1,1] = 1
g[2,2] = 1
show(g.display())
sphericalChart.<r,th,ph> = theOpenSet.chart(r'r th:(0,pi):\theta ph:(0,2*pi):\phi')

spherical_to_Cartesian = sphericalChart.transition_map(CartesianChart,[r*sin(th)*sin(ph),r*sin(th)*cos(ph),r*cos(th)])
Cartesian_to_spherical = spherical_to_Cartesian.inverse()


Sage then gives the error message "ValueError: no solution found; use set_inverse() to set the inverse manually".

If I replace the final two lines with

 Cartesian_to_spherical = CartesianChart.transition_map(sphericalChart[sqrt(x^2+y^2+z^2),arctan(z/sqrt(x^2+y^2)),arctan(y/x)])
spherical_to_Cartesian = Cartesian_to_spherical.inverse()


then Sage gives the following unable to make sense of Maxima expression '[if((-pi/2<parg(_sage_var_xxxx0))and(-pi 2<parg(-_sage_var_xxxx0="" sqrt((4<em="">e^(2I_SAGE_VAR_xxxx1))/(e^(4I*_SA ... [dozens of lines of similar] ... tan(_SAGE_VAR_xxxx1)^2+1)],union())]' in Sage.

I am aware that Sagemanifolds has native commands for using spherical coordinates. I'm attempting to work on a more complicated manifold, and this is is a minimal working example to demonstrate my problems.

 2 None FrédéricC 4199 ●3 ●37 ●85

### Trouble with spheical coordinates in sagemanifolds

I'm probably doing something obviously wrong, but I'd appreciate help with the following.

theManifold = Manifold(3, 'M', r'\mathcal{M}')
theOpenSet = theManifold.open_subset('theOpenSet')
CartesianChart.<x,y,z> = theOpenSet.chart(r'x y z')
g = theManifold.lorentzian_metric('g')
g[0,0] = 1
g[1,1] = 1
g[2,2] = 1
show(g.display())
sphericalChart.<r,th,ph> = theOpenSet.chart(r'r th:(0,pi):\theta ph:(0,2*pi):\phi')

spherical_to_Cartesian = sphericalChart.transition_map(CartesianChart,[r*sin(th)*sin(ph),r*sin(th)*cos(ph),r*cos(th)])
Cartesian_to_spherical = spherical_to_Cartesian.inverse()


Sage then gives the error message "ValueError: no solution found; use set_inverse() to set the inverse manually".

If I replace the final two lines with

 Cartesian_to_spherical = CartesianChart.transition_map(sphericalChart[sqrt(x^2+y^2+z^2),arctan(z/sqrt(x^2+y^2)),arctan(y/x)])
spherical_to_Cartesian = Cartesian_to_spherical.inverse()


then Sage gives the following unable to make sense of Maxima expression '[if((-pi/2<parg(_sage_var_xxxx0))and(-pi 2<parg(-_sage_var_xxxx0="" sqrt((4<em="">e^(2I_SAGE_VAR_xxxx1))/(e^(4I*_SA ... [dozens of lines of similar] ... tan(_SAGE_VAR_xxxx1)^2+1)],union())]' in Sage.

I am aware that Sagemanifolds has native commands for using spherical coordinates. I'm attempting to work on a more complicated manifold, and this is is a minimal working example to demonstrate my problems.