# HG changeset patch
# User Burcin Erocal <burcin@erocal.org>
# Date 1371652151 7200
# Branch hyper
# Node ID 945065a8f66dd2d20a2875bb9d25a6780694913d
# Parent 7cb7a120682e5c26ab132b4728b3c73b434b3a1f
Fix doctests after ordering changes in Pynac.
diff git a/sage/functions/bessel.py b/sage/functions/bessel.py
a

b


99  99  sage: bessel_J(0, 0) 
100  100  bessel_J(0, 0) 
101  101  sage: bessel_J(0, x).diff(x) 
102   1/2*bessel_J(1, x)  1/2*bessel_J(1, x) 
 102  1/2*bessel_J(1, x) + 1/2*bessel_J(1, x) 
103  103  
104  104  sage: N(bessel_J(0, 0), digits = 20) 
105  105  1.0000000000000000000 
… 
… 

133  133  sage: a, b = var('a, b') 
134  134  sage: diffeq = x^2*diff(y,x,x) + x*diff(y,x) + x^2*y == 0 
135  135  sage: f = desolve(diffeq, y, [1, a, b]); f 
136   (a*bessel_Y(1, 1) + b*bessel_Y(0, 1))*bessel_J(0, x)/(bessel_J(0, 1)*bessel_Y(1, 1)  bessel_J(1, 1)*bessel_Y(0, 1))  (a*bessel_J(1, 1) + b*bessel_J(0, 1))*bessel_Y(0, x)/(bessel_J(0, 1)*bessel_Y(1, 1)  bessel_J(1, 1)*bessel_Y(0, 1)) 
 136  (a*bessel_Y(1, 1) + b*bessel_Y(0, 1))*bessel_J(0, x)/(bessel_J(0, 
 137  1)*bessel_Y(1, 1)  bessel_J(1, 1)*bessel_Y(0, 1))  
 138  (a*bessel_J(1, 1) + b*bessel_J(0, 1))*bessel_Y(0, x)/(bessel_J(0, 
 139  1)*bessel_Y(1, 1)  bessel_J(1, 1)*bessel_Y(0, 1)) 
 140  
137  141  
138  142  For more examples, see the docstring for :meth:`Bessel`. 
139  143  
… 
… 

246  250  
247  251  sage: f = bessel_J(2, x) 
248  252  sage: f.diff(x) 
249   1/2*bessel_J(1, x)  1/2*bessel_J(3, x) 
 253  1/2*bessel_J(3, x) + 1/2*bessel_J(1, x) 
250  254  
251  255  Comparison to a wellknown integral representation of `J_1(1)`:: 
252  256  
253  257  sage: A = numerical_integral(1/pi*cos(x  sin(x)), 0, pi) 
254   sage: A[0] 
 258  sage: A[0] # abs tol 1e14 
255  259  0.44005058574493355 
256  260  sage: bessel_J(1.0, 1.0)  A[0] < 1e15 
257  261  True 
… 
… 

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

419  423  
420  424  sage: f = bessel_Y(2, x) 
421  425  sage: f.diff(x) 
422   1/2*bessel_Y(1, x)  1/2*bessel_Y(3, x) 
 426  1/2*bessel_Y(3, x) + 1/2*bessel_Y(1, x) 
423  427  
424  428  High precision and complex valued inputs (see :trac:`4230`):: 
425  429  
… 
… 

515  519  
516  520  sage: f(x) = bessel_Y(10, x) 
517  521  sage: derivative(f, x) 
518   x > 1/2*bessel_Y(9, x)  1/2*bessel_Y(11, x) 
 522  x > 1/2*bessel_Y(11, x) + 1/2*bessel_Y(9, x) 
