# HG changeset patch
# User Eviatar Bach <eviatarbach@gmail.com>
# Date 1371504787 25200
# Branch bessel
# Node ID 4bbd99ed8b181b3bf5cba868ff17a4b12d2b52db
# Parent 099567438c218d9efd28b3d06dbeb287305900e5
Trac 4102: adding to manual, fixing identity, adding SymPy conversions
diff git a/doc/en/reference/functions/index.rst b/doc/en/reference/functions/index.rst
a

b


4  4  .. toctree:: 
5  5  :maxdepth: 2 
6  6  
 7  sage/functions/bessel 
7  8  sage/functions/log 
8  9  sage/functions/hyperbolic 
9  10  sage/functions/transcendental 
diff git a/sage/functions/bessel.py b/sage/functions/bessel.py
a

b


2  2  Bessel Functions 
3  3  
4  4  This module provides symbolic Bessel Functions. These functions use the 
5   `mpmath Library`_ for numerical evaluation and Maxima, GiNaC, Pynac for 
 5  `mpmath library`_ for numerical evaluation and Maxima, GiNaC, Pynac for 
6  6  symbolics. 
7  7  
8  8  The main objects which are exported from this module are: 
9  9  
10   * `bessel_J`  The Bessel J function 
11   * `bessel_Y`  The Bessel J function 
12   * `bessel_I`  The Bessel J function 
13   * `bessel_K`  The Bessel J function 
14   * `Bessel`  A factory function for producing Bessel functions of 
15   various kinds and orders. 
 10  * ``bessel_J``  The Bessel J function 
 11  * ``bessel_Y``  The Bessel Y function 
 12  * ``bessel_I``  The Bessel I function 
 13  * ``bessel_K``  The Bessel K function 
 14  * ``Bessel``  A factory function for producing Bessel functions of 
 15  various kinds and orders 
16  16  
17  17   Bessel functions, first defined by the Swiss mathematician 
18  18  Daniel Bernoulli and named after Friedrich Bessel, are canonical 
… 
… 

20  20  
21  21  .. math:: 
22  22  
23   x^2 \frac{d^2 y}{dx^2} + x \frac{dy}{dx} + (x^2  \nu^2)y = 0, 
 23  x^2 \frac{d^2 y}{dx^2} + x \frac{dy}{dx} + \left(x^2  \nu^2\right)y = 
 24  0, 
24  25  
25   for an arbitrary real number `\nu` (the order). 
 26  for an arbitrary complex number `\nu` (the order). 
26  27  
27  28   In this module, `J_\nu` denotes the unique solution of Bessel's equation 
28  29  which is nonsingular at `x = 0`. This function is known as the Bessel 
… 
… 

138  139  
139  140  AUTHORS: 
140  141  
141    Benjamin Jones (20121227): initial version. 
 142   Benjamin Jones (20121227): initial version 
142  143  
143  144   Some of the documentation here has been adapted from David Joyner's 
144  145  original documentation of Sage's special functions module (2006). 
… 
… 

201  202  .. math:: 
202  203  
203  204  J_\nu(x) = \sum_{k=0}^\infty \frac{(1)^k}{k! \Gamma(k+\nu+1)} 
204   (\frac{x}{2})^{2k+\nu} 
 205  \left(\frac{x}{2}\right)^{2k+\nu} 
205  206  
206  207  The parameter `\nu` is called the order and may be any real or 
207   complex number, however the integer and halfinteger values are most 
 208  complex number; however, integer and halfinteger values are most 
208  209  common. It is defined for all complex numbers `x` when `\nu` 
209  210  is an integer or greater than zero and it diverges as `x \to 0` 
210  211  for negative noninteger values of `\nu`. 
… 
… 

220  221  
221  222  .. math:: 
222  223  
223   J_\nu(x) = \frac{x^n}{2^\nu \Gamma(\nu + 1)} {}_0F_1(\nu + 
224   1, \frac{x^2}{4}). 
 224  J_\nu(x) = \frac{x^n}{2^\nu \Gamma(\nu + 1)} {}_0F_1\left(\nu + 
 225  1, \frac{x^2}{4}\right). 
