Ticket #12455: trac_12455-symbolic_airy3.patch

File trac_12455-symbolic_airy3.patch, 23.0 KB (added by olazo, 7 years ago)
  • new file sage/functions/airy.py

    # HG changeset patch
    # User Oscar Gerardo Lazo Arjona <algebraicamente@gmail.com>
    # Date 1329849284 21600
    # Node ID bdc9f1b2d4c2cfcb39cc8b39541e14b1968b49df
    # Parent  2a2abbcad325ccca9399981ceddf5897eb467e64
    #12455 Make Airy functions symbolic
    
    diff -r 2a2abbcad325 -r bdc9f1b2d4c2 sage/functions/airy.py
    - +  
     1#*****************************************************************************
     2#       Copyright (C) 2010 Oscar Gerardo Lazo Arjona algebraicamente@gmail.com
     3#
     4#  Distributed under the terms of the GNU General Public License (GPL)
     5#
     6#    but WITHOUT ANY WARRANTY; without even the implied warranty of
     7#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     8#    General Public License for more details.
     9#
     10#  The full text of the GPL is available at:
     11#
     12#                  http://www.gnu.org/licenses/
     13#*****************************************************************************
     14
     15from sage.symbolic.function import BuiltinFunction
     16from sage.symbolic.expression import Expression
     17from sage.symbolic.function import is_inexact
     18from sage.structure.coerce import parent
     19
     20from sage.functions.other import gamma
     21from mpmath import airyai as airy_ai_mpmath
     22from mpmath import airybi as airy_bi_mpmath
     23from sage.libs.mpmath import utils as mpmath_utils
     24
     25from sage.calculus.var import var
     26from sage.calculus.functional import derivative
     27
     28from sage.rings.real_mpfr import RR
     29from sage.rings.rational import Rational as R
     30
     31class FunctionAiryAiGeneral(BuiltinFunction):
     32    def __init__(self):
     33        r"""
     34        The generalized derivative of the Airy Ai function
     35
     36        INPUT:
     37       
     38        - ``alpha``.- Return the `\alpha`-th order fractional derivative with respect to `z`. For `\alpha = n = 1,2,3,\ldots` this gives the derivative `\operatorname{Ai}^{(n)}(z)`, and for `\alpha = -n = -1,-2,-3,\ldots` this gives the `n`-fold iterated integral
     39         
     40        .. math ::
     41         
     42            f_0(z) = \operatorname{Ai}(z)
     43         
     44            f_n(z) = \int_0^z f_{n-1}(t) dt.
     45
     46        - ``x``.- The argument of the function.
     47
     48        - ``hold``.- Whether or not to stop from returning higher derivatives in terms of `\operatorname{Ai}(x)` and `\operatorname{Ai}'(x)`.
     49       
     50        EXAMPLES::
     51
     52            sage: x,n=var('x n')
     53            sage: airy_ai(-2,x)
     54            airy_ai(-2, x)
     55            sage: derivative(airy_ai(-2,x),x)
     56            airy_ai(-1, x)
     57            sage: airy_ai(n,x)
     58            airy_ai(n, x)
     59            sage: derivative(airy_ai(n,x),x)
     60            airy_ai(n + 1, x)
     61            sage: airy_ai(2,x,True)
     62            airy_ai(2, x)
     63            sage: derivative(airy_ai(2,x,hold_derivative=True),x)
     64            airy_ai(3, x)
     65        """
     66
     67        BuiltinFunction.__init__(self, "airy_ai", nargs=2,
     68                latex_name=r"\operatorname{Ai}")
     69
     70    def _derivative_(self, alpha, *args, **kwds):
     71        """
     72        EXAMPLES::
     73
     74            sage: x,n=var('x n')
     75            sage: derivative(airy_ai(n,x),x) # indirect doctest
     76            airy_ai(n + 1, x)
     77        """
     78
     79        x=args[0]
     80        return airy_ai_general(alpha+1,x)
     81
     82    def _eval_(self, alpha, *args):
     83        """
     84        EXAMPLES::
     85
     86            sage: x,n=var('x n')
     87            sage: airy_ai(-2,1.0) # indirect doctest
     88            0.136645379421096
     89            sage: airy_ai(n,1.0) # indirect doctest
     90            airy_ai(n, 1.00000000000000)
     91        """
     92
     93       
     94        x=args[0]
     95        if not isinstance(x,Expression) and not isinstance(alpha,Expression):
     96            if is_inexact(x):
     97                return self._evalf_(alpha,x, parent(x))
     98        else:
     99            return None
     100
     101    def _evalf_(self, alpha, x, parent=None):
     102        """
     103        EXAMPLES::
     104            sage: airy_ai(-2,1.0) # indirect doctest
     105            0.136645379421096           
     106        """
     107        return mpmath_utils.call(airy_ai_mpmath, x, derivative=alpha, parent=RR)
     108
     109class FunctionAiryAiSimple(BuiltinFunction):
     110    def __init__(self):
     111        """
     112        The class for the Airy Ai function.
     113
     114        EXAMPLES::
     115
     116            sage: airy_ai_simple= FunctionAiryAiSimple()
     117            sage: f=airy_ai_simple(x); f
     118            airy_ai(x)
     119        """
     120
     121        BuiltinFunction.__init__(self, "airy_ai", latex_name=r'\operatorname{Ai}',
     122                conversions=dict(mathematica='AiryAi'))
     123
     124    def _derivative_(self, x, diff_param=None):
     125        """
     126        EXAMPLES::
     127       
     128            sage: derivative(airy_ai(x),x) # indirect doctest
     129            airy_ai_prime(x)
     130        """
     131        return airy_ai_prime(x)
     132
     133    def _eval_(self, x):
     134        """
     135        EXAMPLES::
     136       
     137            sage: airy_ai(0) # indirect doctest
     138            1/3*3^(1/3)/gamma(2/3)
     139            sage: airy_ai(0.0) # indirect doctest
     140            0.355028053887817
     141            sage: airy_ai(I) # indirect doctest
     142            airy_ai(I)
     143            sage: airy_ai(1.0*I) # indirect doctest
     144            0.331493305432141 - 0.317449858968444*I
     145        """
     146
     147        if not isinstance(x,Expression):
     148            if is_inexact(x):
     149                return self._evalf_(x, parent(x))
     150            elif x==0:
     151                r=R('2/3')
     152                return 1/(3**(r)*gamma(r))
     153        else:
     154            return None
     155
     156    def _evalf_(self, x, parent=None):
     157        """
     158        EXAMPLES::
     159       
     160            sage: airy_ai(0.0) # indirect doctest
     161            0.355028053887817
     162            sage: airy_ai(1.0*I) # indirect doctest
     163            0.331493305432141 - 0.317449858968444*I
     164        """
     165        return mpmath_utils.call(airy_ai_mpmath, x, parent=RR)
     166
     167class FunctionAiryAiPrime(BuiltinFunction):
     168    def __init__(self):
     169        """
     170        The derivative of the Airy Ai function.
     171
     172        EXAMPLES::
     173
     174            sage: x,n=var('x n')
     175            sage: airy_ai_prime(x)
     176            airy_ai_prime(x)
     177            sage: airy_ai_prime(0)
     178            -1/3*3^(2/3)/gamma(1/3)
     179        """
     180
     181        BuiltinFunction.__init__(self, "airy_ai_prime",
     182                latex_name=r"\operatorname{Ai}'",
     183                conversions=dict(mathematica='AiryAiPrime'))
     184
     185    def _derivative_(self, x, diff_param=None):
     186        """
     187        EXAMPLES::
     188
     189            sage: derivative(airy_ai_prime(x),x) # indirect doctest
     190            x*airy_ai(x)
     191        """
     192        return x*airy_ai_simple(x)
     193
     194    def _eval_(self, x):
     195        """
     196        EXAMPLES::
     197
     198            sage: airy_ai(1,0) # indirect doctest
     199            -1/3*3^(2/3)/gamma(1/3)
     200            sage: airy_ai(1,0.0) # indirect doctest
     201            -0.258819403792807
     202        """
     203        if not isinstance(x,Expression):
     204            if is_inexact(x):
     205                return self._evalf_(x, parent(x))
     206            elif x==0:
     207                r=R('1/3')
     208                return -1/(3**(r)*gamma(r))
     209        else:
     210            return None
     211
     212    def _evalf_(self, x, parent=None):
     213        """
     214        EXAMPLES::
     215       
     216            sage: airy_ai(1,0.0) # indirect doctest
     217            -0.258819403792807
     218        """
     219        return mpmath_utils.call(airy_ai_mpmath, x, derivative=1, parent=RR)
     220
     221airy_ai_general=FunctionAiryAiGeneral()
     222airy_ai_simple= FunctionAiryAiSimple()
     223airy_ai_prime=  FunctionAiryAiPrime()
     224
     225
     226def airy_ai(alpha,x=None, hold_derivative=False, *args, **kwds):
     227    r"""
     228    The Airy Ai function `\operatorname{Ai}(x)` is one of the two
     229    linearly independent solutions the Airy differental equation `f''(z) +f(z)x=0`,
     230    defined by the initial conditions:
     231
     232    .. math ::
     233        \operatorname{Ai}(0)=\frac{1}{2^{2/3} \Gamma(\frac{2}{3})},
     234
     235        \operatorname{Ai}'(0)=-\frac{1}{2^{1/3} \Gamma(\frac{1}{3})}.
     236
     237    Another way to define the Airy Ai function is:
     238
     239    .. math::
     240        \operatorname{Ai}(x)=\frac{1}{\pi}\int_0^\infty
     241        \cos\left(\frac{1}{3}t^3+xt\right) dt.
     242
     243    INPUT:
     244   
     245    - ``alpha``.- Return the `\alpha`-th order fractional derivative with respect to `z`. For `\alpha = n = 1,2,3,\ldots` this gives the derivative `\operatorname{Ai}^{(n)}(z)`, and for `\alpha = -n = -1,-2,-3,\ldots` this gives the `n`-fold iterated integral
     246     
     247    .. math ::
     248     
     249        f_0(z) = \operatorname{Ai}(z)
     250     
     251        f_n(z) = \int_0^z f_{n-1}(t) dt.
     252
     253    - ``x``.- The argument of the function.
     254
     255    - ``hold_derivative``.- Whether or not to stop from returning higher derivatives in terms of `\operatorname{Ai}(x)` and `\operatorname{Ai}'(x)`.
     256   
     257
     258    EXAMPLES::
     259
     260        sage: n,x=var('n x')
     261        sage: airy_ai(x)
     262        airy_ai(x)
     263
     264    It can return derivatives or integrals::
     265   
     266        sage: airy_ai(1,x)
     267        airy_ai_prime(x)
     268        sage: airy_ai(2,x)
     269        x*airy_ai(x)
     270        sage: airy_ai(2,x,True)
     271        airy_ai(2, x)
     272        sage: airy_ai(-2,x)
     273        airy_ai(-2, x)
     274        sage: airy_ai(n, x)
     275        airy_ai(n, x)
     276
     277    It can be evaluated symbolically or numerically for real or complex values::
     278
     279        sage: airy_ai(0)
     280        1/3*3^(1/3)/gamma(2/3)
     281        sage: airy_ai(0.0)
     282        0.355028053887817
     283        sage: airy_ai(I)
     284        airy_ai(I)
     285        sage: airy_ai(1.0*I)
     286        0.331493305432141 - 0.317449858968444*I
     287
     288    And the derivatives can be evaluated::
     289
     290        sage: airy_ai(1,0)
     291        -1/3*3^(2/3)/gamma(1/3)
     292        sage: airy_ai(1,0.0)
     293        -0.258819403792807
     294
     295    Plots::
     296
     297        sage: plot(airy_ai(x),(x,-10,5))+plot(airy_ai_prime(x),(x,-10,5),color='red')
     298       
     299    **References**
     300     
     301    - Abramowitz, Milton; Stegun, Irene A., eds. (1965), "Chapter 10"
     302
     303    - http://en.wikipedia.org/wiki/Airy_function
     304    """
     305
     306    #We catch the case with no alpha
     307    if x==None:
     308        x=alpha
     309        return airy_ai_simple(x, **kwds)
     310    #We raise an error if there are too many arguments
     311    if len(args) > 0:
     312        raise TypeError, "Symbolic function airy_ai takes at most 3 arguments (%s given)"%(len(args)+3)
     313
     314    #We take care of all other cases.
     315    if hold_derivative:
     316        return airy_ai_general(alpha,x,**kwds)
     317    elif alpha==0:
     318        return airy_ai_simple(x, **kwds)
     319    elif alpha==1:
     320        return airy_ai_prime(x, **kwds)
     321    elif alpha>1:
     322        #we use a different variable here because if x is a
     323        #particular value, we would be differentiating a constant
     324        #which would return 0. What we want is the value of
     325        #the derivative at the value and not the derivative of
     326        #a particular value of the function.
     327        v=var('v')
     328        return derivative(airy_ai_simple(v,**kwds),v,alpha).subs(v=x)
     329    else:
     330        return airy_ai_general(alpha,x,**kwds)
     331
     332########################################################################
     333########################################################################
     334
     335class FunctionAiryBiGeneral(BuiltinFunction):
     336    def __init__(self):
     337        """
     338        The generalized derivative of the Airy Bi function
     339
     340        INPUT:
     341       
     342        - ``alpha``.- Return the `\alpha`-th order fractional derivative with respect to `z`. For `\alpha = n = 1,2,3,\ldots` this gives the derivative `\operatorname{Bi}^{(n)}(z)`, and for `\alpha = -n = -1,-2,-3,\ldots` this gives the `n`-fold iterated integral
     343         
     344        .. math ::
     345         
     346            f_0(z) = \operatorname{Bi}(z)
     347         
     348            f_n(z) = \int_0^z f_{n-1}(t) dt.
     349
     350        - ``x``.- The argument of the function.
     351
     352        - ``hold``.- Whether or not to stop from returning higher derivatives in terms of `\operatorname{Bi}(x)` and `\operatorname{Bi}'(x)`.
     353       
     354        EXAMPLES::
     355
     356            sage: x,n=var('x n')
     357            sage: airy_bi(-2,x)
     358            airy_bi(-2, x)
     359            sage: derivative(airy_bi(-2,x),x)
     360            airy_bi(-1, x)
     361            sage: airy_bi(n,x)
     362            airy_bi(n, x)
     363            sage: derivative(airy_bi(n,x),x)
     364            airy_bi(n + 1, x)
     365            sage: airy_bi(2,x,True)
     366            airy_bi(2, x)
     367            sage: derivative(airy_bi(2,x,hold_derivative=True),x)
     368            airy_bi(3, x)
     369        """
     370
     371        BuiltinFunction.__init__(self, "airy_bi", nargs=2,
     372            latex_name=r"\operatorname{Bi}")
     373
     374    def _derivative_(self, alpha, *args, **kwds):
     375        """
     376        EXAMPLES::
     377
     378            sage: x,n=var('x n')
     379            sage: derivative(airy_bi(n,x),x) # indirect doctest
     380            airy_bi(n + 1, x)
     381        """
     382
     383        x=args[0]
     384        return airy_bi_general(alpha+1,x)
     385
     386    def _eval_(self, alpha, *args):
     387        """
     388        EXAMPLES::
     389
     390            sage: x,n=var('x n')
     391            sage: airy_bi(-2,1.0) # indirect doctest
     392            0.388621540699059
     393            sage: airy_bi(n,1.0) # indirect doctest
     394            airy_bi(n, 1.00000000000000)
     395        """
     396
     397       
     398        x=args[0]
     399        if not isinstance(x,Expression) and not isinstance(alpha,Expression):
     400            if is_inexact(x):
     401                return self._evalf_(alpha,x, parent(x))
     402        else:
     403            return None
     404
     405    def _evalf_(self, alpha, x, parent=None):
     406        """
     407        EXAMPLES::
     408            sage: airy_bi(-2,1.0) # indirect doctest
     409            0.388621540699059
     410        """
     411        return mpmath_utils.call(airy_bi_mpmath, x, derivative=alpha, parent=RR)
     412
     413class FunctionAiryBiSimple(BuiltinFunction):
     414    def __init__(self):
     415        """
     416        The class for the Airy Bi function.
     417
     418        EXAMPLES::
     419
     420            sage: airy_bi_simple= FunctionAiryBiSimple()
     421            sage: f=airy_bi_simple(x); f
     422            airy_bi(x)
     423        """
     424
     425        BuiltinFunction.__init__(self, "airy_bi", latex_name=r'\operatorname{Bi}',
     426                conversions=dict(mathematica='AiryBi'))
     427
     428    def _derivative_(self, x, diff_param=None):
     429        """
     430        EXAMPLES::
     431       
     432            sage: derivative(airy_bi(x),x) # indirect doctest
     433            airy_bi_prime(x)
     434        """
     435        return airy_bi_prime(x)
     436
     437    def _eval_(self, x):
     438        """
     439        EXAMPLES::
     440       
     441            sage: airy_bi(0) # indirect doctest
     442            1/3*3^(5/6)/gamma(1/3)
     443            sage: airy_bi(0.0) # indirect doctest
     444            0.614926627446001
     445            sage: airy_bi(I) # indirect doctest
     446            airy_bi(I)
     447            sage: airy_bi(1.0*I) # indirect doctest
     448            0.648858208330395 + 0.344958634768048*I
     449        """
     450
     451        if not isinstance(x,Expression):
     452            if is_inexact(x):
     453                return self._evalf_(x, parent(x))
     454            elif x==0:
     455                return 1/(3**(R('1/6'))*gamma(R('2/6')))
     456        else:
     457            return None
     458
     459    def _evalf_(self, x, parent=None):
     460        """
     461        EXAMPLES::
     462       
     463            sage: airy_bi(0.0) # indirect doctest
     464            0.614926627446001
     465            sage: airy_bi(1.0*I) # indirect doctest
     466            0.648858208330395 + 0.344958634768048*I
     467        """
     468        return mpmath_utils.call(airy_bi_mpmath, x, parent=RR)
     469
     470class FunctionAiryBiPrime(BuiltinFunction):
     471    def __init__(self):
     472        """
     473        The derivative of the Airy Bi function.
     474
     475        EXAMPLES::
     476
     477            sage: x,n=var('x n')
     478            sage: airy_bi_prime(x) # indirect doctest
     479            airy_bi_prime(x)
     480            sage: airy_bi_prime(0) # indirect doctest
     481            3^(1/6)/gamma(1/3)
     482        """
     483
     484        BuiltinFunction.__init__(self, "airy_bi_prime",
     485                latex_name=r"\operatorname{Bi}'",
     486                conversions=dict(mathematica='AiryBiPrime'))
     487
     488    def _derivative_(self, x, diff_param=None):
     489        """
     490        EXAMPLES::
     491
     492            sage: derivative(airy_bi_prime(x),x) # indirect doctest
     493            x*airy_bi(x)
     494        """
     495        return x*airy_bi_simple(x)
     496
     497    def _eval_(self, x):
     498        """
     499        EXAMPLES::
     500
     501            sage: airy_bi(1,0) # indirect doctest
     502            3^(1/6)/gamma(1/3)
     503            sage: airy_bi(1,0.0) # indirect doctest
     504            0.448288357353826
     505        """
     506        if not isinstance(x,Expression):
     507            if is_inexact(x):
     508                return self._evalf_(x, parent(x))
     509            elif x==0:
     510                return 3**(R('1/6'))/gamma(R('1/3'))
     511        else:
     512            return None
     513
     514    def _evalf_(self, x, parent=None):
     515        """
     516        EXAMPLES::
     517       
     518            sage: airy_bi(1,0.0) # indirect doctest
     519            0.448288357353826
     520        """
     521        return mpmath_utils.call(airy_bi_mpmath, x, derivative=1, parent=RR)
     522
     523airy_bi_general=FunctionAiryBiGeneral()
     524airy_bi_simple= FunctionAiryBiSimple()
     525airy_bi_prime=  FunctionAiryBiPrime()
     526
     527def airy_bi(alpha,x=None, hold_derivative=False, *args, **kwds):
     528    r"""
     529    The Airy Bi function `\operatorname{Bi}(x)` is one of the two
     530    linearly independent solutions the Airy differental equation `f''(z) +f(z)x=0`,
     531    defined by the initial conditions:
     532
     533    .. math ::
     534        \operatorname{Bi}(0)=\frac{1}{3^{1/6} \Gamma(\frac{2}{3})},
     535
     536        \operatorname{Bi}'(0)=\frac{3^{1/6}}{ \Gamma(\frac{1}{3})}.
     537
     538    Another way to define the Airy Bi function is:
     539
     540    .. math::
     541        \operatorname{Bi}(x)=\frac{1}{\pi}\int_0^\infty
     542        \left[ \exp\left( xt -\frac{t^3}{3} \right)
     543        +\sin\left(xt + \frac{1}{3}t^3\right) \right ] dt.
     544
     545    INPUT:
     546   
     547    - ``alpha``.- Return the `\alpha`-th order fractional derivative with respect to `z`. For `\alpha = n = 1,2,3,\ldots` this gives the derivative `\operatorname{Bi}^{(n)}(z)`, and for `\alpha = -n = -1,-2,-3,\ldots` this gives the `n`-fold iterated integral
     548     
     549    .. math ::
     550     
     551        f_0(z) = \operatorname{Bi}(z)
     552     
     553        f_n(z) = \int_0^z f_{n-1}(t) dt.
     554
     555    - ``x``.- The argument of the function.
     556
     557    - ``hold_derivative``.- Whether or not to stop from returning higher derivatives in terms of `\operatorname{Bi}(x)` and `\operatorname{Bi}'(x)`.
     558   
     559
     560    EXAMPLES::
     561
     562        sage: n,x=var('n x')
     563        sage: airy_bi(x)
     564        airy_bi(x)
     565
     566    It can return derivatives or integrals::
     567   
     568        sage: airy_bi(1,x)
     569        airy_bi_prime(x)
     570        sage: airy_bi(2,x)
     571        x*airy_bi(x)
     572        sage: airy_bi(2,x,True)
     573        airy_bi(2, x)
     574        sage: airy_bi(-2,x)
     575        airy_bi(-2, x)
     576        sage: airy_bi(n, x)
     577        airy_bi(n, x)
     578
     579    It can be evaluated symbolically or numerically for real or complex values::
     580
     581        sage: airy_bi(0)
     582        1/3*3^(5/6)/gamma(1/3)
     583        sage: airy_bi(0.0)
     584        0.614926627446001
     585        sage: airy_bi(I)
     586        airy_bi(I)
     587        sage: airy_bi(1.0*I)
     588        0.648858208330395 + 0.344958634768048*I
     589
     590    And the derivatives can be evaluated::
     591
     592        sage: airy_bi(1,0)
     593        3^(1/6)/gamma(1/3)
     594        sage: airy_bi(1,0.0)
     595        0.448288357353826
     596
     597    Plots::
     598
     599        sage: plot(airy_bi(x),(x,-10,5))+plot(airy_bi_prime(x),(x,-10,5),color='red')
     600       
     601    **References**
     602     
     603    - Abramowitz, Milton; Stegun, Irene A., eds. (1965), "Chapter 10"
     604
     605    - http://en.wikipedia.org/wiki/Airy_function
     606    """
     607
     608    #We catch the case with no alpha
     609    if x==None:
     610        x=alpha
     611        return airy_bi_simple(x, **kwds)
     612    #We raise an error if there are too many arguments
     613    if len(args) > 0:
     614        raise TypeError, "Symbolic function airy_ai takes at most 3 arguments (%s given)"%(len(args)+3)
     615
     616    #We take care of all other cases.
     617    if hold_derivative:
     618        return airy_bi_general(alpha,x,**kwds)
     619    elif alpha==0:
     620        return airy_bi_simple(x, **kwds)
     621    elif alpha==1:
     622        return airy_bi_prime(x, **kwds)
     623    elif alpha>1:
     624        #we use a different variable here because if x is a
     625        #particular value, we would be differentiating a constant
     626        #which would return 0. What we want is the value of
     627        #the derivative at the value and not the derivative of
     628        #a particular value of the function.
     629        v=var('v')
     630        return derivative(airy_bi_simple(v,**kwds),v,alpha).subs(v=x)
     631    else:
     632        return airy_bi_general(alpha,x,**kwds)
     633
  • sage/functions/all.py

    diff -r 2a2abbcad325 -r bdc9f1b2d4c2 sage/functions/all.py
    a b  
     1from airy import airy_ai, airy_bi
     2
    13from piecewise import piecewise, Piecewise
    24
    35from trig import ( sin, cos, sec, csc, cot, tan,
     
    3739                     inverse_jacobi, log_gamma,
    3840                     lngamma, exp_int, error_fcn, elliptic_e,
    3941                     elliptic_f, elliptic_ec, elliptic_eu,
    40                      elliptic_kc, elliptic_pi, elliptic_j,
    41                      airy_ai, airy_bi)
     42                     elliptic_kc, elliptic_pi, elliptic_j)
    4243                       
    4344from orthogonal_polys import (chebyshev_T,
    4445                              chebyshev_U,
  • sage/functions/special.py

    diff -r 2a2abbcad325 -r bdc9f1b2d4c2 sage/functions/special.py
    a b  
    586586    return NewMaximaFunction()
    587587
    588588
    589 def airy_ai(x):
    590    r"""
    591    The function `Ai(x)` and the related function `Bi(x)`,
    592    which is also called an *Airy function*, are
    593    solutions to the differential equation
    594 
    595    .. math::
    596 
    597       y'' - xy = 0,
    598 
    599    known as the *Airy equation*. The initial conditions
    600    `Ai(0) = (\Gamma(2/3)3^{2/3})^{-1}`,
    601    `Ai'(0) = -(\Gamma(1/3)3^{1/3})^{-1}` define `Ai(x)`.
    602    The initial conditions `Bi(0) = 3^{1/2}Ai(0)`,
    603    `Bi'(0) = -3^{1/2}Ai'(0)` define `Bi(x)`.
    604 
    605    They are named after the British astronomer George Biddell Airy.
    606    They belong to the class of "Bessel functions of fractional order".
    607 
    608    EXAMPLES::
    609    
    610        sage: airy_ai(1.0)        # last few digits are random
    611        0.135292416312881400
    612        sage: airy_bi(1.0)        # last few digits are random
    613        1.20742359495287099
    614 
    615    REFERENCE:
    616 
    617    - Abramowitz and Stegun: Handbook of Mathematical Functions,
    618      http://www.math.sfu.ca/~cbm/aands/
    619 
    620    - http://en.wikipedia.org/wiki/Airy_function
    621    """
    622    _init()
    623    return RDF(meval("airy_ai(%s)"%RDF(x)))
    624 
    625 def airy_bi(x):
    626    r"""
    627    The function `Ai(x)` and the related function `Bi(x)`,
    628    which is also called an *Airy function*, are
    629    solutions to the differential equation
    630 
    631    .. math::
    632 
    633       y'' - xy = 0,
    634 
    635    known as the *Airy equation*. The initial conditions
    636    `Ai(0) = (\Gamma(2/3)3^{2/3})^{-1}`,
    637    `Ai'(0) = -(\Gamma(1/3)3^{1/3})^{-1}` define `Ai(x)`.
    638    The initial conditions `Bi(0) = 3^{1/2}Ai(0)`,
    639    `Bi'(0) = -3^{1/2}Ai'(0)` define `Bi(x)`.
    640 
    641    They are named after the British astronomer George Biddell Airy.
    642    They belong to the class of "Bessel functions of fractional order".
    643 
    644    EXAMPLES::
    645    
    646        sage: airy_ai(1)        # last few digits are random
    647        0.135292416312881400
    648        sage: airy_bi(1)        # last few digits are random
    649        1.20742359495287099
    650 
    651    REFERENCE:
    652 
    653    - Abramowitz and Stegun: Handbook of Mathematical Functions,
    654      http://www.math.sfu.ca/~cbm/aands/
    655 
    656    - http://en.wikipedia.org/wiki/Airy_function
    657    """
    658    _init()
    659    return RDF(meval("airy_bi(%s)"%RDF(x)))
    660 
    661 
    662589def bessel_I(nu,z,algorithm = "pari",prec=53):
    663590    r"""
    664591    Implements the "I-Bessel function", or "modified Bessel function,