# HG changeset patch
# User Ethan Van Andel <evlutte@gmail.com>
# Date 1347401807 25200
# Node ID 5eff831f4f25bc1207ff283e13a229ddbaea028d
# Parent c936a538f8f7a9f7a468620541cb8d8032005892
trac 11273: Minor doc/polish fixes.
diff git a/sage/calculus/riemann.pyx b/sage/calculus/riemann.pyx
a

b


106  106  the origin of the unit disc. Note that ``a`` MUST be within 
107  107  the region in order for the results to be mathematically valid. 
108  108  
109   The following inputs must all be passed in as named parameters: 
 109  The following inputs may be passed in as named parameters: 
110  110  
111  111   ``N``  integer (default: ``500``), the number of collocation points 
112  112  used to compute the map. More points will give more accurate results, 
… 
… 

137  137  sage: f(t) = e^(I*t) 
138  138  sage: fprime(t) = I*e^(I*t) 
139  139  sage: m = Riemann_Map([f], [fprime], 0) # long time (4 sec) 
 140  sage: m.plot_colored() + m.plot_spiderweb() # long time 
 141  
 142  The exterior map for the unit circle:: 
 143  
 144  sage: m = Riemann_Map([f], [fprime], 0, exterior=True) # long time (4 sec) 
 145  sage: #spiderwebs are not supported for exterior maps 
 146  sage: m.plot_colored() # long time 
140  147  
141  148  The unit circle with a small hole:: 
142  149  
… 
… 

145  152  sage: hf(t) = 0.5*e^(I*t) 
146  153  sage: hfprime(t) = 0.5*I*e^(I*t) 
147  154  sage: m = Riemann_Map([f, hf], [fprime, hfprime], 0.5 + 0.5*I) 
148   sage: m.plot_colored() + m.plot_spiderweb() # long time 
 155  sage: #spiderweb and color plots cannot be added for multiply 
 156  sage: #connected regions. Instead we do this. 
 157  sage: m.plot_spiderweb(withcolor = True) # long time 
149  158  
150  159  A square:: 
151  160  
… 
… 

225  234  self.tk2[i] = self.tk[i] 
226  235  self.tk2[N] = TWOPI 
227  236  self.B = len(fs) # number of boundaries of the figure 
228   if exterior and (self.B > 1): 
 237  if self.exterior and (self.B > 1): 
