Ticket #3813: 3813-diff.patch
| File 3813-diff.patch, 5.4 KB (added by ncalexan, 5 years ago) |
|---|
-
sage/plot/plot.py
a b 3419 3419 adaptive_recursion -- (default: 5) how many levels of recursion to go 3420 3420 before giving up when doing adaptive refinement. 3421 3421 Setting this to 0 disables adaptive refinement. 3422 adaptive_tolerance -- how large a difference should be before the 3423 adaptive refinement code considers it significant. 3424 This depends on the interval you use by default. 3422 adaptive_tolerance -- (default: 0.01) how large a difference should be 3423 before the adaptive refinement code considers it 3424 significant. Use a smaller value for smoother 3425 plots and a larger value for coarser plots. In 3426 general, adjust adaptive_recursion before 3427 adaptive_tolerance, and consult the code of 3428 adaptive_refinement for the details. 3429 3425 3430 xmin -- starting x value 3426 3431 xmax -- ending x value 3427 3432 color -- an rgb-tuple (r,g,b) with each of r,g,b between 0 and 1, or … … 3559 3564 def _reset(self): 3560 3565 o = self.options 3561 3566 o['plot_points'] = 200 3567 o['adaptive_tolerance'] = 0.01 3562 3568 o['adaptive_recursion'] = 5 3563 3569 o['rgbcolor'] = (0,0,1) 3564 3570 … … 3695 3701 warnings.warn("plot_division is deprecated. See adaptive_recursion in the documentation for plot()", DeprecationWarning, stacklevel=3) 3696 3702 # adaptive refinement 3697 3703 i, j = 0, 0 3698 if 'adaptive_tolerance' in options: 3699 adaptive_tolerance = float(options['adaptive_tolerance']) 3700 del options['adaptive_tolerance'] 3701 else: 3702 adaptive_tolerance = delta * 0.01 3704 adaptive_tolerance = delta * float(options['adaptive_tolerance']) 3705 del options['adaptive_tolerance'] 3703 3706 adaptive_recursion = int(options['adaptive_recursion']) 3704 3707 del options['adaptive_recursion'] 3705 3708 3706 3709 while i < len(data) - 1: 3707 3710 for p in adaptive_refinement(f, data[i], data[i+1], 3708 adaptive_tolerance, adaptive_recursion): 3711 adaptive_tolerance=adaptive_tolerance, 3712 adaptive_recursion=adaptive_recursion): 3709 3713 data.insert(i+1, p) 3710 3714 i += 1 3711 3715 i += 1 … … 4498 4502 adaptive_recursion -- (default: 10) how many levels of recursion to go 4499 4503 before giving up when doing adaptive refinement. 4500 4504 Setting this to 0 disables adaptive refinement. 4501 adaptive_tolerance -- (default 0.01) how large a difference should be4505 adaptive_tolerance -- (default: 0.01) how large a difference should be 4502 4506 before the adaptive refinement code considers 4503 it significant. 4507 it significant. See the documentation for 4508 plot() for more information. 4504 4509 4505 4510 OUTPUT: 4506 4511 list -- a list of points to insert between p1 and p2 to get … … 4508 4513 4509 4514 TESTS: 4510 4515 sage: from sage.plot.plot import adaptive_refinement 4511 sage: adaptive_refinement(sin, (0,0), (pi,0), 0.01, level=10)4516 sage: adaptive_refinement(sin, (0,0), (pi,0), adaptive_tolerance=0.01, level=10) 4512 4517 [] 4513 sage: adaptive_refinement(sin, (0,0), (pi,0), 0.01) 4514 [(0.125000000000000*pi, 0.38268343236508978), (0.187500000000000*pi, 0.55557023301960218), (0.250000000000000*pi, 0.70710678118654757), (0.312500000000000*pi, 0.83146961230254524), (0.375000000000000*pi, 0.92387953251128674), (0.437500000000000*pi, 0.98078528040323043), (0.500000000000000*pi, 1.0), (0.562500000000000*pi, 0.98078528040323043), (0.625000000000000*pi, 0.92387953251128674), (0.687500000000000*pi, 0.83146961230254546), (0.750000000000000*pi, 0.70710678118654757), (0.812500000000000*pi, 0.55557023301960218), (0.875000000000000*pi, 0.38268343236508989)] 4518 sage: adaptive_refinement(sin, (0,0), (pi,0), adaptive_tolerance=0.01) 4519 [(0.125000000000000*pi, 0.38268343236508978), (0.187500000000000*pi, 0.55557023301960218), (0.250000000000000*pi, 0.707106781186547...), (0.312500000000000*pi, 0.83146961230254524), (0.375000000000000*pi, 0.92387953251128674), (0.437500000000000*pi, 0.98078528040323043), (0.500000000000000*pi, 1.0), (0.562500000000000*pi, 0.98078528040323043), (0.625000000000000*pi, 0.92387953251128674), (0.687500000000000*pi, 0.83146961230254546), (0.750000000000000*pi, 0.70710678118654757), (0.812500000000000*pi, 0.55557023301960218), (0.875000000000000*pi, 0.38268343236508989)] 4520 4521 This shows that lowering adaptive_tolerance and raising 4522 adaptive_recursion both increase the number of subdivision points: 4523 4524 sage: x = var('x') 4525 sage: f = sin(1/x) 4526 sage: n1 = len(adaptive_refinement(f, (0,0), (pi,0), adaptive_tolerance=0.01)); n1 4527 79 4528 sage: n2 = len(adaptive_refinement(f, (0,0), (pi,0), adaptive_recursion=5, adaptive_tolerance=0.01)); n2 4529 15 4530 sage: n1 > n2 4531 True 4532 4533 sage: n3 = len(adaptive_refinement(f, (0,0), (pi,0), adaptive_tolerance=0.005)); n3 4534 88 4535 sage: n1 < n3 4536 True 4515 4537 """ 4516 4538 if level >= adaptive_recursion: 4517 4539 return []
