Ticket #3431: trac3431-qepcad-interface-part2.patch
| File trac3431-qepcad-interface-part2.patch, 5.7 kB (added by cwitty, 5 months ago) |
|---|
-
a/sage/interfaces/qepcad.py
old new 208 208 with. We'll start by finding a point on our ellipse. 209 209 210 210 sage: p = qepcad(ellipse == 0, solution='any-point'); p 211 {'y': [0.96850196850295267 .. 0.96850196850295279], 'x': [-1.4685019685029528 .. -1.4685019685029525]}211 {'y': 0.9685019685029527?, 'x': -1.468501968502953?} 212 212 213 (Note that despite appearances, these are really exact numbers.) 213 (Note that despite the decimal printing and the question marks, these 214 are really exact numbers.) 214 215 215 216 We can verify that this point is a solution. To do so, we create 216 217 a copy of ellipse as a polynomial over QQ (instead of a symbolic … … 223 224 For cell-points, let's look at points \emph{not} on the ellipse. 224 225 225 226 sage: pts = qepcad(ellipse != 0, solution='cell-points'); pts 226 [{'y': 0, 'x': 4}, {'y': 1, 'x': [2.4685019685029523 .. 2.4685019685029528]}, {'y': -9, 'x': [2.4685019685029523 .. 2.4685019685029528]}, {'y': 9, 'x': 1/2}, {'y': -1, 'x': 1/2}, {'y': -5, 'x': 1/2}, {'y': 3, 'x': [-1.4685019685029528 .. -1.4685019685029525]}, {'y': -1, 'x': [-1.4685019685029528 .. -1.4685019685029525]}, {'y': 0, 'x': -3}]227 [{'y': 0, 'x': 4}, {'y': 1, 'x': 2.468501968502953?}, {'y': -9, 'x': 2.468501968502953?}, {'y': 9, 'x': 1/2}, {'y': -1, 'x': 1/2}, {'y': -5, 'x': 1/2}, {'y': 3, 'x': -1.468501968502953?}, {'y': -1, 'x': -1.468501968502953?}, {'y': 0, 'x': -3}] 227 228 228 229 For the points here which are in full-dimensional cells, QEPCAD has the 229 230 freedom to choose rational sample points, and it does so. … … 239 240 sage: F = qf.exactly_k(3, y, circle * ellipse == 0); F 240 241 (X3 y)[(y^2 + x^2 - 3) (y^2 + 2 x y + y + 3 x^2 - x - 7) = 0] 241 242 sage: pts = qepcad(F, solution='all-points'); pts 242 [{'x': [1.7320508075688771 .. 1.7320508075688775]}, {'x': [1.7310549134625334 .. 1.7310549134625338]}, {'x': [0.67891138420800389 .. 0.67891138420800401]}, {'x': [-0.94177273774171678 .. -0.94177273774171665]}, {'x': [-1.4681935599288210 .. -1.4681935599288207]}, {'x': [-1.4685019685029528 .. -1.4685019685029525]}]243 [{'x': 1.732050807568878?}, {'x': 1.731054913462534?}, {'x': 0.6789113842080040?}, {'x': -0.9417727377417167?}, {'x': -1.4681935599288208?}, {'x': -1.468501968502953?}] 243 244 244 245 Since $y$ is bound by the quantifier, the solutions only refer to $x$. 245 246 … … 248 249 sage: pt = pts[0] 249 250 sage: pcombo = QQ['x,y'](circle * ellipse) 250 251 sage: intersections = pcombo(y=polygen(AA, 'y'), **pt); intersections 251 y^4 + [4.4641016151377543 .. 4.4641016151377553]*y^3 + [0.26794919243112269 .. 0.26794919243112276]*y^2252 y^4 + 4.464101615137755?*y^3 + 0.2679491924311228?*y^2 252 253 253 254 and verify that it does have three roots: 254 255 255 256 sage: intersections.roots() 256 [( [-4.4032490056009586 .. -4.4032490056009576], 1), ([-0.060852609536796533 .. -0.060852609536796525], 1), ([0.00000000000000000 .. 0.00000000000000000], 2)]257 [(-4.403249005600958?, 1), (-0.06085260953679653?, 1), (0, 2)] 257 258 258 259 Let's check all six solutions. 259 260 … … 407 408 as \sage algebraic real numbers. 408 409 409 410 sage: c.sample_point() 410 (0, [1.7320508075688771 .. 1.7320508075688775])411 (0, 1.732050807568878?) 411 412 sage: c.sample_point_dict() 412 {'y': [1.7320508075688771 .. 1.7320508075688775], 'x': 0}413 {'y': 1.732050807568878?, 'x': 0} 413 414 414 415 We've seen that we can get cells using the \method{cell} method. 415 416 There are several QEPCAD commands that print lists of cells; we can … … 1010 1011 1011 1012 EXAMPLES: 1012 1013 sage: qe = qepcad(x^2 < 0, interact=True) # optional 1013 sage: len(qe.trait_names()) # optional 1014 9 51014 sage: len(qe.trait_names()) # optional, random 1015 97 1015 1016 sage: 'd_cell' in qe.trait_names() # optional 1016 1017 True 1017 1018 """ … … 1487 1488 Return a string containing the current QEPCAD version number. 1488 1489 1489 1490 EXAMPLES: 1491 sage: qepcad_version() # optional, random 1492 'Version B 1.48, 25 Oct 2007' 1493 1494 TESTS: 1490 1495 sage: qepcad_version() # optional 1491 'Version B 1.48, 25 Oct 2007'1496 'Version B ..., ...' 1492 1497 """ 1493 1498 banner = str(qepcad_banner()) 1494 1499 lines = banner.split('\n') … … 2038 2043 EXAMPLES: 2039 2044 sage: from sage.interfaces.qepcad import _eval_qepcad_algebraic 2040 2045 sage: x = _eval_qepcad_algebraic('the unique root of 8 x^2 - 8 x - 29 between -47/32 and -1503/1024'); x 2041 [-1.4685019685029528 .. -1.4685019685029525]2046 -1.468501968502953? 2042 2047 sage: 8*x^2 - 8*x - 29 == 0 2043 2048 True 2044 2049 """ … … 2396 2401 QEPCAD object has moved to phase 'Before Choice' 2397 2402 QEPCAD object has moved to phase 'Before Solution' 2398 2403 sage: v1 = qe.cell(2).sample_point()[0]; v1 # optional 2399 [-0.61803398874989491 .. -0.61803398874989479]2404 -0.6180339887498948? 2400 2405 sage: v2 = qe.cell(4).sample_point()[0]; v2 # optional 2401 [1.6180339887498946 .. 1.6180339887498950]2406 1.618033988749895? 2402 2407 sage: v1 + v2 == 1 # optional 2403 2408 True 2404 2409 """ … … 2440 2445 QEPCAD object has moved to phase 'Before Choice' 2441 2446 QEPCAD object has moved to phase 'Before Solution' 2442 2447 sage: qe.cell(4).sample_point_dict() # optional 2443 {'x': [1.6180339887498946 .. 1.6180339887498950]}2448 {'x': 1.618033988749895?} 2444 2449 """ 2445 2450 points = self.sample_point() 2446 2451 # from sage.calculus.calculus.var import var