229  238  raise ValueError( 
230  239  "The exterior map is undefined for multiply connected domains") 
231  240  cdef np.ndarray[COMPLEX_T,ndim=2] cps = np.zeros([self.B, N], 
… 
… 

244  253  for i in xrange(N): 
245  254  cps[k, i] = np.complex(fs[k](self.tk[i])) 
246  255  dps[k, i] = np.complex(fprimes[k](self.tk[i])) 
247   if exterior: 
 256  if self.exterior: 
248  257  xmax = (1/cps).real.max() 
249  258  xmin = (1/cps).real.min() 
250  259  ymax = (1/cps).imag.max() 
… 
… 

369  378  
370  379  INPUT: 
371  380  
372   The following inputs must all be passed in as named parameters: 
 381  The following inputs may be passed in as named parameters: 
373  382  
374  383   ``boundary``  integer (default: ``1``) if < 0, 
375  384  :meth:`get_theta_points` will return the points for all boundaries. 
… 
… 

699  708  
700  709  INPUT: 
701  710  
702   The following inputs must all be passed in as named parameters: 
 711  The following inputs may be passed in as named parameters: 
703  712  
704  713   ``plotjoined``  boolean (default: ``True``) If ``False``, 
705  714  discrete points will be drawn; otherwise they will be connected 
… 
… 

818  827  may exhibit erratic behavior near the boundary; if this occurs, 
819  828  decreasing ``linescale`` may mitigate the problem. 
820  829  
821   Note that this method requires significantly more computation for 
822   multiply connected domains. 
 830  For multiply connected domains the spiderweb is by necessity 
 831  generated using the forward mapping. This method is more 
 832  computationally intensive. In addition, these spiderwebs cannot 
 833  be ``added`` to color plots. Instead the ``withcolor`` option 
 834  must be used. 
 835  
 836  In addition, spiderweb plots are not currently supported for 
 837  exterior maps. 
823  838  
824  839  INPUT: 
825  840  
826   The following inputs must all be passed in as named parameters: 
 841  The following inputs may be passed in as named parameters: 
827  842  
828  843   ``spokes``  integer (default: ``16``) the number of equally 
829  844  spaced radial lines to plot. 
… 
… 

889  904  sage: m.plot_spiderweb() 
890  905  """ 
891  906  cdef int k, i 
 907  if self.exterior: 
 908  raise ValueError( 
 909  "Spiderwebs for exterior maps are not currently supported") 
892  910  if self.B == 1: #The efficient simply connected 
893  911  edge = self.plot_boundaries(plotjoined=plotjoined, 
894  912  rgbcolor=rgbcolor, thickness=thickness) 
… 
… 

955  973  
956  974  INPUT: 
957  975  
958   The following inputs must all be passed in as named parameters: 
 976  The following inputs may be passed in as named parameters: 
959  977  
960  978   ``plot_range``  (default: ``[]``) list of 4 values 
961  979  ``(xmin, xmax, ymin, ymax)``. Declare if you do not want the plot 
… 
… 

1076  1094  jmax = len(z_values[0])2 
1077  1095  #(f(x+delta)f(xdelta))/2delta 
1078  1096  xderiv = (z_values[1:1,2:]z_values[1:1,:2])/(2*xstep) 
1079   #b/c the function is analytic, we know its abs(derivative) is equal 
1080   #in all directions 
 1097  #b/c the function is analytic, we know the magnitude of its 
 1098  #derivative is equal in all directions 
1081  1099  dr = np.abs(xderiv) 
1082  1100  # the abs(derivative) scaled by distance from origin 
1083  1101  zabs = np.abs(z_values[1:1,1:1]) 
… 
… 

1301  1319  sig_off() 
1302  1320  return rgb 
1303  1321  
1304   cpdef analytic_boundary(FLOAT_T t, int n): 
 1322  cpdef analytic_boundary(FLOAT_T t, int n, FLOAT_T epsilon): 
1305  1323  """ 
1306  1324  Provides an exact (for n = infinity) Riemann boundary 
1307  1325  correspondence for the ellipse with axes 1 + epsilon and 1  epsilon. The 
… 
… 

1314  1332  
1315  1333   ``n``  integer  the number of terms to include. 
1316  1334  10 is fairly accurate, 20 is very accurate. 
 1335  
 1336   ``epsilon``  float  the skew of the ellipse (0 is circular) 
1317  1337  
1318  1338  OUTPUT: 
1319  1339  
… 
… 

1325  1345  Checking the accuracy of this function for different n values:: 
1326  1346  
1327  1347  sage: from sage.calculus.riemann import analytic_boundary 
1328   sage: t100 = analytic_boundary(pi/2,100) 
1329   sage: abs(analytic_boundary(pi/2,10)  t100) < 10^8 
 1348  sage: t100 = analytic_boundary(pi/2, 100, .3) 
 1349  sage: abs(analytic_boundary(pi/2, 10, .3)  t100) < 10^8 
1330  1350  True 
1331   sage: abs(analytic_boundary(pi/2,20)  t100) < 10^15 
 1351  sage: abs(analytic_boundary(pi/2, 20, .3)  t100) < 10^15 
1332  1352  True 
1333  1353  
1334  1354  Using this to check the accuracy of the Riemann_Map boundary:: 
… 
… 

1338  1358  sage: m = Riemann_Map([f], [fp],0,200) 
1339  1359  sage: s = spline(m.get_theta_points()) 
1340  1360  sage: test_pt = uniform(0,2*pi) 
1341   sage: s(test_pt)  analytic_boundary(test_pt,20) < 10^4 
 1361  sage: s(test_pt)  analytic_boundary(test_pt,20, .3) < 10^4 
1342  1362  True 
1343  1363  """ 
1344  1364  cdef FLOAT_T i 
1345  1365  cdef FLOAT_T result = t 
1346  1366  for i from 1 <= i < n+1: 
1347   result += (2*(1)**i/i)*(.3**i/(1+.3**(2*i)))*sin(2*i*t) 
 1367  result += (2*(1)**i/i)*(epsilon**i/(1+epsilon**(2*i)))*sin(2*i*t) 
1348  1368  return result 
1349  1369  
1350  1370  
… 
… 

1358  1378   ``t``  The boundary parameter, meant to be integrated over 
1359  1379  
1360  1380   ``args``  a tuple containing: 
 1381  
 1382   ``epsilon``  float  the skew of the ellipse (0 is circular) 
1361  1383  
1362  1384   ``z``  complex  the point to be mapped. 
1363  1385  
… 
… 

1373  1395  Here is a simple test:: 
1374  1396  
1375  1397  sage: from sage.calculus.riemann import cauchy_kernel 
1376   sage: cauchy_kernel(.5,(.1+.2*I, 10,'c')) 
 1398  sage: cauchy_kernel(.5,(.3, .1+.2*I, 10,'c')) 
1377  1399  (0.584136405997...+0.5948650858950...j) 
1378  1400  """ 
1379  1401  cdef COMPLEX_T result 
1380   cdef COMPLEX_T z = args[0] 
1381   cdef int n = args[1] 
1382   part = args[2] 
1383   result = exp(I*analytic_boundary(t,n))/(exp(I*t)+.3*exp(I*t)z) * \ 
1384   (I*exp(I*t)I*.3*exp(I*t)) 
 1402  cdef FLOAT_T epsilon = args[0] 
 1403  cdef COMPLEX_T z = args[1] 
 1404  cdef int n = args[2] 
 1405  part = args[3] 
 1406  result = exp(I*analytic_boundary(t,n, epsilon))/(exp(I*t)+epsilon*exp(I*t)z) * \ 
 1407  (I*exp(I*t)I*epsilon*exp(I*t)) 
1385  1408  if part == 'c': 
1386  1409  return result 
1387  1410  elif part == 'r': 
… 
… 

1390  1413  return result.imag 
1391  1414  else: return None 
1392  1415  
1393   cpdef analytic_interior(COMPLEX_T z, int n): 
 1416  cpdef analytic_interior(COMPLEX_T z, int n, FLOAT_T epsilon): 
1394  1417  """ 
1395  1418  Provides a nearly exact compuation of the Riemann Map of an interior 
1396  1419  point of the ellipse with axes 1 + epsilon and 1  epsilon. It is 
… 
… 

1411  1434  sage: f(t) = e^(I*t)+.3*e^(I*t) 
1412  1435  sage: fp(t) = I*e^(I*t)I*.3*e^(I*t) 
1413  1436  sage: m = Riemann_Map([f],[fp],0,200) 
1414   sage: abs(m.riemann_map(.5)analytic_interior(.5,20)) < 10^4 
 1437  sage: abs(m.riemann_map(.5)analytic_interior(.5, 20, .3)) < 10^4 
1415  1438  True 
1416  1439  sage: m = Riemann_Map([f],[fp],0,2000) 
1417   sage: abs(m.riemann_map(.5)analytic_interior(.5,20)) < 10^6 
 1440  sage: abs(m.riemann_map(.5)analytic_interior(.5, 20, .3)) < 10^6 
1418  1441  True 
1419  1442  """ 
1420  1443  # evaluates the cauchy integral of the boundary, split into the real 
1421  1444  # and imaginary results because numerical_integral can't handle complex data. 
1422  1445  rp = 1/(TWOPI)*numerical_integral(cauchy_kernel,0,2*pi, 
1423   params = [z,n,'i'])[0] 
 1446  params = [epsilon,z,n,'i'])[0] 
1424  1447  ip = 1/(TWOPI*I)*numerical_integral(cauchy_kernel,0,2*pi, 
1425   params = [z,n,'r'])[0] 
 1448  params = [epsilon,z,n,'r'])[0] 
1426  1449  return rp + ip 