225  226  
226  227  EXAMPLES:: 
227  228  
… 
… 

288  289  bessel_J 
289  290  """ 
290  291  BuiltinFunction.__init__(self, "bessel_J", nargs=2, 
291   conversions=dict(maxima='bessel_j', 
292   mathematica='BesselJ')) 
 292  conversions=dict(mathematica='BesselJ', 
 293  maxima='bessel_j', 
 294  sympy='besselj')) 
293  295  
294  296  # remove after deprecation period 
295  297  def __call__(self, *args, **kwds): 
296  298  """ 
297   Custom `__call__` method which uses the old Bessel function code if the 
298   `algorithm` or `prec` arguments are used. This should be removed after 
299   the deprecation period. 
 299  Custom ``__call__`` method which uses the old Bessel function code if 
 300  the ``algorithm`` or ``prec`` arguments are used. This should be 
 301  removed after the deprecation period. 
300  302  
301  303  EXAMPLES:: 
302  304  
… 
… 

355  357  sage: derivative(f, z) 
356  358  z > 1/2*bessel_J(9, z)  1/2*bessel_J(11, z) 
357  359  """ 
358   return (bessel_J(n1, x)  bessel_J(n+1, x))/Integer(2) 
 360  return (bessel_J(n  1, x)  bessel_J(n + 1, x)) / Integer(2) 
359  361  
360  362  def _print_latex_(self, n, z): 
361  363  """ 
… 
… 

448  450  bessel_Y(0, x) 
449  451  """ 
450  452  BuiltinFunction.__init__(self, "bessel_Y", nargs=2, 
451   conversions=dict(maxima='bessel_y', 
452   mathematica='BesselY')) 
 453  conversions=dict(mathematica='BesselY', 
 454  maxima='bessel_y', 
 455  sympy='bessely')) 
453  456  
454  457  # remove after deprecation period 
455  458  def __call__(self, *args, **kwds): 
456  459  """ 
457   Custom `__call__` method which uses the old Bessel function code if the 
458   `algorithm` or `prec` arguments are used. This should be removed after 
459   the deprecation period. 
 460  Custom ``__call__`` method which uses the old Bessel function code if 
 461  the ``algorithm`` or ``prec`` arguments are used. This should be 
 462  removed after the deprecation period. 
460  463  
461  464  EXAMPLES:: 
462  465  
… 
… 

514  517  sage: derivative(f, x) 
515  518  x > 1/2*bessel_Y(9, x)  1/2*bessel_Y(11, x) 
516  519  """ 
517   return (bessel_Y(n1, x)  bessel_Y(n+1, x))/Integer(2) 
 520  return (bessel_Y(n  1, x)  bessel_Y(n + 1, x)) / Integer(2) 
518  521  
519  522  def _print_latex_(self, n, z): 
520  523  """ 
… 
… 

611  614  bessel_I(1, x) 
612  615  """ 
613  616  BuiltinFunction.__init__(self, "bessel_I", nargs=2, 
614   conversions=dict(maxima='bessel_i', 
615   mathematica='BesselI')) 
 617  conversions=dict(mathematica='BesselI', 
 618  maxima='bessel_i', 
 619  sympy='besseli')) 
616  620  
617  621  # remove after deprecation period 
618  622  def __call__(self, *args, **kwds): 
619  623  """ 
620   Custom `__call__` method which uses the old Bessel function code if the 
621   `algorithm` or `prec` arguments are used. This should be removed after 
622   the deprecation period. 
 624  Custom ``__call__`` method which uses the old Bessel function code if 
 625  the ``algorithm`` or ``prec`` arguments are used. This should be 
 626  removed after the deprecation period. 
623  627  
624  628  EXAMPLES:: 
625  629  
… 
… 

