library.specfun Submodule

Module Summary

Interfaces for the NAG Mark 30.3 specfun Chapter.

specfun - Approximations of Special Functions

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

See Also

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

regularized incomplete

Complement of the Cumulative Normal distribution

Complement of the Error function

complex argument, scaled

real argument

scalar: erfc_real()

vectorized: erfc_real_vector()

real argument, scaled

scalar: erfcx_real()

vectorized: erfcx_real_vector()

Cosine

hyperbolic: cosh()

Cosine Integral: integral_cos()

Cumulative Normal distribution function

scalar: cdf_normal()

vectorized: cdf_normal_vector()

Dawson’s Integral

scalar: dawson()

vectorized: dawson_vector()

Digamma function, scaled: polygamma_deriv()

Elliptic functions, Jacobian, sn, cn, dn

complex argument: jacellip_complex()

real argument: jacellip_real()

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

degenerate of 1st kind, : ellipint_symm_1_degen()

of 1st kind, : ellipint_symm_1()

of 2nd kind, : ellipint_symm_2()

of 3rd kind, : ellipint_symm_3()

Erf

real argument

scalar: erf_real()

vectorized: erf_real_vector()

Erfc

complex argument, scaled

real argument

scalar: erfc_real()

vectorized: erfc_real_vector()

erfcx

real argument

scalar: erfcx_real()

vectorized: erfcx_real_vector()

Exponential

complex: exp_complex()

Exponential Integral: integral_exp()

Fresnel integral

scalar: fresnel_c()

vectorized: fresnel_c_vector()

scalar: fresnel_s()

vectorized: fresnel_s_vector()

Gamma function

incomplete

scalar: gamma()

vectorized: gamma_vector()

Generalized factorial function

scalar: gamma()

vectorized: gamma_vector()

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

real argument: jactheta_real()

Kelvin function

scalar: kelvin_bei()

vectorized: kelvin_bei_vector()

scalar: kelvin_ber()

vectorized: kelvin_ber_vector()

scalar: kelvin_kei()

vectorized: kelvin_kei_vector()

scalar: kelvin_ker()

vectorized: kelvin_ker_vector()

Legendre functions of 1st kind , : legendre_p()

Logarithm of : log_shifted()

Logarithm of beta function

real

Logarithm of gamma function

Mathieu function (angular)

periodic, real

Modified Struve function

, real argument

, real argument

, real argument

scalar: struve_l0()

, real argument

scalar: struve_l1()

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 option price with Greeks, sensitivities of model parameters and negative rates: opt_heston_more_greeks()

Heston’s model with term structure: opt_heston_term()

standard barrier option price: opt_barrier_std_price()

Polygamma function

, real : psi_deriv_real()

, complex : psi_deriv_complex()

psi function: polygamma()

psi function derivatives, scaled: polygamma_deriv()

Scaled modified Bessel function(s)

, real argument

, real argument

, real argument

, real argument

Sine

hyperbolic: sinh()

Sine Integral: integral_sin()

Struve function

, real argument

scalar: struve_h0()

, real argument

scalar: struve_h1()

Tangent

circular: tan()

hyperbolic: tanh()

Trigamma function, scaled: polygamma_deriv()

Zeros of Bessel functions , , ,

For full information please refer to the NAG Library document

https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/s/sintro.html

Examples

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

Example for naginterfaces.library.specfun.opt_bsm_price().

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]

Example for naginterfaces.library.specfun.opt_heston_more_greeks().

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