519  523  """ 
520  524  return (bessel_Y(n  1, x)  bessel_Y(n + 1, x)) / Integer(2) 
521  525  
… 
… 

563  567  
564  568  sage: f = bessel_I(2, x) 
565  569  sage: f.diff(x) 
566   1/2*bessel_I(1, x) + 1/2*bessel_I(3, x) 
 570  1/2*bessel_I(3, x) + 1/2*bessel_I(1, x) 
567  571  
568  572  Special identities that bessel_I satisfies:: 
569  573  
570  574  sage: bessel_I(1/2, x) 
571   sqrt(1/(pi*x))*sqrt(2)*sinh(x) 
 575  sqrt(2)*sqrt(1/(pi*x))*sinh(x) 
572  576  sage: eq = bessel_I(1/2, x) == bessel_I(0.5, x) 
573  577  sage: eq.test_relation() 
574  578  True 
575  579  sage: bessel_I(1/2, x) 
576   sqrt(1/(pi*x))*sqrt(2)*cosh(x) 
 580  sqrt(2)*sqrt(1/(pi*x))*cosh(x) 
577  581  sage: eq = bessel_I(1/2, x) == bessel_I(0.5, x) 
578  582  sage: eq.test_relation() 
579  583  True 
… 
… 

688  692  
689  693  sage: f(z) = bessel_I(10, x) 
690  694  sage: derivative(f, x) 
691   z > 1/2*bessel_I(9, x) + 1/2*bessel_I(11, x) 
 695  z > 1/2*bessel_I(11, x) + 1/2*bessel_I(9, x) 
692  696  """ 
693  697  return (bessel_I(n  1, x) + bessel_I(n + 1, x)) / Integer(2) 
694  698  
… 
… 

737  741  
738  742  sage: f = bessel_K(2, x) 
739  743  sage: f.diff(x) 
740   1/2*bessel_K(1, x) + 1/2*bessel_K(3, x) 
 744  1/2*bessel_K(3, x) + 1/2*bessel_K(1, x) 
741  745  
742  746  sage: bessel_K(1/2, x) 
743  747  bessel_K(1/2, x) 
744  748  sage: bessel_K(1/2, 1) 
745  749  bessel_K(1/2, 1) 
746  750  sage: bessel_K(1/2, 1) 
747   sqrt(pi)*sqrt(1/2)*e^(1) 
 751  sqrt(1/2)*sqrt(pi)*e^(1) 
748  752  
749  753  Examples of asymptotic behavior:: 
750  754  
… 
… 

873  877  
874  878  sage: f(x) = bessel_K(10, x) 
875  879  sage: derivative(f, x) 
876   x > 1/2*bessel_K(9, x) + 1/2*bessel_K(11, x) 
 880  x > 1/2*bessel_K(11, x) + 1/2*bessel_K(9, x) 
877  881  """ 
878  882  return (bessel_K(n  1, x) + bessel_K(n + 1, x)) / Integer(2) 
879  883  
… 
… 

951  955  
952  956  sage: f(x) = Bessel(0, 'J')(x) 
953  957  sage: derivative(f, x) 
954   x > 1/2*bessel_J(1, x)  1/2*bessel_J(1, x) 
 958  x > 1/2*bessel_J(1, x) + 1/2*bessel_J(1, x) 
955  959  sage: derivative(f, x, x) 
956   x > 1/4*bessel_J(2, x)  1/2*bessel_J(0, x) + 1/4*bessel_J(2, x) 
 960  x > 1/4*bessel_J(2, x)  1/2*bessel_J(0, x) + 1/4*bessel_J(2, x) 
957  961  
958  962  Verify that `J_0` satisfies Bessel's differential equation numerically 
959  963  using the ``test_relation()`` method:: 
… 
… 

979  983  sage: y = function('y', x) 
980  984  sage: diffeq = x^2*diff(y,x,x) + x*diff(y,x) + x^2*y == 0 
981  985  sage: f = desolve(diffeq, y, [1, 1, 1]); f 
982   (bessel_Y(0, 1) + bessel_Y(1, 1))*bessel_J(0, x)/(bessel_J(0, 1)*bessel_Y(1, 1)  bessel_J(1, 1)*bessel_Y(0, 1))  (bessel_J(0, 1) + bessel_J(1, 1))*bessel_Y(0, x)/(bessel_J(0, 1)*bessel_Y(1, 1)  bessel_J(1, 1)*bessel_Y(0, 1)) 
983   
 986  (bessel_Y(1, 1) + bessel_Y(0, 1))*bessel_J(0, x)/(bessel_J(0, 
 987  1)*bessel_Y(1, 1)  bessel_J(1, 1)*bessel_Y(0, 1))  (bessel_J(1, 
 988  1) + bessel_J(0, 1))*bessel_Y(0, x)/(bessel_J(0, 1)*bessel_Y(1, 1) 
 989   bessel_J(1, 1)*bessel_Y(0, 1)) 
984  990  sage: f.subs(x=1).n() # numerical verification 
985  991  1.00000000000000 
986  992  sage: fp = f.diff(x) 