658  662  return self._evalf_(n, x, parent(n)) 
659  663  
660  664  # special identities 
661   if n == Integer(1)/Integer(2): 
662   return sqrt(2/(pi*x))*sinh(x) 
663   elif n == Integer(1)/Integer(2): 
664   return sqrt(2/(pi*x))*cosh(x) 
 665  if n == Integer(1) / Integer(2): 
 666  return sqrt(2 / (pi * x)) * sinh(x) 
 667  elif n == Integer(1) / Integer(2): 
 668  return sqrt(2 / (pi * x)) * cosh(x) 
665  669  
666  670  return None # leaves the expression unevaluated 
667  671  
… 
… 

677  681  
678  682  def _derivative_(self, n, x, diff_param=None): 
679  683  """ 
680   Return the derivative of the Bessel I function `I_n(x)` with repect 
 684  Return the derivative of the Bessel I function `I_n(x)` with respect 
681  685  to `x`. 
682  686  
683  687  EXAMPLES:: 
… 
… 

686  690  sage: derivative(f, x) 
687  691  z > 1/2*bessel_I(9, x) + 1/2*bessel_I(11, x) 
688  692  """ 
689   return (bessel_I(n1, x) + bessel_I(n+1, x))/Integer(2) 
 693  return (bessel_I(n  1, x) + bessel_I(n + 1, x)) / Integer(2) 
690  694  
691  695  def _print_latex_(self, n, z): 
692  696  """ 
… 
… 

799  803  bessel_K 
800  804  """ 
801  805  BuiltinFunction.__init__(self, "bessel_K", nargs=2, 
802   conversions=dict(maxima='bessel_k', 
803   mathematica='BesselK')) 
 806  conversions=dict(mathematica='BesselK', 
 807  maxima='bessel_k', 
 808  sympy='besselk')) 
804  809  
805  810  # remove after deprecation period 
806  811  def __call__(self, *args, **kwds): 
807  812  """ 
808   Custom `__call__` method which uses the old Bessel function code if the 
809   `algorithm` or `prec` arguments are used. This should be removed after 
810   the deprecation period. 
 813  Custom ``__call__`` method which uses the old Bessel function code if 
 814  the ``algorithm`` or ``prec`` arguments are used. This should be 
 815  removed after the deprecation period. 
811  816  
812  817  EXAMPLES:: 
813  818  
… 
… 

843  848  return self._evalf_(n, x, parent(n)) 
844  849  
845  850  # special identity 
846   if n == Integer(1)/Integer(2) and x > 0: 
847   return sqrt(pi/2)*exp(x)*x**(Integer(1)/Integer(2)) 
 851  if n == Integer(1) / Integer(2) and x > 0: 
 852  return sqrt(pi / 2) * exp(x) * x ** (Integer(1) / Integer(2)) 
848  853  
849  854  return None # leaves the expression unevaluated 
850  855  
… 
… 

870  875  sage: derivative(f, x) 
871  876  x > 1/2*bessel_K(9, x) + 1/2*bessel_K(11, x) 
872  877  """ 
873   return (bessel_K(n1, x) + bessel_K(n+1, x))/Integer(2) 
 878  return (bessel_K(n  1, x) + bessel_K(n + 1, x)) / Integer(2) 
874  879  
875  880  def _print_latex_(self, n, z): 
876  881  """ 
… 
… 

902  907  function 
903  908   ``Bessel()``  order is unspecified, type is 'J' 
904  909  
905   where `order` can be any integer and T must be one of the strings 'I', 'J', 
906   'K', or 'Y'. 
 910  where ``order`` can be any integer and T must be one of the strings 'I', 
 911  'J', 'K', or 'Y'. 
907  912  
908  913  See the EXAMPLES below. 
909  914  
… 
… 

1049  1054  _system = 'mpmath' 
1050  1055  
1051  1056  # return the function 
1052   # TODO remove assertions 
1053   assert _type in ['I', 'J', 'K', 'Y'] 
1054   assert _order is None or _order in RR 
1055   assert _nargs == 1 or _nargs == 2 
1056   assert _system == 'mpmath' 
1057   
1058   # TODO what to do with _system? 
1059  1057  _f = bessel_type_dict[_type] 
1060  1058  if _nargs == 1: 
1061  1059  return lambda x: _f(_order, x) 