| Version 9 (modified by kcrisman, 15 months ago) (diff) |
|---|
Sage is missing symbolic definitions for many special functions that we are capable of evaluating numerically. Some of these are even provided in symbolic form by maxima (see below for a list).
Implementing a symbolic function involves subclassing sage.symbolic.function.BuiltinFunction and defining custom evaluation (_eval_), numeric evaluation (_evalf_), differentiation (_derivative_), conjugate (_conjugate_), imaginary and real part methods (_{imag,real}_part_).
See sage.functions.other.Function_gamma_inc or sage.functions.trig.Function_cot for examples.
A list of tickets related to improving an existing function or implementing a new one:
- #9130 Access to beta function
- #3401 extend li to work with complex arguments
- #7357 add non offset logarithm
- #8383 make symbolic versions of moebius, sigma and euler_phi
- erf:
- bessel:
- #2516 hypergeometric function
- #4498 symbolic arg function
- #9874 derivative of ceil and floor
- #11143 exponential integral
- #10050 wrap the polylogarithm functions from pynac
- #10075 Make log gamma symbolic
- #11155 abs(pi+I) = pi+I (new _eval_ method for abs())
- #11423 Make atan2(0,0) consistent
- #10070 make heaviside and step play nicely together.
- #10074 Improve less-used hyperbolic functions
- #9424 make symbolic summation numerically evaluatable
- #12455 Make Airy functions symbolical
Tips for implementing custom methods
- Returning None in _eval_ leaves the function symbolic with the given input.
- ...
Special functions defined in Maxima
Notes from Benjamin Jones (#11143) ( http://maxima.sourceforge.net/docs/manual/en/maxima_16.html#SEC56)
bessel_j (index, expr) Bessel function, 1st kind bessel_y (index, expr) Bessel function, 2nd kind bessel_i (index, expr) Modified Bessel function, 1st kind bessel_k (index, expr) Modified Bessel function, 2nd kind
- Notes: bessel_I, bessel_J, etc. are functions in Sage for numerical evaluation. There is also the Bessel class, but no conversions from Maxima's bessel_i etc. to Sage.
hankel_1 (v,z) Hankel function of the 1st kind hankel_2 (v,z) Hankel function of the 2nd kind struve_h (v,z) Struve H function struve_l (v,z) Struve L function
- Notes: None of these functions are currently exposed at the top level in Sage. Evaluation is possible using mpmath.
assoc_legendre_p[v,u] (z) Legendre function of degree v and order u assoc_legendre_q[v,u] (z) Legendre function, 2nd kind
- Notes: In Sage we have legendre_P(n, x) and legendre_Q(n, x) both described as Legendre functions. It's not clear to me how there are related to Maxima's versions since the number of arguments differs.
%f[p,q] ([], [], expr) Generalized Hypergeometric function hypergeometric(l1, l2, z) Hypergeometric function slommel %m[u,k] (z) Whittaker function, 1st kind %w[u,k] (z) Whittaker function, 2nd kind
- Notes: hypergeometric(l1, l2, z) needs a conversion to Sage's hypergeometric_U. The others can be evaluated using mpmath. slommel is presumably mpmath's lommels1() or lommels2() (or both?). This isn't well documented in Maxima.
expintegral_e (v,z) Exponential integral E expintegral_e1 (z) Exponential integral E1 expintegral_ei (z) Exponential integral Ei expintegral_li (z) Logarithmic integral Li expintegral_si (z) Exponential integral Si expintegral_ci (z) Exponential integral Ci expintegral_shi (z) Exponential integral Shi expintegral_chi (z) Exponential integral Chi erfc (z) Complement of the erf function
- Notes: The exponential integral functions expintegral_e1 and expintegral_ei (z) are called exponential_integral_1 and Ei resp. in Sage. They both need conversions. The rest need BuiltinFunction classes defined for them with evaluation handled by mpmath and the symbol table conversion added. Also, erfc is called error_fcn, so also needs a conversion.
kelliptic (z) Complete elliptic integral of the first
kind (K)
parabolic_cylinder_d (v,z) Parabolic cylinder D function
- Notes: kelliptic(z) needs a conversion to elliptic_kc in Sage and parabolic_cylinder_d (v,z) does not seem to be exposed at top level. It can be evaluated by mpmath.
There are also some specific hypergeometric function defined in Maxima's contrib_ode package:
dgauss_a dgauss_b dkummer_m dkummer_u gauss_a gauss_b kummer_m kummer_u
which are returned by certain ODE solvers in Maxima and which mpmath can evaluate.
