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.Tue, 10 May 2016 10:17:30 +0200Sub-manifold: bug or my misunderstanding?https://ask.sagemath.org/question/33345/sub-manifold-bug-or-my-misunderstanding/###Define a manifold and sub-manifold:
R2 = Manifold(2, 'R^2', start_index=1) # R^2
c_xy.<x,y> = R2.chart() # Cartesian coordinates on R^2
M = R2.open_subset('M', coord_def={c_xy: x>0 and y>0}) # First quadrant
###Test the coordinate restrictions:
R2.point((0,1)) in M; R2.point((0,0)) in M; R2.point((1,0)) in M; R2.point((1,1)) in M
###Result:
False
False
*True*
True
Question: Have I misunderstood how to restrict to the first quadrant, or have I stumbled on a bug? Tue, 10 May 2016 00:04:21 +0200https://ask.sagemath.org/question/33345/sub-manifold-bug-or-my-misunderstanding/Answer by eric_g for <h3>Define a manifold and sub-manifold:</h3>
<p>R2 = Manifold(2, 'R^2', start_index=1) # R^2 <br/>
c_xy.<x,y> = R2.chart() # Cartesian coordinates on R^2 <br/>
M = R2.open_subset('M', coord_def={c_xy: x>0 and y>0}) # First quadrant</p>
<h3>Test the coordinate restrictions:</h3>
<p>R2.point((0,1)) in M; R2.point((0,0)) in M; R2.point((1,0)) in M; R2.point((1,1)) in M</p>
<h3>Result:</h3>
<p>False
False
<em>True</em>
True</p>
<p>Question: Have I misunderstood how to restrict to the first quadrant, or have I stumbled on a bug? </p>
https://ask.sagemath.org/question/33345/sub-manifold-bug-or-my-misunderstanding/?answer=33346#post-id-33346Actually, you must declare the first quadrant as
M = R2.open_subset('M', coord_def={c_xy: [x>0, y>0]})
Then the output of your test is correct, i.e. it is False False *False* True.
Of course the syntax you used, i.e. `x>0 and y>0`, is more user friendly, and we should definitively implement it! For the time being, coordinate conditions passed as a list are combined with `and`, while those passed as a tuple are combined with `or`. For instance `[x>0, (y>2, y<-2)]` stands for `x>0 and (y>2 or y<-2)`. This is documented in the function `add_restrictions` on http://sagemanifolds.obspm.fr/doc/reference/manifolds/sage/manifolds/chart.html, but not in the function `open_subset`, as it should; sorry for the inconvenience.
Tue, 10 May 2016 10:17:30 +0200https://ask.sagemath.org/question/33345/sub-manifold-bug-or-my-misunderstanding/?answer=33346#post-id-33346