Ticket #12455: trac_12455-symbolic_airy.patch

File trac_12455-symbolic_airy.patch, 5.9 KB (added by olazo, 8 years ago)
  • sage/functions/special.py

    # HG changeset patch
    # User Oscar Gerardo Lazo Arjona <algebraicamente@gmail.com>
    # Date 1328600994 21600
    # Node ID 88a61cc0d17afaf33b4043246d8b04642dc3e915
    # Parent  2a2abbcad325ccca9399981ceddf5897eb467e64
    #12455 Make Airy functions symbolical
    
    diff -r 2a2abbcad325 -r 88a61cc0d17a sage/functions/special.py
    a b  
    585585
    586586    return NewMaximaFunction()
    587587
     588class AiryAi(BuiltinFunction):
     589    r"""
     590    The function `Ai(x)` and the related function `Bi(x)`,
     591    which is also called an *Airy function*, are
     592    solutions to the differential equation
     593   
     594    .. math::
     595   
     596      y'' - xy = 0,
     597   
     598    known as the *Airy equation*. The initial conditions
     599    `Ai(0) = (\Gamma(2/3)3^{2/3})^{-1}`,
     600    `Ai'(0) = -(\Gamma(1/3)3^{1/3})^{-1}` define `Ai(x)`.
     601    The initial conditions `Bi(0) = 3^{1/2}Ai(0)`,
     602    `Bi'(0) = -3^{1/2}Ai'(0)` define `Bi(x)`.
     603   
     604    They are named after the British astronomer George Biddell Airy.
     605    They belong to the class of "Bessel functions of fractional order".
     606   
     607    EXAMPLES::
    588608
    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
     609        sage: var('x')
     610        sage: airy_ai(x)
     611        airy_ai(x)
     612        sage: airy_bi(x)
     613        airy_bi(x)
     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    def __init__(self):
     623        BuiltinFunction.__init__(self, "airy_ai", latex_name=r"\operatorname{Ai}")
    594624
    595    .. math::
     625    def _derivative_(self, x, diff_param=None): return airy_ai_prime(x)
     626   
     627    def _evalf_(self, x, parent=None):
     628        r"""
     629        EXAMPLES::
    596630
     631            sage: float(airy_ai(1.0))
     632            0.135292416313
     633        """       
     634        _init()
     635        return RDF(meval("airy_ai(%s)"%RDF(x)))
     636airy_ai=AiryAi()
     637
     638class AiryBi(BuiltinFunction):
     639    r"""
     640    The function `Ai(x)` and the related function `Bi(x)`,
     641    which is also called an *Airy function*, are
     642    solutions to the differential equation
     643   
     644    .. math::
     645   
    597646      y'' - xy = 0,
     647   
     648    known as the *Airy equation*. The initial conditions
     649    `Ai(0) = (\Gamma(2/3)3^{2/3})^{-1}`,
     650    `Ai'(0) = -(\Gamma(1/3)3^{1/3})^{-1}` define `Ai(x)`.
     651    The initial conditions `Bi(0) = 3^{1/2}Ai(0)`,
     652    `Bi'(0) = -3^{1/2}Ai'(0)` define `Bi(x)`.
     653   
     654    They are named after the British astronomer George Biddell Airy.
     655    They belong to the class of "Bessel functions of fractional order".
     656   
     657    EXAMPLES::
    598658
    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)`.
     659        sage: var('x')
     660        sage: airy_ai(x)
     661        airy_ai(x)
     662        sage: airy_bi(x)
     663        airy_bi(x)
     664   
     665    REFERENCE:
     666   
     667    - Abramowitz and Stegun: Handbook of Mathematical Functions,
     668     http://www.math.sfu.ca/~cbm/aands/
     669   
     670    - http://en.wikipedia.org/wiki/Airy_function
     671    """
     672    def __init__(self):
     673        BuiltinFunction.__init__(self, "airy_bi", latex_name=r"\operatorname{Bi}")
     674    def _derivative_(self, x, diff_param=None): return airy_ai_prime(x)
    604675
    605    They are named after the British astronomer George Biddell Airy.
    606    They belong to the class of "Bessel functions of fractional order".
     676    def _evalf_(self, x, parent=None):
     677        r"""
     678        EXAMPLES::
    607679
    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
     680            sage: float(airy_bi(1.0))
     681            1.20742359495
     682        """
     683        _init()
     684        return RDF(meval("airy_bi(%s)"%RDF(x)))
     685airy_bi=AiryBi()
    614686
    615    REFERENCE:
     687class AiryAiPrime(BuiltinFunction):
     688    r"""
     689    The derivative of the Airy function `Ai(x)`.
     690    """
     691    def __init__(self):
     692        BuiltinFunction.__init__(self, "airy_ai_prime", latex_name=r"\operatorname{Ai}'")
     693airy_ai_prime=AiryAiPrime()
    616694
    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 
     695class AiryBiPrime(BuiltinFunction):
     696    r"""
     697    The derivative of the Airy function `Bi(x)`.
     698    """
     699    def __init__(self):
     700        BuiltinFunction.__init__(self, "airy_bi_prime", latex_name=r"\operatorname{Bi}'")
     701airy_bi_prime=AiryBiPrime()
    661702
    662703def bessel_I(nu,z,algorithm = "pari",prec=53):
    663704    r"""