# library.specfun Submodule¶

## Module Summary¶

Interfaces for the NAG Mark 28.6 specfun Chapter.

specfun - Approximations of Special Functions

This module is concerned with the provision of some commonly occurring physical and mathematical functions.

naginterfaces.library.examples.specfun :

This subpackage contains examples for the specfun module. See also the Examples subsection.

## Functionality Index¶

Airy function

, real argument

, real argument

, real argument

or , complex argument, optionally scaled: airy_ai_complex()

, real argument

or , complex argument, optionally scaled: airy_bi_complex()

Arccos

inverse circular cosine: arccos()

Arccosh

inverse hyperbolic cosine: arccosh()

Arcsin

inverse circular sine: arcsin()

Arcsinh

inverse hyperbolic sine: arcsinh()

Arctanh

inverse hyperbolic tangent: arctanh()

Bessel function

, complex argument, optionally scaled: bessel_i_complex()

, real argument

, real argument

, complex argument: bessel_j_seq_complex()

, complex argument, optionally scaled: bessel_j_complex()

, real argument

, real argument

, complex argument, optionally scaled: bessel_k_complex()

, real argument

, real argument

, complex argument, optionally scaled: bessel_y_complex()

, real argument

, real argument

beta function

Complement of the Cumulative Normal distribution

Complement of the Error function

complex argument, scaled

real argument

real argument, scaled

Cosine

Cosine Integral: integral_cos()

Cumulative Normal distribution function

Dawson’s Integral

Digamma function, scaled: polygamma_deriv()

Elliptic functions, Jacobian, sn, cn, dn

Elliptic integral

general

of 2nd kind, : ellipint_general_2()

Legendre form

complete of 1st kind, : ellipint_complete_1()

complete of 2nd kind, : ellipint_complete_2()

of 1st kind, : ellipint_legendre_1()

of 2nd kind, : ellipint_legendre_2()

of 3rd kind, : ellipint_legendre_3()

symmetrised

Erf

Erfc

complex argument, scaled

real argument

erfcx

Exponential

Exponential Integral: integral_exp()

Fresnel integral

Gamma function

Generalized factorial function

Hankel function or

complex argument, optionally scaled: hankel_complex()

Hypergeometric functions

, confluent, real argument: hyperg_confl_real()

, confluent, real argument, scaled form: hyperg_confl_real_scaled()

, Gauss, real argument: hyperg_gauss_real()

, Gauss, real argument, scaled form: hyperg_gauss_real_scaled()

Jacobian theta functions

Kelvin function

Legendre functions of 1st kind , : legendre_p()

Logarithm of : log_shifted()

Logarithm of beta function

Logarithm of gamma function

Mathieu function (angular)

periodic, real

Modified Struve function

, real argument

, real argument

, real argument

, real argument

Option Pricing

American option, Bjerksund and Stensland option price: opt_amer_bs_price()

Asian option, geometric continuous average rate price: opt_asian_geom_price()

Asian option, geometric continuous average rate price with Greeks: opt_asian_geom_greeks()

binary asset-or-nothing option price: opt_binary_aon_price()

binary asset-or-nothing option price with Greeks: opt_binary_aon_greeks()

binary cash-or-nothing option price: opt_binary_con_price()

binary cash-or-nothing option price with Greeks: opt_binary_con_greeks()

Black–Scholes implied volatility: opt_imp_vol()

Black–Scholes–Merton option price: opt_bsm_price()

Black–Scholes–Merton option price with Greeks: opt_bsm_greeks()

European option, option prices, using Merton jump-diffusion model: opt_jumpdiff_merton_price()

European option, option price with Greeks, using Merton jump-diffusion model: opt_jumpdiff_merton_greeks()

floating-strike lookback option price: opt_lookback_fls_price()

floating-strike lookback option price with Greeks: opt_lookback_fls_greeks()

Heston’s model option price: opt_heston_price()

Heston’s model option price with Greeks: opt_heston_greeks()

Heston’s model with term structure: opt_heston_term()

standard barrier option price: opt_barrier_std_price()

Polygamma function

psi function: polygamma()

psi function derivatives, scaled: polygamma_deriv()

Scaled modified Bessel function(s)

, real argument

, real argument

, real argument

, real argument

Sine

Sine Integral: integral_sin()

Struve function

, real argument

, real argument

Tangent

Trigamma function, scaled: polygamma_deriv()

Zeros of Bessel functions , , ,

For full information please refer to the NAG Library document

https://www.nag.com/numeric/nl/nagdoc_28.6/flhtml/s/sintro.html

## Examples¶

naginterfaces.library.examples.specfun.opt_bsm_price_ex.main()[source]

Computes the European option price given by the Black–Scholes–Merton formula.

>>> main()
naginterfaces.library.specfun.opt_bsm_price Python Example Results.
Prices for six European call options.
Strike     Expiry    Price
58.0000    0.7000    5.9198
58.0000    0.8000    6.5506
60.0000    0.7000    5.0809
60.0000    0.8000    5.6992
62.0000    0.7000    4.3389
62.0000    0.8000    4.9379

naginterfaces.library.examples.specfun.opt_heston_more_greeks_ex.main()[source]

Computes the European option price given by the Heston model, provides greeks and derivatives with respect to model parameters.

>>> main()
naginterfaces.library.specfun.opt_heston_more_greeks
Python Example Results.
Prices for four European call options.
q         r         Price     dp_dsigmav
0.0250    0.0100    6.5961   -1.9804
0.0250   -0.0100    7.9845   -1.7047
-0.0250    0.0100    3.9303   -2.4431
-0.0250   -0.0100    5.0138   -2.3868